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.

0
3 comments

Does it happen only when you build in IntelliJ IDEA or when you run Maven build in the terminal as well?

0

Hi !

Yes, it happens only when I build/push in Intellij IDEA. From the command line, it is correctly executed :

bbo@work ~/B/project>git push origin xxx-branch
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:

[...]

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:05 min
[INFO] Finished at: 2018-10-10T16:29:25+02:00
[INFO] Final Memory: 82M/1278M
[INFO] ------------------------------------------------------------------------
Décompte des objets: 23, fait.
Delta compression using up to 4 threads.
Compression des objets: 100% (20/20), fait.
Écriture des objets: 100% (23/23), 1.73 KiB | 1.73 MiB/s, fait.
Total 23 (delta 14), reused 0 (delta 0)
remote: Resolving deltas: 100% (14/14), completed with 14 local objects.
To github.com:<company>/<project>.git
+ a76b05ac...a59c5f09 <xxx-branch> -> <xxx-branch>
bbo@work ~/B/project> 
0

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.

0

Please sign in to leave a comment.