From 9e66264ffe308eb3b08311a4c6c33a8196003ada Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Mon, 3 Jul 2017 14:50:44 -0500 Subject: [PATCH] Parents are returned adjacent to commit data Signed-off-by: Brandon Keepers --- index.js | 2 +- lib/dco.js | 4 ++-- test/dco.js | 15 +++++++-------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/index.js b/index.js index e6707a7..64ff175 100644 --- a/index.js +++ b/index.js @@ -25,7 +25,7 @@ module.exports = robot => { head: pr.head.sha })); - const signedOff = compare.commits.every(data => dco(data.commit)); + const signedOff = compare.commits.every(dco); const params = Object.assign({ sha: pr.head.sha, diff --git a/lib/dco.js b/lib/dco.js index 39d2ea1..826efd8 100644 --- a/lib/dco.js +++ b/lib/dco.js @@ -1,5 +1,5 @@ -module.exports = commit => { - const isMerge = commit.parents && commit.parents.length > 1; +module.exports = ({commit, parents}) => { + const isMerge = parents && parents.length > 1; return isMerge || commit.message.includes(signOff(commit)); }; diff --git a/test/dco.js b/test/dco.js index bad52c9..b275bca 100644 --- a/test/dco.js +++ b/test/dco.js @@ -11,7 +11,7 @@ describe('dco', () => { } }; - expect(dco(commit)).toBe(true); + expect(dco({commit})).toBe(true); }); it('returns true for merge commit', () => { @@ -20,11 +20,10 @@ describe('dco', () => { author: { name: 'Brandon Keepers', email: 'bkeepers@github.com' - }, - parents: ['commit 1', 'commit 2'] + } }; - expect(dco(commit)).toBe(true); + expect(dco({commit, parents: [1, 2]})).toBe(true); }); it('returns false if message does not have signoff', () => { @@ -36,7 +35,7 @@ describe('dco', () => { } }; - expect(dco(commit)).toBe(false); + expect(dco({commit})).toBe(false); }); it('returns false if the signoff does not match the author', () => { @@ -48,7 +47,7 @@ describe('dco', () => { } }; - expect(dco(commit)).toBe(false); + expect(dco({commit})).toBe(false); }); describe('integration tests', () => { @@ -57,13 +56,13 @@ describe('dco', () => { it('passes for commits with signoff', () => { signedOff.commits.forEach(commit => { - expect(dco(commit)).toBe(true); + expect(dco({commit})).toBe(true); }); }); it('fails for commits without signoff', () => { notSignedOff.commits.forEach(commit => { - expect(dco(commit)).toBe(false); + expect(dco({commit})).toBe(false); }); }); });