Background
When emoji-commit receives the path .git/COMMIT_EDITMSG it assumes that the file is empty and it will initialize a new commit message by displaying the emoji-picker. This is the typical and desired behavior when invoking git commit. This will overwrite the content of .git/COMMIT_EDITMSG .
Issue
I have found some cases where emoji-commit will receive .git/COMMIT_EDITMSG and it is not desired to overwrite the content of .git/COMMIT_EDITMSG.
After doing a git pull --rebase that results in one or more conflicts, the final step of resolving those conflicts are by running git rebase --continue. Git wants to give the user the option to edit the commit message (as documented in https://git-scm.com/docs/git-rebase#_commit_rewording) which results in .git/COMMIT_EDITMSG being sent to emoji-commit.
After running git rebase --interactive and selecting reword on one or more commits, the previous message will be written to .git/COMMIT_EDITMSG and provided to emoji-commit.
When running git commit --amend.
Solution
I propose that we solve this by checking if the git message is empty (either each line is empty or starts with a #) before displaying the emoji-picker. If the message is empty we proceed as always and show the emoji-picker. Otherwise we launch the default editor with the given path, which will give the user the option to edit or keep the current message. I will create a PR with a solution proposal.
Background When emoji-commit receives the path
.git/COMMIT_EDITMSG
it assumes that the file is empty and it will initialize a new commit message by displaying the emoji-picker. This is the typical and desired behavior when invokinggit commit
. This will overwrite the content of.git/COMMIT_EDITMSG
.Issue I have found some cases where emoji-commit will receive
.git/COMMIT_EDITMSG
and it is not desired to overwrite the content of.git/COMMIT_EDITMSG
.git pull --rebase
that results in one or more conflicts, the final step of resolving those conflicts are by runninggit rebase --continue
. Git wants to give the user the option to edit the commit message (as documented in https://git-scm.com/docs/git-rebase#_commit_rewording) which results in.git/COMMIT_EDITMSG
being sent to emoji-commit.git rebase --interactive
and selecting reword on one or more commits, the previous message will be written to.git/COMMIT_EDITMSG
and provided to emoji-commit.git commit --amend
.Solution I propose that we solve this by checking if the git message is empty (either each line is empty or starts with a #) before displaying the emoji-picker. If the message is empty we proceed as always and show the emoji-picker. Otherwise we launch the default editor with the given path, which will give the user the option to edit or keep the current message. I will create a PR with a solution proposal.