Question

I'm using Gerrit Code review.

I have a problem with it. There are some hooks with Gerrit, one of them is:

patchset-created --change <change id> --change-url <change url>
--project <project name> --branch <branch> --uploader <uploader>
--commit <sha1> --patchset <patchset id> 

Gerrit will call it if you push some change to Gerrit.

The commit parameter passed in is the sha1 commit number, but what I want is the commit log. For example, if I do git commit -m "id:110", I want to get id:110.

How can I get it? Is there any API I can use?

Was it helpful?

Solution 2

i have solve the problem myself.it seems that gerrit has not such apis. but , if patchset-created hook is called , the change parameter it passed in is usefull, if refer to a private key of gerrit database table ,named Change ,every git push to gerrit it record such change to the Change table , include the commit message , so , you can use the change parameter to query the table , so got the commit message from the hook !

OTHER TIPS

You can use git log or git show, run from within the correct repository. Your hook will be passed the repo via --repository. The hook will be called from a useful working directory (I just checked into this last week, I think it cd's into the repo before running the hook?)

git log $SHA1 or git show $SHA1 depending on which information you want.

That said, I'd prefer a better solution. I'm looking to add the diff / patchset to the information, and it is not available via any of the gerrit hooks.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top