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

Conversation

walles
Copy link
Contributor

@walles walles commented Feb 2, 2023

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 their tests was difficult.

The replacement grammar, unlike the current grammar:

Fixes #133888
Fixes #168847

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

For the record, I was the one setting up the new Git Commit Message project. And it was fun!

After

after

Sample message to test this yourselves:


# Ange incheckningsmeddelandet för dina ändringar. Rader som inleds
# med "#" kommer ignoreras, och ett tomt meddelande avbryter incheckningen.
#
# På grenen main
# Ändringar att checka in:
#	ändrad:        hej
#
# ------------------------ >8 ------------------------
# Raden ovan får inte ändras eller tas bort.
# Allt under den kommer tas bort.
diff --git hej hej
index 257cc56..5716ca5 100644
--- hej
+++ hej
@@ -1 +1 @@
-foo
+bar

Before

Note lack of file names highlighting and diff highlighting.

before

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!
@walles walles force-pushed the johan/replace-git-commit-grammar branch from 2d4317c to 761a485 Compare February 2, 2023 20:08
@walles walles mentioned this pull request Feb 2, 2023
@walles walles marked this pull request as ready for review February 2, 2023 20:43
@alexr00 alexr00 assigned alexr00 and unassigned lszomoru Feb 3, 2023
@alexr00
Copy link
Member

alexr00 commented Feb 3, 2023

@walles thank you for the PR! Normally I prefer to see that the grammar has some wide use as an extension before adopting it, but given that this grammar is very small I'm fine with merging it anyway once it's ready.

I'm seeing a pretty big difference in how the "Changes to be committed" lines are colored (current on the left, yours on the right):
image

Are you able to restore the current behavior?

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

@walles
Copy link
Contributor Author

walles commented Feb 3, 2023

I'm seeing a pretty big difference in how the "Changes to be committed" lines are colored (current on the left, yours on the right)

Are you able to restore the current behavior?

No, I don't think that's possible.

The current behavior depends on setting the color based on keywords in English.

Since I want this grammar to work for other languages as well (Swedish in particular), I think keyword.other.file-type.git-commit and string.unquoted.filename.git-commit is as good as it gets.

If you try the current highlighting with a Swedish Git commit template, you can see that the current highlighting just doesn't work, but my new one does:

This is the summary line. It can't be too long.
After I can write a much more detailed description without quite the same restrictions on length.

# Ange incheckningsmeddelandet för dina ändringar. Rader som inleds
# med "#" kommer ignoreras, och ett tomt meddelande avbryter incheckningen.
#
# På grenen main
# Ändringar att checka in:
#	ändrad:        hej
#
# ------------------------ >8 ------------------------
# Raden ovan får inte ändras eller tas bort.
# Allt under den kommer tas bort.
diff --git hej hej
index 257cc56..5716ca5 100644
--- hej
+++ hej
@@ -1 +1 @@
-foo
+bar

@alexr00
Copy link
Member

alexr00 commented Feb 6, 2023

The current behavior depends on setting the color based on keywords in English.

I see your point, thanks for the context. It seems like it should be possible to keep the extra highlighting for English and still provide the good highlighting you've added for all other languages. Would that be possible?

walles added a commit to walles/git-commit-message-plus that referenced this pull request Feb 6, 2023
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).
@walles
Copy link
Contributor Author

walles commented Feb 6, 2023

It seems like it should be possible to keep the extra highlighting for English and still provide the good highlighting you've added for all other languages. Would that be possible?

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

Copy link
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

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

Thank you for the changes @walles! We usually update grammars via a script, so I've made the updates required to keep that working (and ran the script so that git-commit.tmLanguage.json would be consistent with our other grammar files). I've also updated our test results and the cgmanifest file (which tracks where code came from).

Looks great!

@alexr00 alexr00 added this to the February 2023 milestone Feb 7, 2023
@alexr00 alexr00 merged commit f8c3f89 into microsoft:main Feb 7, 2023
@walles walles deleted the johan/replace-git-commit-grammar branch February 7, 2023 14:09
@walles
Copy link
Contributor Author

walles commented Feb 7, 2023

Thank you @alexr00 for the constructive review process, this was a pleasure!

c-claeys pushed a commit to c-claeys/vscode that referenced this pull request Feb 16, 2023
* 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 <alros@microsoft.com>
walles added a commit to walles/git-commit-message-plus that referenced this pull request Mar 4, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Mar 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider adopting a new git grammar No diff colors in non-English Git commit message
4 participants