Issue 1326: Gerrit 2.3 | hook names are incorrect
Status:  Accepted
Owner: ----
Reported by evil...@gmail.com, Apr 11, 2012
Affected Version: 2.3

What steps will reproduce the problem?
1. Set up hooks for Gerrit with default settings
2. Undertake any event that should trigger a hook
3. Check hook has fired

What is the expected output?

The hook appropriate for the event should fire

What do you see instead?

Rather that the correct hook getting fired it fires 'gerrit-hook' instead. Setting the names explicitly using the "hooks" config section makes no difference.

This was working just fine for us until I upgraded to 2.3. The error_log output shows that up until that point the correct file names were being used and after that it always calls 'gerrit-hooks'.

Please provide any additional information below.
Apr 12, 2012
#1 evil...@gmail.com
Ok, I've managed to resolve this. I basically stopped, moved the hooks folder, restarted Gerrit and moved the hooks folder back and it now works.

Truly odd. Unfortunately, I don't know enough (any thing) about Java to dig into this myself. If those who can want to close the ticket I opened please feel free but if you want to investigate and I can provide any further information please do let me know.

Apr 12, 2012
Project Member #2 mf...@codeaurora.org
(No comment was entered for this change.)
Status: Invalid
May 16, 2012
#3 claus.ro...@lumigon.com
Seen similar issues after updating to 2.3. 

When using symbolic links to point to a common hook-script the first argument to the script will be changed after updating the common hook-script. 

As stated above, recreating the folder will make it operational again, but will fail again after updating the hook. 

Commenting an issue with comment-added symlinked to python-script gives:
sys.argv= ['/home/gerrit2/gerrit/hooks/comment-added', ... ]

After updating the python-script, commenting an issue gives:
sys.argv= ['/home/gerrit2/gerrit/hooks/hook', ... ]
May 16, 2012
#4 evil...@gmail.com
Heh. Glad it wasn't just me going insane :)
May 16, 2012
#5 sop@google.com
I think the change here might be the server doing a "resolve" call on the file path. Which is possibly chasing symbolic links back to the original. And it does it a few times, once for "hooks" and again for the individual hook commands. And there may be some differences between startup and later during server execution. Ick.

I'm not sure when these changes were made, or why, but I was looking at the hook setup code over the weekend as I was looking at ejecting it to a plugin, and it was reading funny to me with all of the resolve calls here.
Status: Accepted
May 16, 2012
#6 evil...@gmail.com
You know, it would be nice if there was an option to just use one script and have the "hook" name passed in rather then having to have multiple scripts (or, as in my case, one script with symlinks). Both are valid solutions but I suspect having one script that can handle hooks is generally going to be simpler.