Skip to content

Commit

Permalink
Parents are returned adjacent to commit data
Browse files Browse the repository at this point in the history
Signed-off-by: Brandon Keepers <bkeepers@github.com>
  • Loading branch information
bkeepers committed Jul 3, 2017
1 parent ad13b58 commit 9e66264
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions lib/dco.js
Original file line number Diff line number Diff line change
@@ -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));
};

Expand Down
15 changes: 7 additions & 8 deletions test/dco.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('dco', () => {
}
};

expect(dco(commit)).toBe(true);
expect(dco({commit})).toBe(true);
});

it('returns true for merge commit', () => {
Expand All @@ -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', () => {
Expand All @@ -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', () => {
Expand All @@ -48,7 +47,7 @@ describe('dco', () => {
}
};

expect(dco(commit)).toBe(false);
expect(dco({commit})).toBe(false);
});

describe('integration tests', () => {
Expand All @@ -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);
});
});
});
Expand Down

0 comments on commit 9e66264

Please sign in to comment.