Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unfreeze Git Commit Message grammar II #173195

Merged
merged 4 commits into from
Feb 7, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion extensions/git-base/build/update-grammars.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

var updateGrammar = require('vscode-grammar-updater');

updateGrammar.update('textmate/git.tmbundle', 'Syntaxes/Git%20Commit%20Message.tmLanguage', './syntaxes/git-commit.tmLanguage.json');
updateGrammar.update('walles/git-commit-message-plus', 'syntaxes/git-commit.tmLanguage.json', './syntaxes/git-commit.tmLanguage.json', undefined, 'main');
updateGrammar.update('textmate/git.tmbundle', 'Syntaxes/Git%20Rebase%20Message.tmLanguage', './syntaxes/git-rebase.tmLanguage.json');
37 changes: 36 additions & 1 deletion extensions/git-base/cgmanifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <johan.walles@gmail.com>",
"",
"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 extensions/git-base/syntaxes/git-commit.tmLanguage.json
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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you no longer have a line-too-long scope. Did you intentionally remove this?

Copy link
Contributor Author

@walles walles Feb 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that was intentional.

I replaced those scopes with diagnostics and Quick Fixes.

This is what it looks like in the upstream project:

screenshot

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most users won't have your whole extension installed, so having the line-too-long scope in the syntax highlighting would still be beneficial to them. Would you be willing to bring it back?

Copy link
Contributor Author

@walles walles Feb 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, just pushed a new change for that: 15defef

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

},
{
"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"
}
]
}
}
]
}
}
]
}