Skip to content

Commit

Permalink
Allow colons in commit message title (#41)
Browse files Browse the repository at this point in the history
The title-format rule was previously too eager and disallowed
all usage of colons followed by non-spaces, rather than just
for the subsystem. Fix that by only checking for a space after
the *first* colon.

Fixes: #40
  • Loading branch information
addaleax authored and joyeecheung committed Dec 16, 2018
1 parent b3a89a1 commit a3e9d95
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/title-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
}

{
const result = /^(.+?:)[^ ]/.exec(context.title)
const result = /^([^:]+:)[^ ]/.exec(context.title)
if (result) {
context.report({
id: id
Expand Down
18 changes: 18 additions & 0 deletions test/rules/title-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ test('rule: title-format', (t) => {
tt.end()
})

t.test('space after subsystem, colon in message', (tt) => {
tt.plan(2)
const context = makeCommit('test: missing:space')

context.report = (opts) => {
tt.pass('called report')
tt.strictSame(opts, {
id: 'title-format'
, message: 'Title is formatted correctly.'
, string: ''
, level: 'pass'
})
}

Rule.validate(context)
tt.end()
})

t.test('consecutive spaces', (tt) => {
tt.plan(2)
const context = makeCommit('test: with two spaces')
Expand Down

0 comments on commit a3e9d95

Please sign in to comment.