Skip to content
This repository has been archived by the owner on Feb 5, 2018. It is now read-only.

Commit

Permalink
Merge pull request #27 from tusharmath/master
Browse files Browse the repository at this point in the history
Consider default merge commit as valid commit
  • Loading branch information
Kent C. Dodds committed Mar 13, 2016
2 parents bb0afb6 + 7ae35cc commit 333f358
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var TYPES = config.types || ['feat', 'fix', 'docs', 'style', 'refactor', 'perf',

// fixup! and squash! are part of Git, commits tagged with them are not intended to be merged, cf. https://git-scm.com/docs/git-commit
var PATTERN = /^((fixup! |squash! )?(\w+)(?:\(([^\)\s]+)\))?: (.+))(?:\n|$)/;

var MERGE_COMMIT_PATTERN = /^Merge branch \'.*\' into .*$/;
var error = function() {
// gitx does not display it
// http://gitx.lighthouseapp.com/projects/17830/tickets/294-feature-display-hook-error-message-when-hook-fails
Expand All @@ -45,6 +45,11 @@ var validateMessage = function(raw) {

var isValid = true;

if(MERGE_COMMIT_PATTERN.test(message)){
console.log('Merge commit detected.');
return true
}

if (IGNORED.test(message)) {
console.log('Commit message validation ignored.');
return true;
Expand Down
6 changes: 6 additions & 0 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ describe('validate-commit-msg.js', function() {
expect(m.validateMessage('fixup! fix($compile): something')).to.equal(VALID);
expect(m.validateMessage('squash! fix($compile): something super mega extra giga tera long, maybe even longer and longer and longer...')).to.equal(VALID);
});

it('should handle merge commits', function() {
expect(m.validateMessage('Merge branch \'master\' into validate-commit-msg-integration')).to.equal(VALID);
expect(m.validateMessage('Merge branch master into validate-commit-msg-integration')).to.equal(INVALID);
expect(m.validateMessage('Merge branch \'master\' into validate-commit_msg-integration')).to.equal(VALID);
});
});

afterEach(function() {
Expand Down

0 comments on commit 333f358

Please sign in to comment.