patchset-created hook will miss topic (commit message) information

112 views
Skip to first unread message

林倩如

unread,
Nov 15, 2016, 11:42:11 AM11/15/16
to Repo and Gerrit Discussion
Why this is marked as abuse? It has been marked as abuse.
Report not abuse
Hi guys,

I am trying to use Gerrit and Redmine for my project. I wrote a batch file that should be triggered every time there is a new patchset. (I call patchset_created.bat via the patchset-created hook)
This script I wrote is to apply new patchset to Redmine. However, when I put the batch file under $GERRIT_HOME\hook\ and triggered git comment “git push origin HEAD:refs/for/TEST1”, it just send below information to Gerrit server. It miss "topic" information.

python "C:\Bitnami\redmine-3.0.3-0\gerrit\review_site\hooks\patchset_created.bat" --change I9cde6eb5bb89cb6e6856e266b302e3f7f18e9cc2 --is-draft false --kind REWORK --change-url http://XXXXX.com:1001/7428 --change-owner "sherry.lin (sherr...@XXXXX.com)" --project MP1234/alps/abi --branch TEST1 --uploader "sherry.lin (sherr...@XXXXX.com)" --commit 7078c7df5b6465110b65b071c9eed60b9a7903dd --patchset 1

Those information doesn’t have topic (commit message), so Redmine always can’t get #${redmine-issue-id} and update the issue.
What should I do let it can send topic (commit message) when I trigger git comment to Gerrit?

Below are my Gerrit and Redmine version information.
Redmine version is 3.3.0 (OS version is Ubuntu 16.04)
Gerrit version is 2.11.3 (OS version is Windows 2008 server)

 I think I probably done this incorrectly since I don't have any experience with Gerrit before.

PS1. Attachment is my patchset_created.bat on Gerrit server. (Please change the txt to bat)
PS2. I refer https://github.com/tru/redmine-gerrit-scripts this link to integrate Gerrit and Redmine and modify my batch file.

PS3. I saw https://dev.vaadin.com/review/Documentation/config-hooks.html has default information. (patchset-created --change <change id> --is-draft <boolean> --kind <change kind> --change-url <change url> --change-owner <change owner> --project <project name> --branch <branch> --topic <topic> --uploader <uploader> --commit <sha1> --patchset <patchset id>)


Many thanks and hope to listen your reply.
Sherry Lin

patchset_created.txt

David Pursehouse

unread,
Nov 15, 2016, 8:54:17 PM11/15/16
to 林倩如, Repo and Gerrit Discussion
Why this is marked as abuse? It has been marked as abuse.
Report not abuse
The change topic is passed to the hook with the --topic parameter, however it seems that what you actually want is the commit message.

The commit message does not get sent to the hook.  If you need this you'll need to use the revision (from the --commit parameter) to get the commit message out of the git repository.



--
--
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/d/optout.

林倩如

unread,
Nov 16, 2016, 8:32:22 PM11/16/16
to Repo and Gerrit Discussion, sherry...@gmail.com
Why this is marked as abuse? It has been marked as abuse.
Report not abuse
I need parses the commit messages from Gerrit and looks for a Redmine issue in the style of "#1028".

Do you know how to use the revision (from the --commit parameter) to get the commit message out of the git repository?

Thanks your reply and best regards,
Sherry

David Pursehouse於 2016年11月16日星期三 UTC+8上午9時54分17秒寫道:

Zaro

unread,
Nov 17, 2016, 1:25:27 PM11/17/16
to 林倩如, Repo and Gerrit Discussion
Why this is marked as abuse? It has been marked as abuse.
Report not abuse
To be more specific, I believe what David is saying is that you can
run another command, like query[1], in your script to get the commit
message. You just need to pass it the sha1 of the commit you received
from hook. You could also call the REST revisions[2] endpoint to get
the commit message as well.


[1] https://gerrit-documentation.storage.googleapis.com/Documentation/2.13.2/cmd-query.html#EXAMPLES
[2] https://gerrit-documentation.storage.googleapis.com/Documentation/2.13.2/rest-api-changes.html#get-commit

David Pursehouse

unread,
Nov 17, 2016, 8:37:17 PM11/17/16
to Zaro, 林倩如, Repo and Gerrit Discussion
Why this is marked as abuse? It has been marked as abuse.
Report not abuse
On Thu, Nov 17, 2016 at 10:25 AM Zaro <zaro...@gmail.com> wrote:
To be more specific, I believe what David is saying is that you can
run another command, like query[1], in your script to get the commit
message. 

I was rather thinking it would be possible to get it directly by a git command, since the hook is likely to be running on the same server where the repositories are located.
Reply all
Reply to author
Forward
0 new messages