-
Notifications
You must be signed in to change notification settings - Fork 100
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
Full workflow example for fixing a previously rejected commit message #523
Comments
I know this isn't perfect, but the commit-msg hook of gitlint itself does print the commit-msg in full in case of violations. You can then copy-paste it. I haven't looked into the linked pre-commit ticket yet, will do when I have more time :) |
Thanks, This is the flow suggested in the pre-commit issue using a combination of
What would you think of adding two flags to
These two would allow to implement the flow I described above by updating the - id: gitlint-restore
name: gitlint-restore
description: Restores any previously rejected git commit message
language: python
additional_dependencies: ["./gitlint-core[trusted-deps]"]
entry: gitlint
args: [--restore-msg-backup, ".git/gitlint-backup" --msg-filename]
stages: [prepare-commit-msg]
- id: gitlint
name: gitlint
description: Checks your git commit messages for style.
language: python
additional_dependencies: ["./gitlint-core[trusted-deps]"]
entry: gitlint
args: [--staged, --maintain-msg-backup, ".git/gitlint-backup" --msg-filename]
stages: [commit-msg]
- id: gitlint-ci
name: gitlint
language: python
additional_dependencies: ["./gitlint-core[trusted-deps]"]
entry: gitlint
always_run: true
pass_filenames: false
stages: [manual] Of course I would also understand if you prefer to keep this separate from |
Hi! Unless I'm mistaken, if the violation is in a rule linked to the title, it will only print the title (and potentially completely lose the beautiful body you spent time to type up 😢 ) |
While evalulating the use of
gitlint
I was pretty impressed by the configurability and ease of creating your own linting rules. Thanks a lot for creating and maintaining this tool!When testing an actual commit workflow noticed that any commit messages rejected due to linting violations will get lost though:
gitlint
is configured ascommit-msg
hook viapre-commit
as described at https://jorisroovers.com/gitlint/latest/commit_hooks/#pre-commitgit config --global commit.template ~/.gittemplate
git commit
which opens my configured editor prepopulated with the template and I am free to author my commit messagegitlint
will spring to life and check the previously authored commit message against my configured rulesa. In case there is no vilations, all is good. The commit is completed and done.
b. In case of linting violations
gitlint
rejects and git aborts the commit as expectedCase 4b. is now the challenging one because
gitlint
will nicely print all my violations, however once I start a second attempt to commit again viagit commit
with the plan to correct my commit message all previously authored content is gone and I see the blank template again.This problem is also discussed in pre-commit/pre-commit#833 with some suggestions to address this but no production grade solution given.
Before diving deeper into working on a pull request to implement a solution like discussed in the referenced issue, I wanted to check here if am simply missing something? What does a typical workflow with
gitlint
ascommit-msg
hook look like that does not expose the problem described above?Thanks for helping me on understanding this :)
The text was updated successfully, but these errors were encountered: