Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion commit-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default function commitStream (ghUser, ghProject) {
(commit.reviewers ??= []).push({ name: m[1], email: m[2] })
} else if ((m = line.match(/\bCVE-ID:\s+(CVE-\d{4}-\d{4,})\b/)) !== null) {
commit.cveId = m[1]
} else if ((m = line.match(/^\s+PR(?:[- ]?URL)?:?\s*(.+)\s*$/) || line.match(/\(#(\d+)\)$/)) !== null) {
} else if ((m = line.match(/^\s+PR(?:[- ]?URL)?:\s*(.+)\s*$/) || line.match(/\(#(\d+)\)$/)) !== null) {
commit.prUrl = m[1]
if (ghUser && ghProject && (m = commit.prUrl.match(/^\s*#?(\d+)\s*$/)) !== null) {
commit.prUrl = `https://github.com/${ghUser}/${ghProject}/pull/${m[1]}`
Expand Down
31 changes: 31 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,37 @@ test('cve id with 4 or more sequence digits', async () => {
assert.deepStrictEqual(commits.map((c) => c.cveId), ids)
})

test('body lines starting with "PR" are not PR urls', async () => {
const commits = await toCommits([
'commit 0000000000000000000000000000000000000000',
'Author: Rod Vagg <rod@vagg.org>',
'Date: Fri Apr 17 10:52:16 2015 +1000',
'',
' PRs: tidy up docs',
'',
' PRetty much done'
])
assert.strictEqual(commits[0].prUrl, undefined)
assert.strictEqual(commits[0].summary, 'PRs: tidy up docs')
assert.deepStrictEqual(commits[0].description, ['PRetty much done'])
})

for (const line of ['PR-URL: #12', 'PR URL: #12', 'PRURL: #12', 'PR: #12']) {
test(`"${line}" is parsed as a PR url`, async () => {
const commits = await toCommits([
'commit 0000000000000000000000000000000000000000',
'Author: Rod Vagg <rod@vagg.org>',
'Date: Fri Apr 17 10:52:16 2015 +1000',
'',
' doc: tidy up',
'',
` ${line}`
], 'rvagg', 'commit-stream')
assert.strictEqual(commits[0].prUrl, 'https://github.com/rvagg/commit-stream/pull/12')
assert.strictEqual(commits[0].summary, 'doc: tidy up')
})
}

test('line before first commit header rejects pipeline', async () => {
await assert.rejects(toCommits(['garbage']), {
message: 'Unexpected line before first "commit" header: garbage'
Expand Down
Loading