Skip to content

Commit

Permalink
Validate: Check ticket references
Browse files Browse the repository at this point in the history
Fixes gh-2
  • Loading branch information
jzaefferer committed Jan 14, 2014
1 parent 34c70b3 commit 557d037
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ module.exports = function( message, options ) {
line.length + " characters, only " + options.limits.other +
" allowed. Was: " + line.substring( 0, 20 ) + "[...]" );
}
// ticket references
if ( /^(close[sd]?|fix(e(sd)?)?|resolve[sd]?)/i.test( line ) ) {
if ( !/(Fixes|Closes) (.*#|gh-)[0-9]+/.test( line )) {

This comment has been minimized.

Copy link
@scottgonzalez

scottgonzalez Jan 14, 2014

Contributor

This is too restrictive. We need cross-project references as well, e.g., Fixes jquery/other-repo#20.

This comment has been minimized.

Copy link
@jzaefferer

jzaefferer Jan 14, 2014

Author Owner

I actually added that already, but forgot to update the message. There's a .+ in front of the # and a test with Closes jquery/jquery-mobile#123 below. Did I miss something else, or just the message (two lines below)?

This comment has been minimized.

Copy link
@scottgonzalez

scottgonzalez Jan 14, 2014

Contributor

Sorry, I just missed the .* catching that. Good job :-)

errors.push( "Invalid ticket reference, must be " +
"/(Fixes|Closes) (#|gh-)[0-9]+/, was: " + line );
}
}
});

return errors;
Expand Down
11 changes: 10 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ var valid = [
"\n" +
"Long description\n" +
"\n" +
"Close #xxx"
"Closes #123"
},
{
msg: "Component: short message\n" +
"\n" +
"Closes jquery/jquery-mobile#123"
},
{
msg: "short message",
Expand Down Expand Up @@ -59,6 +64,10 @@ var invalid = [
msg: "component: bla\n\nline too long beyond 80 chars line too long beyond" +
"line too long line too long line too long",
expected: [ "Commit message line 3 too long: 91 characters, only 80 allowed. Was: line too long beyond[...]" ]
},
{
msg: "Docs: Fix a typo\n\nCloses: gh-155",
expected: [ "Invalid ticket reference, must be /(Fixes|Closes) (#|gh-)[0-9]+/, was: Closes: gh-155" ]
}
];

Expand Down

0 comments on commit 557d037

Please sign in to comment.