I’m working on a “commit-msg” git hook that validates whether some specific information is present in the commit comment (JIRA ticket id). However, I’m realizing that if the commit is a merge commit, we can’t expect the JIRA ticket to be present, as that will sometimes be created automatically without human intervention.
I know that completed merge commits have two (or more) parents, so that’s how you can detect merge commits that are already committed, but in the case of a git hook, the merge commit doesn’t exist yet.
I don’t think it’s sufficient to check for “merge” in the commit comment.
I saw this post: Figure out merged commit in prepare-commit-msg hook
The well-respected answer was written almost ten years ago. I hope it is still accurate. I’m also wondering about some of the details in that answer. The answerer describes this “GITHEAD_” environment variable. What exactly will that “” value be? Will that be a commit id? If so, what commit does that correspond to?