Skip to content

Commit 67931fe

Browse files
committed
guessReleaseNotes: be smarter when looking at PRs
The default for PRs is to say "This closes <url>" when the `open-pr` workflow creates a PR, referencing the original issue. So it would not really help if we linked to that issue in the release notes as much as if we looked for a URL in that referenced issue. Therefore, let's follow that link and look for such a better URL. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent ecbd0c4 commit 67931fe

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

GitForWindowsHelper/component-updates.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const needsSeparateARM64Build = package_name => {
5050
].includes(package_name)
5151
}
5252

53-
const guessReleaseNotes = (issue) => {
53+
const guessReleaseNotes = async (context, issue) => {
5454
if (!issue.pull_request
5555
&&issue.labels.filter(label => label.name === 'component-update').length !== 1) throw new Error(`Cannot determine release note from issue ${issue.number}`)
5656
let { package_name, version } = guessComponentUpdateDetails(issue.title, issue.body)
@@ -69,6 +69,18 @@ const guessReleaseNotes = (issue) => {
6969

7070
const match = issue.body.match(/See (https:\/\/\S+) for details/)
7171
if (match) return match[1]
72+
73+
const issueMatch = issue.body.match(/https:\/\/github\.com\/git-for-windows\/git\/issues\/(\d+)/)
74+
if (issueMatch) {
75+
const githubApiRequest = require('./github-api-request')
76+
const issue = await githubApiRequest(
77+
context,
78+
null,
79+
'GET',
80+
`/repos/git-for-windows/git/issues/${issueMatch[1]}`
81+
)
82+
return matchURLInIssue(issue)
83+
}
7284
}
7385

7486
const url = await matchURL()

GitForWindowsHelper/slash-commands.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ module.exports = async (context, req) => {
311311
let [ , , , type, message ] = relNotesMatch
312312
if (!type) {
313313
const { guessReleaseNotes } = require('./component-updates');
314-
({ type, message } = await guessReleaseNotes(req.body.issue))
314+
({ type, message } = await guessReleaseNotes(context, req.body.issue))
315315
}
316316

317317
await thumbsUp()

test-guess-relnote.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
)
1717

1818
const { guessReleaseNotes } = require('./GitForWindowsHelper/component-updates')
19-
const guessed = await guessReleaseNotes(issue)
19+
const guessed = await guessReleaseNotes(console, issue)
2020
console.log(JSON.stringify(guessed, null, 2))
2121
})().catch(console.log)

0 commit comments

Comments
 (0)