Gerrit 钩子 API
我正在使用 Gerrit 代码审查。
我有一个问题。 Gerrit 有一些钩子,其中之一是:
patchset-created --change <change id> --change-url <change url>
--project <project name> --branch <branch> --uploader <uploader>
--commit <sha1> --patchset <patchset id>
如果您向 Gerrit 推送一些更改,Gerrit 就会调用它。
传入的commit参数是sha1提交号,但我想要的是提交日志。例如,如果我执行 git commit -m "id:110"
,我想获得 id:110
。
我怎样才能得到它?有我可以使用的 API 吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 git log 或 git show,从正确的存储库中运行。您的钩子将通过 --repository 传递到存储库。该钩子将从一个有用的工作目录中调用(我上周刚刚签入,我认为它在运行钩子之前已进入存储库?)
git log $SHA1
或git show $ SHA1
取决于您想要的信息。也就是说,我更喜欢更好的解决方案。我希望将差异/补丁集添加到信息中,但它无法通过任何 gerrit 挂钩获得。
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
orgit 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.
我自己解决了这个问题。似乎gerrit没有这样的api。
但是,如果调用 patchset 创建的钩子,它传入的更改参数是有用的,
如果引用gerrit数据库表的私钥,名为Change,每次git推送到gerrit时,它都会将此类更改记录到Change表中,并包含提交消息,因此,您可以使用change参数来查询该表,从而获得提交消息挂起!
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 !