Skip to content
Merged
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
10 changes: 8 additions & 2 deletions commit-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ export default function commitStream (ghUser, ghProject) {
return new Transform({
objectMode: true,
transform (line, _, callback) {
emit(this, addLine(line))
let done
try {
done = addLine(line)
} catch (err) {
return callback(/** @type {Error} */ (err))
}
Comment thread
trivikr marked this conversation as resolved.
Resolved
emit(this, done)
callback()
},
flush (callback) {
Expand All @@ -73,7 +79,7 @@ export default function commitStream (ghUser, ghProject) {
let m

if (!commit) {
throw new Error('Something unexpected occurred')
throw new Error(`Unexpected line before first "commit" header: ${line}`)
}

if ((m = line.match(/^CommitDate:\s+(.*)$/)) !== null) {
Expand Down
14 changes: 14 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,17 @@ test('cve id with 4 or more sequence digits', async () => {
const commits = await toCommits(ids.flatMap(log))
assert.deepStrictEqual(commits.map((c) => c.cveId), ids)
})

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

test('line before first commit header emits error on write', async () => {
const stream = commitStream()
const error = once(stream, 'error')
stream.write('garbage')
const [err] = await error
assert.strictEqual(err.message, 'Unexpected line before first "commit" header: garbage')
})
2 changes: 1 addition & 1 deletion types/commit-stream.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading