Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 6131521

Browse files
committed
fix(git-validator): support fixup and better errors
1 parent af89daf commit 6131521

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

validate-commit-msg.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var util = require('util');
1313

1414

1515
var MAX_LENGTH = 70;
16-
var PATTERN = /^(\w*)(\(([\w\$\.\-\*/]*)\))?\: (.*)$/;
16+
var PATTERN = /^(?:fixup!\s*)?(\w*)(\(([\w\$\.\-\*/]*)\))?\: (.*)$/;
1717
var IGNORED = /^WIP\:/;
1818
var TYPES = {
1919
feat: true,
@@ -51,7 +51,7 @@ var validateMessage = function(message) {
5151
var match = PATTERN.exec(message);
5252

5353
if (!match) {
54-
error('does not match "<type>(<scope>): <subject>" !');
54+
error('does not match "<type>(<scope>): <subject>" ! was: ' + message);
5555
return false;
5656
}
5757

validate-commit-msg.spec.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ describe('validate-commit-msg.js', function() {
2222
describe('validateMessage', function() {
2323

2424
it('should be valid', function() {
25+
expect(m.validateMessage('fixup! fix($compile): something')).toBe(VALID);
2526
expect(m.validateMessage('fix($compile): something')).toBe(VALID);
2627
expect(m.validateMessage('feat($location): something')).toBe(VALID);
2728
expect(m.validateMessage('docs($filter): something')).toBe(VALID);
@@ -50,7 +51,7 @@ describe('validate-commit-msg.js', function() {
5051
var msg = 'not correct format';
5152

5253
expect(m.validateMessage(msg)).toBe(INVALID);
53-
expect(errors).toEqual(['INVALID COMMIT MSG: does not match "<type>(<scope>): <subject>" !']);
54+
expect(errors).toEqual(['INVALID COMMIT MSG: does not match "<type>(<scope>): <subject>" ! was: not correct format']);
5455
});
5556

5657

0 commit comments

Comments
 (0)