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

Commit

Permalink
fix(git-validator): support fixup and better errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mhevery committed Jan 18, 2013
1 parent af89daf commit 6131521
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions validate-commit-msg.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -51,7 +51,7 @@ var validateMessage = function(message) {
var match = PATTERN.exec(message);

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

Expand Down
3 changes: 2 additions & 1 deletion validate-commit-msg.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 "<type>(<scope>): <subject>" !']);
expect(errors).toEqual(['INVALID COMMIT MSG: does not match "<type>(<scope>): <subject>" ! was: not correct format']);
});


Expand Down

2 comments on commit 6131521

@mlem
Copy link

@mlem mlem commented on 6131521 Sep 2, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a question: what is this fixup for?

@Starefossen
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I have that question too. This is not in any way referenced in the AngularJS Git Commit Message Conventions document.

Please # to comment.