Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion corpus/body.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,14 @@ BREAKING CHANGE
test

BREAKING CHANGE: My message

BREAKING-CHANGE: also valid
--------------------------------------------------------------------------------

(source
(message
(breaking_change
(token)
(value))
(breaking_change
(token)
(value))))
8 changes: 7 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const COMMENT_TITLE = /[^\n\r:\uff1a]+[:\uff1a]\s*\r?\n/;
const TRAILER_TOKEN = /[a-zA-Z-]+[ ]*[:\uff1a] /;
const GENERATED_COMMENT_TITLE = /[^\n\r:\uff1a]+[:\uff1a][ ]*/;
const NUMBER = /\d+/;
const BREAKING_CHANGE = /BREAKING[- ]CHANGE/;

module.exports = grammar({
name: 'gitcommit',
Expand Down Expand Up @@ -56,7 +57,12 @@ module.exports = grammar({
seq(alias(TRAILER_TOKEN, $.token), alias(ANYTHING, $.value)),

breaking_change: ($) =>
seq(alias('BREAKING CHANGE', $.token), alias(ANYTHING, $.value)),
seq(
// BREAKING_CHANGE conflicts with TRAILER_TOKEN, an so requires higher
// lexical precedence
alias(token(prec(1, BREAKING_CHANGE)), $.token),
alias(ANYTHING, $.value)
),

comment: ($) =>
seq(
Expand Down
11 changes: 9 additions & 2 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,15 @@
{
"type": "ALIAS",
"content": {
"type": "STRING",
"value": "BREAKING CHANGE"
"type": "TOKEN",
"content": {
"type": "PREC",
"value": 1,
"content": {
"type": "PATTERN",
"value": "BREAKING[- ]CHANGE"
}
}
},
"named": true,
"value": "token"
Expand Down
Loading