Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid checking for sign off on merges #14

Merged
merged 2 commits into from
Jul 3, 2017
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 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
10 changes: 7 additions & 3 deletions lib/dco.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module.exports = commit => {
const signOff = `Signed-off-by: ${commit.author.name} <${commit.author.email}>`;
return commit.message.includes(signOff);
module.exports = ({commit, parents}) => {
const isMerge = parents && parents.length > 1;
return isMerge || commit.message.includes(signOff(commit));
};

function signOff(commit) {
return `Signed-off-by: ${commit.author.name} <${commit.author.email}>`;
}
22 changes: 17 additions & 5 deletions test/dco.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,19 @@ describe('dco', () => {
}
};

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

it('returns true for merge commit', () => {
const commit = {
message: 'mergin stuff',
author: {
name: 'Brandon Keepers',
email: 'bkeepers@github.com'
}
};

expect(dco({commit, parents: [1, 2]})).toBe(true);
});

it('returns false if message does not have signoff', () => {
Expand All @@ -23,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 @@ -35,7 +47,7 @@ describe('dco', () => {
}
};

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

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