diff --git a/lib/dco.js b/lib/dco.js index 5050cbf..c335048 100644 --- a/lib/dco.js +++ b/lib/dco.js @@ -14,8 +14,10 @@ module.exports = async function (commits, isRequiredFor) { for (const {commit, author, parents} of commits) { const isMerge = parents && parents.length > 1 - const signoffRequired = await isRequiredFor(author.login) - if (isMerge || author.type === 'Bot' || (!signoffRequired && commit.verification.verified)) { + const signoffRequired = !author || await isRequiredFor(author.login) + if (isMerge || (!signoffRequired && commit.verification.verified)) { + continue + } else if (!author || author.type === 'Bot') { continue } const match = regex.exec(commit.message) diff --git a/package.json b/package.json index e94c7d2..72944a0 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "devDependencies": { "eslint-plugin-import": "^2.11.0", "jest": "^22.4.3", - "nock": "^9.2.5", + "nock": "^9.2.6", "smee-client": "^1.0.1", "standard": "^11.0.0" }, diff --git a/test/dco.test.js b/test/dco.test.js index cd4481a..d3b397c 100644 --- a/test/dco.test.js +++ b/test/dco.test.js @@ -406,4 +406,25 @@ describe('dco', () => { expect(JSON.stringify(dcoObject)).toBe(success) } ) + + test( + 'returns success if author does not exist but everything else is ok', + async () => { + const commit = { + message: 'What a nice day!\n\nSigned-off-by: Bex Warner ', + 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(success) + } + ) })