Using Git Notes inside Gerrit Hook

280 views
Skip to first unread message

krishna chaitanya kurnala

unread,
Feb 1, 2013, 7:44:04 PM2/1/13
to repo-d...@googlegroups.com
Hello

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.
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 ? Did anyone try using git notes inside gerrit hooks. kindly advise. i really appeciate any insights/guidance.

thanks
Krishna

Alex Blewitt

unread,
Feb 2, 2013, 3:46:20 AM2/2/13
to krishna chaitanya kurnala, repo-d...@googlegroups.com
What is the URL for "origin"? Does running the same command as the same user you're running the hook as succeed?

You aren't capturing stderr which may have further clues as to why it's failing. If your origin is ssh then it could easily be a transport issue like host not found, or a key problem. 

Alex

Sent from my iPhone 5
--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en
 
---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Magnus Bäck

unread,
Feb 3, 2013, 6:11:31 PM2/3/13
to repo-d...@googlegroups.com
On Friday, February 01, 2013 at 19:44 EST,
krishna chaitanya kurnala <kkc...@gmail.com> wrote:

> 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

krishna chaitanya kurnala

unread,
Feb 11, 2013, 7:24:40 PM2/11/13
to repo-d...@googlegroups.com
Hello All

Thank you very much for your time. I have run the git notes commands alone in the project'.git folder and seems to work fine. Apparently, we dont need to fetch/push notes as we are already on the central gerrit server.

Thanks
Krishna
Reply all
Reply to author
Forward
0 new messages