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(/^\s*CVE-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*$/) || (commit.summary === undefined ? line.match(/^ {4}.*\(#(\d+)\)$/) : null)) !== 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
18 changes: 18 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,24 @@ for (const line of ['PR-URL: #12', 'PR URL: #12', 'PRURL: #12', 'PR: #12']) {
})
}

for (const line of ['see also (#12)', '* fix: squashed (#7)']) {
test(`body line "${line}" is kept in description`, 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 (#41)',
'',
` ${line}`
], 'rvagg', 'commit-stream')
assert.strictEqual(commits[0].prUrl, 'https://github.com/rvagg/commit-stream/pull/41')
assert.strictEqual(commits[0].ghIssue, 41)
assert.strictEqual(commits[0].summary, 'doc: tidy up')
assert.deepStrictEqual(commits[0].description, [line])
})
}

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