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
2 changes: 1 addition & 1 deletion lib/dco.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = async function (commits, isRequiredFor) {
const signoffRequired = !author || await isRequiredFor(author.login)
if (isMerge || (!signoffRequired && commit.verification.verified)) {
continue
} else if (!author || author.type === 'Bot') {
} else if (author && author.type === 'Bot') {
continue
}
const match = regex.exec(commit.message)
Expand Down
25 changes: 25 additions & 0 deletions test/dco.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,4 +427,29 @@ describe('dco', () => {
expect(JSON.stringify(dcoObject)).toBe(success)
}
)

test(
'returns failure if author does not exist and there is no sign off',
async () => {
const commit = {
message: 'What a nice day!',
author: {
name: 'Bexo',
email: 'bexo@gmail.com'
},
committer: {
name: 'Bex Warner',
email: 'bexmwarner@gmail.com'
}
}
const author = null
const dcoObject = await getDCOStatus([{commit, author, parents: []}], alwaysRequireSignoff)

expect(JSON.stringify(dcoObject)).toBe(JSON.stringify({
state: 'failure',
description: 'The sign-off is missing.',
target_url: 'https://github.com/probot/dco#how-it-works'
}))
}
)
})