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 #24 from remy/master
Browse files Browse the repository at this point in the history
Support empty commits
  • Loading branch information
Kent C. Dodds committed Mar 6, 2016
2 parents 0d571c5 + 4de3a58 commit bb0afb6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 10 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,16 @@ var error = function() {
};


var validateMessage = function(message) {
var validateMessage = function(raw) {
var message = (raw || '').split('\n').filter(function (str) {
return str.indexOf('#') !== 0;
}).join('\n');

if (message === '') {
console.log('Aborting commit due to empty commit message.');
return false;
}

var isValid = true;

if (IGNORED.test(message)) {
Expand Down
5 changes: 5 additions & 0 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ describe('validate-commit-msg.js', function() {
expect(logs).to.not.deep.equal([]);
});

it('should allow for empty commits', function() {
expect(m.validateMessage('# this is just a comment')).to.equal(INVALID);
expect(logs).to.deep.equal(['Aborting commit due to empty commit message.']);
});


it('should handle undefined message"', function() {
expect(m.validateMessage()).to.equal(INVALID);
Expand Down

0 comments on commit bb0afb6

Please sign in to comment.