Skip to content

Commit 72733bf

Browse files
committed
guessReleaseNotes(msys2-runtime): link to Cygwin's release notes
When a `component-update` ticket notices that a new Cygwin runtime version is available, the plan is to allow calling the usual `/open pr` and `/add release note` dance. The `/open pr` support will take a bit more work, as a merging rebase is involved that requires a PR at https://github.com/git-for-windows/msys2-runtime, and once merged, a follow-up one at https://github.com/git-for-windows/MSYS2-packages. But we can already tackle (and use) the `/add release note` part. This here patch forward-ports how things were done before GitHub Actions: https://github.com/git-for-windows/build-extra/blob/356779ddb189/please.sh#L1727-L1730 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent bd52324 commit 72733bf

2 files changed

Lines changed: 50 additions & 1 deletion

File tree

GitForWindowsHelper/component-updates.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,31 @@ const needsSeparateARM64Build = package_name => {
5555
].includes(package_name)
5656
}
5757

58+
const guessCygwinReleaseNotesURL = async (version) => {
59+
const { fetchHTML } = require('./https-request')
60+
const html = await fetchHTML('https://cygwin.com')
61+
const match = html.match(new RegExp(`The most recent version of the Cygwin DLL is[^]*?<a href=['"]?([^"' ]*)[^>]*>${version}</a>`))
62+
if (match) return match[1]
63+
64+
throw new Error(`Could not determine Cygwin Release Notes URL for version ${version}`)
65+
}
66+
5867
const guessReleaseNotes = async (context, issue) => {
5968
if (!issue.pull_request
6069
&&issue.labels.filter(label => label.name === 'component-update').length !== 1) throw new Error(`Cannot determine release note from issue ${issue.number}`)
6170
let { package_name, version } = guessComponentUpdateDetails(issue.title, issue.body)
6271

72+
if (package_name === 'msys2-runtime') {
73+
const url = await guessCygwinReleaseNotesURL(version)
74+
const message = `Comes with the MSYS2 runtime (Git for Windows flavor) based on [Cygwin v${version}](${url}).`
75+
return {
76+
type: 'feature',
77+
message,
78+
package: package_name,
79+
version
80+
}
81+
}
82+
6383
const matchURLInIssue = (issue) => {
6484
const pattern = {
6585
bash: /(?:^|\n)(https:\/\/\S+)/, // use the first URL

__tests__/component-updates.test.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,21 @@ jest.mock('../GitForWindowsHelper/github-api-request', () => {
5656
return mockGithubApiRequest
5757
})
5858

59+
const mockFetchHTML = {
60+
'https://cygwin.com': `<div>
61+
62+
<h2 class="cartouche">Cygwin version</h2>
63+
64+
<p>
65+
The most recent version of the Cygwin DLL is
66+
<b><a href="https://cygwin.com/pipermail/cygwin-announce/2023-September/011291.html">3.4.9</a></b>.
67+
</p>
68+
<p>
69+
The Cygwin DLL currently works with all recent, commercially released
70+
x86_64 versions of Windows, starting with Windows 7.
71+
</p>
72+
</div>`
73+
}
5974
const missingURL = 'https://wingit.blob.core.windows.net/x86-64/curl-8.1.2-1-x86_64.pkg.tar.xz'
6075
const missingMinTTYURL = 'https://wingit.blob.core.windows.net/i686/mintty-1~3.6.5-1-i686.pkg.tar.xz'
6176
const bogus32BitMSYS2RuntimeURL = 'https://wingit.blob.core.windows.net/i686/msys2-runtime-3.4.9-1-i686.pkg.tar.xz'
@@ -64,7 +79,10 @@ const mockDoesURLReturn404 = jest.fn(url => [
6479
missingURL, missingMinTTYURL, bogus32BitMSYS2RuntimeURL, bogus64BitMSYS2RuntimeURL
6580
].includes(url))
6681
jest.mock('../GitForWindowsHelper/https-request', () => {
67-
return { doesURLReturn404: mockDoesURLReturn404, }
82+
return {
83+
doesURLReturn404: mockDoesURLReturn404,
84+
fetchHTML: jest.fn(url => mockFetchHTML[url])
85+
}
6886
})
6987

7088

@@ -139,6 +157,17 @@ http://www.gnutls.org/news.html#2023-02-10`
139157
package: 'openssl',
140158
version: '3.1.1'
141159
})
160+
161+
expect(await guessReleaseNotes(context, {
162+
labels: [{ name: 'component-update' }],
163+
title: '[New cygwin version] cygwin-3.4.9',
164+
body: `\nCygwin 3.4.9 release\n\nhttps://github.com/cygwin/cygwin/releases/tag/cygwin-3.4.9`
165+
})).toEqual({
166+
type: 'feature',
167+
message: 'Comes with the MSYS2 runtime (Git for Windows flavor) based on [Cygwin v3.4.9](https://cygwin.com/pipermail/cygwin-announce/2023-September/011291.html).',
168+
package: 'msys2-runtime',
169+
version: '3.4.9'
170+
})
142171
})
143172

144173
test('getMissingDeployments()', async () => {

0 commit comments

Comments
 (0)