Skip to content

Commit 741a618

Browse files
committed
Add a function to determine whether a package has been deployed completely
In git-for-windows/git#4567 it was pointed out that Git LFS v3.3.0 is shipped with Git for Windows v2.42.0, but the release notes state that the current version is v3.4.0. In preparation for making `/add relnote` a bit safer to use, introduce the functionality in the GitForWindowsHelper GitHub App to determine whether a given version of a given package has been deployed, and if not, which parts are missing (indicated by the respective Pacman repository URL(s)). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent e5b5533 commit 741a618

2 files changed

Lines changed: 41 additions & 3 deletions

File tree

GitForWindowsHelper/component-updates.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,38 @@ const guessReleaseNotes = async (context, issue) => {
107107
}
108108
}
109109

110+
const pacmanRepositoryBaseURL = 'https://wingit.blob.core.windows.net/'
111+
112+
const pacmanRepositoryURLs = (package_name, version) =>
113+
isMSYSPackage(package_name)
114+
? [
115+
`${pacmanRepositoryBaseURL}i686/${package_name}-${version}-1-i686.pkg.tar.xz`,
116+
`${pacmanRepositoryBaseURL}x86-64/${package_name}-${version}-1-x86_64.pkg.tar.xz`
117+
] : [
118+
`${pacmanRepositoryBaseURL}i686/${package_name.replace(/^mingw-w64/, '$&-i686')}-${version}-1-any.pkg.tar.xz`,
119+
`${pacmanRepositoryBaseURL}x86-64/${package_name.replace(/^mingw-w64/, '$&-x86_64')}-${version}-1-any.pkg.tar.xz`
120+
]
121+
122+
const getMissingDeployments = async (package_name, version) => {
123+
const urls = []
124+
const msysName = package_name.replace(/^mingw-w64-/, '')
125+
if (packageNeedsBothMSYSAndMINGW(msysName)) {
126+
urls.push(...pacmanRepositoryURLs(msysName, version))
127+
urls.push(...pacmanRepositoryURLs(`mingw-w64-${msysName}`, version))
128+
} else {
129+
urls.push(...pacmanRepositoryURLs(package_name, version))
130+
}
131+
const { doesURLReturn404 } = require('./https-request')
132+
const result = await Promise.all(urls.map(async url => doesURLReturn404(url)))
133+
return urls.filter((_, index) => result[index])
134+
}
135+
110136
module.exports = {
111137
guessComponentUpdateDetails,
112138
guessReleaseNotes,
113139
prettyPackageName,
114140
isMSYSPackage,
115141
packageNeedsBothMSYSAndMINGW,
116-
needsSeparateARM64Build
142+
needsSeparateARM64Build,
143+
getMissingDeployments
117144
}

__tests__/component-updates.test.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const {
22
guessComponentUpdateDetails,
3-
guessReleaseNotes
3+
guessReleaseNotes,
4+
getMissingDeployments
45
} = require('../GitForWindowsHelper/component-updates')
56

67
const bashTicketBody = `# [New bash version] Bash-5.2 patch 15: fix too-aggressive optimizing forks out of subshell commands
@@ -126,4 +127,14 @@ http://www.gnutls.org/news.html#2023-02-10`
126127
package: 'openssl',
127128
version: '3.1.1'
128129
})
129-
})
130+
})
131+
132+
test('getMissingDeployments()', async () => {
133+
const missingURL = 'https://wingit.blob.core.windows.net/x86-64/curl-8.1.2-1-x86_64.pkg.tar.xz'
134+
const mockDoesURLReturn404 = jest.fn(url => url === missingURL)
135+
jest.mock('../GitForWindowsHelper/https-request', () => {
136+
return { doesURLReturn404: mockDoesURLReturn404 }
137+
})
138+
139+
expect(await getMissingDeployments('curl', '8.1.2')).toEqual([missingURL])
140+
})

0 commit comments

Comments
 (0)