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

Save failed commit messages somewhere? #9

Open
danbernier opened this issue Sep 20, 2022 · 3 comments
Open

Save failed commit messages somewhere? #9

danbernier opened this issue Sep 20, 2022 · 3 comments

Comments

@danbernier
Copy link

When I write a commit message in my editor, and save and close it, if the message fails commitlint, I have to recreate everything I wrote (re-gather reference URLs, re-copy any supporting evidence for the reasoning in the commit, etc), from scratch.

It would be great if commitlint could keep a record of the last failed commit, so that a fresh git commit opens it up automatically, and you can make the (usually minor) necessary changes to pass commitlint.

@gumbo2k
Copy link

gumbo2k commented Jul 15, 2024

I like that idea... I just had the same annoying experience. I wrote a lengthy commit message, commitlint said NO, and my long commit message was gone.

Unfortunately I think it is not commitlint, but git itself, that removes the temporary file with the commit message.

I guess it might be possible to create a copy of the file by simply adding a .bak to the filename if commitlint is called with a filename (and not reading the commit message from stdin.).
If commitlint exits with an OK, it removes the .bak otherwise it prints the path to the file, so that you can recover the contents for the next attempt.

@danbernier
Copy link
Author

I wrote a lengthy commit message, commitlint said NO, and my long commit message was gone.

It's SO frustrating!

Your .bak file approach sounds workable. Even if (in the case of a "bad" commit message) you have to manually open the file and copy in its contents, and manually delete the file, it's far preferable to the toilet-flush that you experience this way.

@gumbo2k
Copy link

gumbo2k commented Jul 16, 2024

Another idea might be a little more intrusive, but more helpful ... 🤔
If we decide to fiddle about with git-config, we might save the "bad" message in a file and put its location in config.template ... Thus making git commit automatically open that file on the next commit and put it in the editor 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants