Skip to content

Commit

Permalink
Merge pull request #125 from dscho/fix-pcre2-relnotes
Browse files Browse the repository at this point in the history
Fix PCRE2 `/add release note`
  • Loading branch information
dscho authored Feb 21, 2025
2 parents 35cd252 + 8061e70 commit 5487d90
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
10 changes: 7 additions & 3 deletions GitForWindowsHelper/component-updates.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const guessComponentUpdateDetails = (title, body) => {
else if (['clang', 'llvm', 'mingw-w64-clang'].includes(package_name)) package_name = 'mingw-w64-llvm'

version = version
.replace(/^(GCM |openssl-|OpenSSL_|v|V_|GnuTLS |tig-|Heimdal |cygwin-|PCRE2-|Bash-|curl-|gnupg-|is-)/, '')
.replace(/^(GCM |openssl-|OpenSSL_|v|V_|GnuTLS |tig-|Heimdal |cygwin-|PCRE2-|Bash-|curl-|gnupg-|is-|pcre2-)/, '')
.replace(/\s+patch\s+/, '.')
.replace(/_/g, '.')
.replace(/-release$/, '')
Expand Down Expand Up @@ -147,7 +147,8 @@ const pacmanRepositoryURLs = (package_name, version, architectures) =>
architectures.map(arch => {
const fileName = isMSYSPackage(package_name)
? `${package_name}-${version}-1-${arch}.pkg.tar.xz`
: `${package_name.replace(/^mingw-w64/, `$&-${arch}`)}-${version}-1-any.pkg.tar.xz`
: `${package_name.replace(/^mingw-w64/,
`$&-${arch === 'aarch64' ? `clang-${arch}` : arch}`)}-${version}-1-any.pkg.tar.xz`
return `${pacmanRepositoryBaseURL}${arch.replace(/_/g, '-')}/${fileName}`
})

Expand All @@ -163,11 +164,14 @@ const getMissingDeployments = async (package_name, version) => {
if (package_name === 'msys2-runtime') architectures.shift()
else if (package_name === 'msys2-runtime-3.3') architectures.pop()

const mingwArchitectures = [...architectures, 'aarch64']
const urls = []
const msysName = package_name.replace(/^mingw-w64-/, '')
if (packageNeedsBothMSYSAndMINGW(msysName)) {
urls.push(...pacmanRepositoryURLs(msysName, version, architectures))
urls.push(...pacmanRepositoryURLs(`mingw-w64-${msysName}`, version, architectures))
urls.push(...pacmanRepositoryURLs(`mingw-w64-${msysName}`, version, mingwArchitectures))
} else if (package_name !== msysName) {
urls.push(...pacmanRepositoryURLs(package_name, version, mingwArchitectures))
} else {
urls.push(...pacmanRepositoryURLs(package_name, version, architectures))
}
Expand Down
21 changes: 19 additions & 2 deletions __tests__/component-updates.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,20 @@ href="[email protected]/">cygwin 3.4.7-1</a></b>
</pre>[... even more stuff...]</body></html>`
}
const missingURL = 'https://wingit.blob.core.windows.net/x86-64/curl-8.1.2-1-x86_64.pkg.tar.xz'
const missingAarch64URL = 'https://wingit.blob.core.windows.net/aarch64/mingw-w64-clang-aarch64-curl-8.1.2-1-any.pkg.tar.xz'
const missingMinTTYURL = 'https://wingit.blob.core.windows.net/i686/mintty-1~3.6.5-1-i686.pkg.tar.xz'
const bogus32BitMSYS2RuntimeURL = 'https://wingit.blob.core.windows.net/i686/msys2-runtime-3.4.9-1-i686.pkg.tar.xz'
const bogus64BitMSYS2RuntimeURL = 'https://wingit.blob.core.windows.net/x86-64/msys2-runtime-3.3-3.3.7-1-x86_64.pkg.tar.xz'
const missingOpenSSHURL = 'https://wingit.blob.core.windows.net/i686/openssh-9.5p1-1-i686.pkg.tar.xz'
const missingBashURL = 'https://wingit.blob.core.windows.net/x86-64/bash-5.2.020-1-x86_64.pkg.tar.xz'
const mockDoesURLReturn404 = jest.fn(url => [
missingURL, missingMinTTYURL, bogus32BitMSYS2RuntimeURL, bogus64BitMSYS2RuntimeURL, missingOpenSSHURL, missingBashURL
missingURL,
missingAarch64URL,
missingMinTTYURL,
bogus32BitMSYS2RuntimeURL,
bogus64BitMSYS2RuntimeURL,
missingOpenSSHURL,
missingBashURL
].includes(url))
jest.mock('../GitForWindowsHelper/https-request', () => {
return {
Expand Down Expand Up @@ -204,10 +211,20 @@ http://www.gnutls.org/news.html#2023-02-10`
package: 'msys2-runtime',
version: '3.4.7'
})
expect(await guessReleaseNotes(context, {
labels: [{ name: 'component-update' }],
title: '[New pcre2 version] pcre2-10.45',
body: `\n\nhttps://github.com/PCRE2Project/pcre2/releases/tag/pcre2-10.45`
})).toEqual({
type: 'feature',
message: 'Comes with [PCRE2 v10.45](https://github.com/PCRE2Project/pcre2/releases/tag/pcre2-10.45).',
package: 'pcre2',
version: '10.45'
})
})

test('getMissingDeployments()', async () => {
expect(await getMissingDeployments('curl', '8.1.2')).toEqual([missingURL])
expect(await getMissingDeployments('curl', '8.1.2')).toEqual([missingURL, missingAarch64URL])
expect(await getMissingDeployments('mintty', '3.6.5')).toEqual([missingMinTTYURL])
expect(await getMissingDeployments('msys2-runtime', '3.4.9')).toEqual([])
expect(await getMissingDeployments('msys2-runtime-3.3', '3.3.7')).toEqual([])
Expand Down
4 changes: 2 additions & 2 deletions __tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ The workflow run [was started](dispatched-workflow-add-release-note.yml)`,
})
expect(mockGetInstallationAccessToken).toHaveBeenCalledTimes(1)
expect(mockGitHubApiRequestAsApp).not.toHaveBeenCalled()
expect(mockDoesURLReturn404).toHaveBeenCalledTimes(4)
expect(mockDoesURLReturn404).toHaveBeenCalledTimes(5)
expect(dispatchedWorkflows).toHaveLength(1)
expect(dispatchedWorkflows[0].payload.inputs).toEqual({
message: 'Comes with [GNU TLS v3.8.0](https://lists.gnupg.org/pipermail/gnutls-help/2023-February/004816.html).',
Expand All @@ -763,7 +763,7 @@ testIssueComment({ comment: '/add release note', note: 'missing deployment' }, {
})
expect(mockGetInstallationAccessToken).toHaveBeenCalledTimes(1)
expect(mockGitHubApiRequestAsApp).not.toHaveBeenCalled()
expect(mockDoesURLReturn404).toHaveBeenCalledTimes(2)
expect(mockDoesURLReturn404).toHaveBeenCalledTimes(3)
expect(dispatchedWorkflows).toHaveLength(0)
})

Expand Down

0 comments on commit 5487d90

Please sign in to comment.