Closed EpicWink closed 4 years ago
That is strange - from what I understand, commit-msg
serves as a commit message verification, so it shouldn't interfere with time injection.
The "Not injecting time into cancelled commit" message happens when the commit message is empty (ignoring comments, like git does), because git will not create a commit with an empty message (at least by default) and I sometimes use that to cancel the commit while writing the message - injecting the time made the message valid and un-cancelled the commit.
Do you have any idea why would it happen? What does your commit-msg
do and how do you create the commits?
It is possible that the logic is wrong.
That is strange - from what I understand, commit-msg serves as a commit message verification, so it shouldn't interfere with time injection.
I agree. The Git hooks documentation says that commit-msg
happens after prepare-commit-msg
, so it's execution shouldn't affect prepare-commit-msg
at all
What does your commit-msg do and how do you create the commits?
It checks for a type of string and exits with non-zero return-code if the parsing fails: a glorified GREP
Do you have any idea why would it happen?
My guess is that Git is providing an empty default message when a commit-msg
will be used. I can test this tomorrow and give an update.
I did some testing.
Adding to the top of prepare-commit-msg
echo file $1
echo type $2
echo hash $3
echo ===
cat $1
echo ===
I get the following output:
$ git commit -m "Spam
>
> Jira: SPAM-42"
file .git/COMMIT_EDITMSG
type message
hash
===
Spam
Jira: SPAM-42
===
Not injecting time into cancelled commit
Jira: project 'SPAM', issue number '42'
[master ef766b1] Spam
1 file changed, 2 insertions(+)
It seems like the sed | grep
command is mistakenly identifying the commit message as empty
Thank you for your research, I'll look into it.
Can you please check if the last commit fixes it? The build is here (jar is zipped because of GitHub's restrictions).
Seems to work
Great, thanks!
I have some repos which use the
commit-msg
Git hook. When this is used, the time-tracker's hook doesn't add the tracked time, instead only displaying message "Not injecting time into cancelled commit". If I use--no-verify
, or commit with a repo which doesn't have acommit-msg
hook, it works fine