Git pre-push hook executed twice
Answered
Hi,
I'm using IDEA Commuity on a Maven multi-project and Git. I have configured a hook to "mvn clean install" before pushing a branch. The script is at <project_dir>/.git/hooks/pre-push
bbo@work ~/B/projects> cd .git/hooks/
bbo@work ~/B/p/.g/hooks> ls -l pre-push
-rwxrwxr-x. 1 bbo bbo 79 16 mars 2018 pre-push*
But the hook is executed twice : before and after pushing.
[...]
[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
[[1;34mINFO[m] [1;32mBUILD SUCCESS[m
[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
[[1;34mINFO[m] Total time: 02:01 min
[[1;34mINFO[m] Finished at: 2018-10-09T11:54:57+02:00
[[1;34mINFO[m] Final Memory: 82M/1567M
[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
Delta compression using up to 4 threads.
Total 167 (delta 64), reused 0 (delta 0)
remote:
remote: Create a pull request for '<xxx-Branch>' on GitHub by visiting:
remote: https://github.com/<company>/<project>/pull/new/<xxx-Branch>
remote:
To github.com:<company>/<project>.git
* refs/heads/<xxx-Branch>:refs/heads/<xxx-Branch> [new branch]
Branch '<xxx-Branch>' set up to track remote branch '<xxx-Branch>' from 'origin'.
Done
11:55:02.107: [<project>] git -c core.quotepath=false -c log.showSignature=false push --progress --porcelain origin refs/heads/<xxx-Branch>:<xxx-Branch> --set-upstream
[[1;34mINFO[m] Scanning for projects...
[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
[[1;34mINFO[m] [1mReactor Build Order:[m
[[1;34mINFO[m]
[...]
Would you have some clue to avoid it ?
Thank you.
Please sign in to leave a comment.
Does it happen only when you build in IntelliJ IDEA or when you run Maven build in the terminal as well?
Hi !
Yes, it happens only when I build/push in Intellij IDEA. From the command line, it is correctly executed :
Are you sure it is the hook which is executed twice? Can it be possible that one of these `mvn clean install` commands are issued from IDEA Maven Integration? If you're not sure, to diagnose this you can add some output line to the hook that would clearly indicate that it it a hook which is being executed.
At any case, please reproduce the issue and attach idea.log file.