Handle pre-commit hook failures better as to not lose commit messages
This is not an enhancement, but a bug.
Currently, if you try and use git-plus with a repository that has a pre-configured git pre-commit hook, and you take the time to write out a nice long commit message, the message is completely lost if the pre-commit hook fails.
Steps to reproduce:
- Copy paste this stuff into bash to setup the test case:
temp=$(mktemp -d) git init "$temp" echo -e '#!/bin/bash\necho "ERROR: Simulating failed pre-commit hook"\nexit 1' > "$temp/.git/hooks/pre-commit" chmod +x "$temp/.git/hooks/pre-commit" touch "$temp/foo" atom "$temp/foo" - Now type some stuff in atom, and hit
CTRL+sto save - Now type
CTRL+SHIFT+A ato "Git add all and commit" - Add a commit message to the newly minted
COMMIT_EDITMSGpane - Finally, press
CTRL+sagain to save the message (pane disappears) - Observe the failure and how the commit 1. fails 2. message is not retained anywhere
The way git proper handles this on the commandline is by running the pre-commit hook before it asks for a message.
If you're like me and forget sometimes where you have pre-commit hooks in place, and you're like me and write out lengthy messages - this is a serious bug/annoyance to have to re-write everything you just worked hard to explain.
Git will run the hook before asking for a message if no arguments are passed with git commit.
Commits are handled by the package by passing the file, in which you've written the commit message into, to the commit command in the shell with git commit --file path/to/COMMIT_EDITMSG. After everything finishes, regardless of success, the COMMIT_EDITMSG file gets deleted. Perhaps it is better to keep the file or cache the failed commit message so it is easily retrievable.
This seems to have made it to 7.0.5, though Is see you left it open still. You're aware that this does not pass the test case?
I typo'd and entered the wrong issue number in that commit message. Those changes were not related to this that's why I left it open
I understand, no problem. I was just eager to test and a cursory look-over of the changeset seemed to imply a dialog. Thanks!