From 61315211da5d85d73c24169d78e060fb256670e3 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 17 Jan 2013 22:56:42 -0800 Subject: fix(git-validator): support fixup and better errors --- validate-commit-msg.js | 4 ++-- validate-commit-msg.spec.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/validate-commit-msg.js b/validate-commit-msg.js index 7e8df6be..ec853a46 100755 --- a/validate-commit-msg.js +++ b/validate-commit-msg.js @@ -13,7 +13,7 @@ var util = require('util'); var MAX_LENGTH = 70; -var PATTERN = /^(\w*)(\(([\w\$\.\-\*/]*)\))?\: (.*)$/; +var PATTERN = /^(?:fixup!\s*)?(\w*)(\(([\w\$\.\-\*/]*)\))?\: (.*)$/; var IGNORED = /^WIP\:/; var TYPES = { feat: true, @@ -51,7 +51,7 @@ var validateMessage = function(message) { var match = PATTERN.exec(message); if (!match) { - error('does not match "(): " !'); + error('does not match "(): " ! was: ' + message); return false; } diff --git a/validate-commit-msg.spec.js b/validate-commit-msg.spec.js index 4d153dc0..d4b37775 100644 --- a/validate-commit-msg.spec.js +++ b/validate-commit-msg.spec.js @@ -22,6 +22,7 @@ describe('validate-commit-msg.js', function() { describe('validateMessage', function() { it('should be valid', function() { + expect(m.validateMessage('fixup! fix($compile): something')).toBe(VALID); expect(m.validateMessage('fix($compile): something')).toBe(VALID); expect(m.validateMessage('feat($location): something')).toBe(VALID); expect(m.validateMessage('docs($filter): something')).toBe(VALID); @@ -50,7 +51,7 @@ describe('validate-commit-msg.js', function() { var msg = 'not correct format'; expect(m.validateMessage(msg)).toBe(INVALID); - expect(errors).toEqual(['INVALID COMMIT MSG: does not match "(): " !']); + expect(errors).toEqual(['INVALID COMMIT MSG: does not match "(): " ! was: not correct format']); }); -- cgit v1.2.3