On Friday, February 01, 2013 at 19:44 EST,
> I am trying to come up with a hook that would parse the commit message
> of any change that is Approved/Merged in Gerrit and add a portion of
> the commit message to git notes.
You know about refs/notes/review, right?
http://gerrit-documentation.googlecode.com/svn/Documentation/2.5/refs-notes-review.html
> I added a snippet to change-merged gerrit hook, for example,
> git fetch origin +refs/notes/*:refs/notes/* >> $hook_logfile
>
> I get single entry "exit status 128" in the log file.
>
> Does git notes need a valid workspace to execute ?
It operates on a Git repository, so yes there must be a Git repository
context. An easy way of doing this is changing to the directory of the
repository you want to affect.
> Did anyone try using git notes inside gerrit hooks. kindly advise. i
> really appeciate any insights/guidance.
Was the above the only contents of the hook? Things to consider:
- The working directory when the change-merged hook is run is probably
undefined, so you'll have to step into the correct Git directory
yourself. This is trivial since the hook is called with the
--project option.
- "git fetch origin" doesn't make sense because there is no origin
remote. The git in question *is* the origin.
_ As someone else has pointed out you're not catching stderr output
so the cause of the 128 exit status from the hook is hard to debug.
Gerrit should log stderr output if if doesn't already do so.
--
Magnus Bäck
ba...@google.com