Skip to content

Commit f45dff6

Browse files
committed
fix: match green-button (#N) only on the summary line
A body line ending in "(#N)", such as "see also (#12)" or a squash-merge entry "* fix: foo (#7)", overwrote prUrl/ghIssue and was dropped from description.
1 parent a8bf4f8 commit f45dff6

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

‎commit-stream.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export default function commitStream (ghUser, ghProject) {
9999
(commit.reviewers ??= []).push({ name: m[1], email: m[2] })
100100
} else if ((m = line.match(/^\s*CVE-ID:\s+(CVE-\d{4}-\d{4,})\b/)) !== null) {
101101
commit.cveId = m[1]
102-
} else if ((m = line.match(/^\s+PR(?:[- ]?URL)?:\s*(.+)\s*$/) || line.match(/\(#(\d+)\)$/)) !== null) {
102+
} else if ((m = line.match(/^\s+PR(?:[- ]?URL)?:\s*(.+)\s*$/) || (commit.summary === undefined ? line.match(/^ {4}.*\(#(\d+)\)$/) : null)) !== null) {
103103
commit.prUrl = m[1]
104104
if (ghUser && ghProject && (m = commit.prUrl.match(/^\s*#?(\d+)\s*$/)) !== null) {
105105
commit.prUrl = `https://github.com/${ghUser}/${ghProject}/pull/${m[1]}`

‎test.js‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,24 @@ for (const line of ['PR-URL: #12', 'PR URL: #12', 'PRURL: #12', 'PR: #12']) {
295295
})
296296
}
297297

298+
for (const line of ['see also (#12)', '* fix: squashed (#7)']) {
299+
test(`body line "${line}" is kept in description`, async () => {
300+
const commits = await toCommits([
301+
'commit 0000000000000000000000000000000000000000',
302+
'Author: Rod Vagg <rod@vagg.org>',
303+
'Date: Fri Apr 17 10:52:16 2015 +1000',
304+
'',
305+
' doc: tidy up (#41)',
306+
'',
307+
` ${line}`
308+
], 'rvagg', 'commit-stream')
309+
assert.strictEqual(commits[0].prUrl, 'https://github.com/rvagg/commit-stream/pull/41')
310+
assert.strictEqual(commits[0].ghIssue, 41)
311+
assert.strictEqual(commits[0].summary, 'doc: tidy up')
312+
assert.deepStrictEqual(commits[0].description, [line])
313+
})
314+
}
315+
298316
test('line before first commit header rejects pipeline', async () => {
299317
await assert.rejects(toCommits(['garbage']), {
300318
message: 'Unexpected line before first "commit" header: garbage'

0 commit comments

Comments
 (0)