Skip to content

Commit

Permalink
Unfreeze Git Commit Message grammar II
Browse files Browse the repository at this point in the history
Before this change, the upstream for the VSCode Git grammar was dead.
Also, the test setup for that project has been EOL since 2014, so even
just running the tests was difficult.

The replacement grammar, unlike the current grammar:
* Has a vscode-tmgrammar-test test suite that is runnable and passing
  and that will run in CI for any PRs (in the upstream project)
* Has diff highlighting for Swedish as well as English (microsoft#133888)
* Highlights touched files both in Swedish and in English

Fixes microsoft#133888
Fixes microsoft#168847

Ref: <https://github.com/walles/git-commit-message-plus>

And for the record, I was the one setting up the new Git Commit Message
project. And it was fun!
  • Loading branch information
walles committed Feb 2, 2023
1 parent b424430 commit 761a485
Showing 1 changed file with 35 additions and 117 deletions.
152 changes: 35 additions & 117 deletions extensions/git-base/syntaxes/git-commit.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -1,141 +1,59 @@
{
"information_for_contributors": [
"This file has been converted from https://github.com/textmate/git.tmbundle/blob/master/Syntaxes/Git%20Commit%20Message.tmLanguage",
"This file has been copied from https://github.com/walles/git-commit-message-plus/blob/main/syntaxes/git-commit.tmLanguage.json",
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
"Once accepted there, we are happy to receive an update request."
],
"version": "https://github.com/textmate/git.tmbundle/commit/93897a78c6e52bef13dadc0d4091d203c5facb40",
"metadata": [
"This file is maintained here:",
"https://github.com/walles/git-commit-message-plus/blob/main/syntaxes/git-commit.tmLanguage.json",
"",
"It was originally based on this file, but has been heavily modified:",
"https://github.com/microsoft/vscode/blob/e95c74c4c7af876e79ec58df262464467c06df28/extensions/git-base/syntaxes/git-commit.tmLanguage.json"
],
"name": "Git Commit Message",
"scopeName": "text.git-commit",
"patterns": [
{
"begin": "\\A(?!# Please enter the commit message)",
"end": "^(?=# Please enter the commit message)",
"comment": "diff presented at the end of the commit message when using commit -v.",
"name": "meta.embedded.diff.git-commit",
"contentName": "source.diff",
"begin": "(?=^diff\\ \\-\\-git)",
"end": "\\z",
"patterns": [ { "include": "source.diff" } ]
},
{
"comment": "User supplied message",
"name": "meta.scope.message.git-commit",
"begin": "^(?!#)",
"end": "^(?=#)",
"patterns": [
{
"begin": "\\A(?=#)",
"end": "^(?!#)",
"patterns": [
{
"include": "#comment"
}
]
},
{
"begin": "^(?!# Please enter the commit message)",
"end": "^(?=# Please enter the commit message)",
"patterns": [
{
"begin": "\\G",
"end": "^(?!\\G)",
"name": "meta.scope.subject.git-commit",
"patterns": [
{
"captures": {
"1": {
"name": "keyword.other.$2.git-commit"
}
},
"match": "\\G((fixup|squash)!)\\s*"
},
{
"match": ".{73,}$",
"name": "invalid.illegal.line-too-long.git-commit"
},
{
"match": ".{51,}$",
"name": "invalid.deprecated.line-too-long.git-commit"
}
]
},
{
"begin": "^(?!# Please enter the commit message)",
"end": "^(?=# Please enter the commit message)",
"patterns": [
{
"include": "#comment"
}
]
}
]
"name": "meta.scope.subject.git-commit",
"match": "\\G.*$"
}
]
},
{
"begin": "^(?=# Please enter the commit message)",
"end": "\\z",
"comment": "Git supplied metadata in a number of lines starting with #",
"name": "meta.scope.metadata.git-commit",
"begin": "^(?=#)",
"end": "(?!^#)",
"patterns": [
{
"include": "#metadata"
}
]
}
],
"repository": {
"comment": {
"begin": "^(#)",
"captures": {
"1": {
"name": "punctuation.definition.comment.git-commit"
}
},
"end": "\\n",
"name": "comment.line.number-sign.git-commit"
},
"metadata": {
"patterns": [
{
"begin": "(?=^# Changes to be committed:)",
"end": "(?!\\G)((?=^# \\w)|(?!^#))",
"patterns": [
{
"begin": "(^[ \\t]+)?(?=#)",
"beginCaptures": {
"1": {
"name": "punctuation.whitespace.comment.leading.git-commit"
}
},
"contentName": "comment.line.number-sign.git-commit",
"end": "(?!\\G)^",
"patterns": [
{
"match": "\\G#",
"name": "punctuation.definition.comment.git-commit"
},
{
"match": "((modified|renamed):.*)$\\n?",
"name": "markup.changed.git-commit"
},
{
"match": "(new file:.*)$\\n?",
"name": "markup.inserted.git-commit"
},
{
"match": "(deleted:.*)$\\n?",
"name": "markup.deleted.git-commit"
}
]
}
]
},
{
"include": "#comment"
"comment": "What is happening with which files",
"match": "^#\\t([^:]+): *(.*)$",
"name": "comment.line.number-sign.git-commit",
"captures": {
"1": { "name": "keyword.other.file-type.git-commit" },
"2": { "name": "string.unquoted.filename.git-commit" }
}
},
{
"begin": "(?=diff\\ \\-\\-git)",
"comment": "diff presented at the end of the commit message when using commit -v.",
"contentName": "source.diff",
"end": "\\z",
"name": "meta.embedded.diff.git-commit",
"patterns": [
{
"include": "source.diff"
}
]
"name": "comment.line.number-sign.git-commit",
"match": "^#.*$"
}
]
}
}
}
]
}

0 comments on commit 761a485

Please sign in to comment.