-
Notifications
You must be signed in to change notification settings - Fork 222
feat: use tree-sitter for gitcommit #2081
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
base: master
Are you sure you want to change the base?
Conversation
38f6484 to
dc2526c
Compare
|
I noticed |
The previous gitcommit parser naively took the contents until the first comment. If there are inline comments, such as when squashing two commits in an interactive rebase, the text after those comments would not be checked. Instead, we use tree-sitter-gitcommit parsing and mask the nodes that are subject, message lines or breaking change descriptions. As before, we re-parse these parts with the existing markdown parser. A new crate `harper-git-commit` is added.
dc2526c to
98013c8
Compare
You're absolutely right. It must have gotten lost in #2037. I've returned it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this looks almost good to go.
| [dependencies] | ||
| harper-core = { path = "../harper-core", version = "0.68.0" } | ||
| harper-tree-sitter = { path = "../harper-tree-sitter", version = "0.68.0" } | ||
| tree-sitter-gitcommit = { git = "https://github.com/gbprod/tree-sitter-gitcommit", rev = "a716678c0f00645fed1e6f1d0eb221481dbd6f6d" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, Harper can't include git dependencies. crates.io doesn't allow it. Would it be possible for you to upload the crate to crates.io and reference that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The crate is already on crates.io, but it does not have the newest commits in the repo unfortunately. I could ask for a release or use the released version there; however, the version there does not have separate tree-sitter nodes for comments in between actual message lines, meaning that I can't remove those comments from the mask.
I'll ask upstream for a new release and version bump on crates.io.
Sorry, I'm not really knowledgeable about the rust packaging ecosystem, and didn't know that git dependencies aren't allowed when publishing on crates.io.
| @@ -0,0 +1,26 @@ | |||
| This is the the subject | |||
|
|
|||
| This is a first line without typos | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good tests!
Issues
There's no existing GitHub issue for this, but I noticed sometimes harper not seeing my typos when they appear in a git commit description after a comment.
Description
The previous gitcommit parser naively took the contents until the first comment. If there are inline comments, such as when squashing two commits in an interactive rebase, the text after those comments would not be checked.
Instead, we use tree-sitter-gitcommit parsing and mask the nodes that are subject, message lines or breaking change descriptions. As before, we re-parse these parts with the existing markdown parser.
A new crate
harper-git-commitis added.Demo
How Has This Been Tested?
Tested manually with helix and harper-ls on some git commits.
Checklist