You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
1) Add a "prepare-commit-msg" Git hook (see Git docs here) that contains a shell script that outputs the second parameter passed to the hook:
2) In Sourcetree, perform a merge that has no conflicts WITHOUT the "Commit merge immediately (if no conflicts)" option checked.
3) In Sourcetree, commit the result and click "Show Full Output" in the resulting modal window.
4) Observe the output; specifically around the last line before "Completed successfully."
The "prepare-commit-msg" script should output the second parameter as: "merge".
This can be verified by performing a merge WITH the "Commit merge immediately (if no conflicts)" option checked (which will result in the correct value of "merge" being printed).
See attached screenshot "with_option_checked-CORRECT.png"
The "prepare-commit-msg" script outputs the second parameter as "message" (which is incorrect; it should be "merge").
See attached screenshot "without_option_checked-WRONG.png"
The steps above are simply to demonstrate the issue.
The actual issue occurs when we perform a merge that has conflicts and then try to commit from Sourcetree. This results in the same scenario as seen in the steps above, where Sourcetree does not commit the merge immediately but does provide a commit message. After we resolve the conflicts we commit from Sourcetree and that is when we see the issue.
My team's "prepare-commnit-msg" hook relies on the second parameter to customize the commit message when a merge conflict exists. We rely on this commit message to know what files had conflicts so we know what files to review and re-test after a merge with conflicts.
Without the correct parameter, our hook cannot detect that a merge is occurring and therefore cannot customize the commit message.
Do not use Sourcetree; commit from the command line.