Skip to content

Commit

Permalink
parse everything following scissors as one message
Browse files Browse the repository at this point in the history
connects #2
  • Loading branch information
the-mikedavis committed Mar 2, 2022
1 parent a48627e commit d046669
Show file tree
Hide file tree
Showing 5 changed files with 3,936 additions and 2,494 deletions.
17 changes: 7 additions & 10 deletions grammar.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/* glossary:
- subject: the first line of a commit
- short subjects are <= 50 characters long
- long subjects are 51..72 characters long
- oversized subjects are >= 73 characters long
- message: the body of a commit
- starts on the third line of the file (1-indexed)
- usually starts on the third line of the file (1-indexed)
- may be interspersed with comments
- item: an issue or PR
- change: how a file will change with this commit
Expand All @@ -27,7 +24,7 @@ const PREC = {
};

const SCISSORS =
/# -+ >8 -+\n# Do not modify or remove the line above.\n# Everything below it will be ignored./;
/# -+ >8 -+\r?\n# Do not modify or remove the line above.\r?\n# Everything below it will be ignored.\r?\n?/;

module.exports = grammar({
name: "git_commit",
Expand All @@ -38,7 +35,8 @@ module.exports = grammar({
source: ($) =>
seq(
optional(choice($.comment, $.subject)),
optional(seq(NEWLINE, repeat($._body_line)))
optional(seq(NEWLINE, repeat($._body_line))),
optional(seq(alias(SCISSORS, $.scissors), optional(alias($._rest, $.message))))
),

_body_line: ($) =>
Expand All @@ -58,10 +56,7 @@ module.exports = grammar({
),

comment: ($) =>
choice(
alias(SCISSORS, $.scissors),
seq(token.immediate("#"), optional($._comment_body))
),
seq(token.immediate("#"), optional($._comment_body)),

_comment_body: ($) =>
choice(
Expand Down Expand Up @@ -226,5 +221,7 @@ module.exports = grammar({

user: ($) => token(prec(PREC.USER, /@[^\s@]+/)),
item: ($) => token(prec(PREC.ITEM, /#\d+/)),

_rest: ($) => repeat1(choice(/.*/, NEWLINE)),
},
});
87 changes: 64 additions & 23 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d046669

Please sign in to comment.