I am currently in the process to add some automation after a user pulls or merge into the current branch (e.g. update user settings, build updated dependencies). I read the hook documentation and found out that pre-merge-commit / post-merge hooks would do that for me. So, the in the use case that we have no merge conflicts, i.e. the merge was successful, both hooks should trigger.
This works fine as long as the merge creates no changes on the working copy (as result of the merge). But if there are changes (e.g. a new file has been added) and I run the git merge command with --no-commit option, both pre-merge-commit and post-merge hooks are NOT executed.
At least with the pre-merge-commit hook I would expect to get the hook fired as the hook is triggered before the commit!
Is this by design? Is there another way to trigger a script after a merge has been successful ignoring the option if I want a commit afterall?
Thanks!
I agree with you that the documentation is not very clear about when it should be executed, but I think that at least the commit process has to begin. Here is why:
pre-merge-commit[...] is invoked after the merge has been carried out successfully and before obtaining the proposed commit log message to make a commit
First part is clear, merge must be successful. Second part could be misunderstood, but I interpreted in this way:
pre-merge-commit runsAfter all, this hook, in its default implementation runs the pre-commit hook that is in turn called by git commit. Especially this last part has made me think that it is not a bug or anything like that, but a design choice.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With