forked from microsoft/vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unfreeze Git Commit Message grammar II (microsoft#173195)
* Unfreeze Git Commit Message grammar II 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! * Remedy review feedback Retain the line-too-long subject line highlighting. Improved to highlight only the too-long part, but same idea still. Special case English language file operations keywords and retain the previous classification of those. But fallback to op-and-filename classification when that fails (like it will for Swedish git for example). * Update colorize test result * Update script and cgmanifest --------- Co-authored-by: Alex Ross <[email protected]>
- Loading branch information
Showing
4 changed files
with
105 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,42 @@ | |
], | ||
"license": "MIT", | ||
"version": "0.0.0" | ||
}, | ||
{ | ||
"component": { | ||
"type": "git", | ||
"git": { | ||
"name": "walles/git-commit-message-plus", | ||
"repositoryUrl": "https://github.com/walles/git-commit-message-plus", | ||
"commitHash": "35a079dea5a91b087021b40c01a6bb4eb0337a87" | ||
} | ||
}, | ||
"licenseDetail": [ | ||
"Copyright (c) 2023 Johan Walles <[email protected]>", | ||
"", | ||
"Permission is hereby granted, free of charge, to any person obtaining", | ||
"a copy of this software and associated documentation files (the\"", | ||
"Software\"), to deal in the Software without restriction, including", | ||
"without limitation the rights to use, copy, modify, merge, publish,", | ||
"distribute, sublicense, and/or sell copies of the Software, and to", | ||
"permit persons to whom the Software is furnished to do so, subject to", | ||
"the following conditions:", | ||
"", | ||
"The above copyright notice and this permission notice shall be", | ||
"included in all copies or substantial portions of the Software.", | ||
"", | ||
"THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,", | ||
"EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF", | ||
"MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND", | ||
"NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE", | ||
"LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION", | ||
"OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION", | ||
"WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE." | ||
], | ||
"license": "MIT", | ||
"version": "1.0.0", | ||
"description": "The original JSON grammars were derived from https://github.com/microsoft/vscode/blob/e95c74c4c7af876e79ec58df262464467c06df28/extensions/git-base/syntaxes/git-commit.tmLanguage.json. That file was originally copied from https://github.com/textmate/git.tmbundle." | ||
} | ||
], | ||
"version": 1 | ||
} | ||
} |
167 changes: 58 additions & 109 deletions
167
extensions/git-base/syntaxes/git-commit.tmLanguage.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,141 +1,90 @@ | ||
{ | ||
"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 converted from https://github.com/walles/git-commit-message-plus/blob/master/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", | ||
"version": "https://github.com/walles/git-commit-message-plus/commit/35a079dea5a91b087021b40c01a6bb4eb0337a87", | ||
"name": "Git Commit Message", | ||
"scopeName": "text.git-commit", | ||
"patterns": [ | ||
{ | ||
"begin": "\\A(?!# Please enter the commit message)", | ||
"end": "^(?=# Please enter the commit message)", | ||
"name": "meta.scope.message.git-commit", | ||
"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": [ | ||
{ | ||
"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" | ||
} | ||
] | ||
} | ||
] | ||
"include": "source.diff" | ||
} | ||
] | ||
}, | ||
{ | ||
"begin": "^(?=# Please enter the commit message)", | ||
"end": "\\z", | ||
"name": "meta.scope.metadata.git-commit", | ||
"comment": "User supplied message", | ||
"name": "meta.scope.message.git-commit", | ||
"begin": "^(?!#)", | ||
"end": "^(?=#)", | ||
"patterns": [ | ||
{ | ||
"include": "#metadata" | ||
"comment": "Mark > 50 lines as deprecated, > 72 as illegal", | ||
"name": "meta.scope.subject.git-commit", | ||
"match": "\\G.{0,50}(.{0,22}(.*))$", | ||
"captures": { | ||
"1": { | ||
"name": "invalid.deprecated.line-too-long.git-commit" | ||
}, | ||
"2": { | ||
"name": "invalid.illegal.line-too-long.git-commit" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
], | ||
"repository": { | ||
"comment": { | ||
"begin": "^(#)", | ||
"captures": { | ||
"1": { | ||
"name": "punctuation.definition.comment.git-commit" | ||
} | ||
}, | ||
"end": "\\n", | ||
"name": "comment.line.number-sign.git-commit" | ||
}, | ||
"metadata": { | ||
{ | ||
"comment": "Git supplied metadata in a number of lines starting with #", | ||
"name": "meta.scope.metadata.git-commit", | ||
"begin": "^(?=#)", | ||
"contentName": "comment.line.number-sign.git-commit", | ||
"end": "^(?!#)", | ||
"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" | ||
} | ||
] | ||
"match": "^#\\t((modified|renamed):.*)$", | ||
"captures": { | ||
"1": { | ||
"name": "markup.changed.git-commit" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"include": "#comment" | ||
"match": "^#\\t(new file:.*)$", | ||
"captures": { | ||
"1": { | ||
"name": "markup.inserted.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" | ||
"match": "^#\\t(deleted.*)$", | ||
"captures": { | ||
"1": { | ||
"name": "markup.deleted.git-commit" | ||
} | ||
} | ||
}, | ||
{ | ||
"comment": "Fallback for non-English git commit template", | ||
"match": "^#\\t([^:]+): *(.*)$", | ||
"captures": { | ||
"1": { | ||
"name": "keyword.other.file-type.git-commit" | ||
}, | ||
"2": { | ||
"name": "string.unquoted.filename.git-commit" | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} |
Oops, something went wrong.