Skip to content

Commit 81c2bcf

Browse files
authored
Merge pull request #43 from dscho/adjust-msys2-runtime-deployment-expectations
Adjust `msys2-runtime` deployment expectations
2 parents aaba09c + 94c132a commit 81c2bcf

2 files changed

Lines changed: 20 additions & 13 deletions

File tree

GitForWindowsHelper/component-updates.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,27 +109,28 @@ const guessReleaseNotes = async (context, issue) => {
109109

110110
const pacmanRepositoryBaseURL = 'https://wingit.blob.core.windows.net/'
111111

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-
]
112+
const pacmanRepositoryURLs = (package_name, version, architectures) =>
113+
architectures.map(arch => {
114+
const fileName = isMSYSPackage(package_name)
115+
? `${package_name}-${version}-1-${arch}.pkg.tar.xz`
116+
: `${package_name.replace(/^mingw-w64/, `$&-${arch}`)}-${version}-1-any.pkg.tar.xz`
117+
return `${pacmanRepositoryBaseURL}${arch.replace(/_/g, '-')}/${fileName}`
118+
})
121119

122120
const getMissingDeployments = async (package_name, version) => {
123121
// MinTTY is at epoch 1, which is part of Pacman's versioning scheme
124122
if (package_name === 'mintty') version = `1~${version}`
123+
const architectures = ['i686', 'x86_64']
124+
if (package_name === 'msys2-runtime') architectures.shift()
125+
else if (package_name === 'msys2-runtime-3.3') architectures.pop()
125126

126127
const urls = []
127128
const msysName = package_name.replace(/^mingw-w64-/, '')
128129
if (packageNeedsBothMSYSAndMINGW(msysName)) {
129-
urls.push(...pacmanRepositoryURLs(msysName, version))
130-
urls.push(...pacmanRepositoryURLs(`mingw-w64-${msysName}`, version))
130+
urls.push(...pacmanRepositoryURLs(msysName, version, architectures))
131+
urls.push(...pacmanRepositoryURLs(`mingw-w64-${msysName}`, version, architectures))
131132
} else {
132-
urls.push(...pacmanRepositoryURLs(package_name, version))
133+
urls.push(...pacmanRepositoryURLs(package_name, version, architectures))
133134
}
134135
const { doesURLReturn404 } = require('./https-request')
135136
const result = await Promise.all(urls.map(async url => doesURLReturn404(url)))

__tests__/component-updates.test.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,17 @@ http://www.gnutls.org/news.html#2023-02-10`
132132
test('getMissingDeployments()', async () => {
133133
const missingURL = 'https://wingit.blob.core.windows.net/x86-64/curl-8.1.2-1-x86_64.pkg.tar.xz'
134134
const missingMinTTYURL = 'https://wingit.blob.core.windows.net/i686/mintty-1~3.6.5-1-i686.pkg.tar.xz'
135-
const mockDoesURLReturn404 = jest.fn(url => url === missingURL || url === missingMinTTYURL)
135+
const bogus32BitMSYS2RuntimeURL = 'https://wingit.blob.core.windows.net/i686/msys2-runtime-3.4.9-1-i686.pkg.tar.xz'
136+
const bogus64BitMSYS2RuntimeURL = 'https://wingit.blob.core.windows.net/x86-64/msys2-runtime-3.3-3.3.7-1-x86_64.pkg.tar.xz'
137+
const mockDoesURLReturn404 = jest.fn(url => [
138+
missingURL, missingMinTTYURL, bogus32BitMSYS2RuntimeURL, bogus64BitMSYS2RuntimeURL
139+
].includes(url))
136140
jest.mock('../GitForWindowsHelper/https-request', () => {
137141
return { doesURLReturn404: mockDoesURLReturn404 }
138142
})
139143

140144
expect(await getMissingDeployments('curl', '8.1.2')).toEqual([missingURL])
141145
expect(await getMissingDeployments('mintty', '3.6.5')).toEqual([missingMinTTYURL])
146+
expect(await getMissingDeployments('msys2-runtime', '3.4.9')).toEqual([])
147+
expect(await getMissingDeployments('msys2-runtime-3.3', '3.3.7')).toEqual([])
142148
})

0 commit comments

Comments
 (0)