| Issue 1424: | "git pull " is not executed in Gerrit hook change-merged | |
| 2 people starred this issue and may be notified of changes. | Back to list |
************************************************************
***** NOTE: THIS BUG TRACKER IS FOR GERRIT CODE REVIEW *****
***** DO NOT SUBMIT BUGS FOR CHROME, ANDROID, INTERNAL *****
***** ISSUES WITH YOUR COMPANY'S GERRIT SETUP, ETC. *****
***** THOSE ISSUE BELONG IN DIFFERENT ISSUE TRACKERS! *****
************************************************************
Affected Version:2.4
What steps will reproduce the problem?
1. My objective is to update a local working git repository immediately after some change is merged into the master branch of a bare repository managed by Gerrit. Both repositories are on the same machine with ubuntu 12.04. My Gerrit is deployed in Tomcat6.
2. I put some commnands in gerrit hook file change-merged:
//change to the existing local working git repository cloned previously
git pull file:///path/to/bare/reposiroty >> temp.txt
whoami >> temp.txt
2. I review and submit the change through Gerrit
3.
What is the expected output? What do you see instead?
I expect that the new master branch is pulled into the local working repository. However, it seems that "git pull" is not executed at all. There is nothing recored in temp.txt except "tomcat6". The working repository is not changed.
Please provide any additional information below.
I tried to run the script as "sudo -u tomcat6 command". This time, it works well. So I guess that it is not a problem of Linux permission.
As I tested, "git clone" command can be executed in the hook file.
Jun 6, 2012
#1
icee...@googlemail.com
Jun 6, 2012
Sure, your method may work. But it is strange why "git pull" and "git fetch" cannot be executed in Gerrit hook. "change-merged" seems to be the suitable place to do such operations. Thanks.
Jun 10, 2012
I guess the push/merge is not considered complete as long as not all hooks have run. So in the hook you will only see the previous state if you are calling git like you do. So git fect/pull will be do-nothings.
Jun 11, 2012
If so, "git pull file:///path/to/bare/reposiroty >> temp.txt" should at least generate some messages to say that the operations cannot be done. right?
Jun 20, 2012
You might want to do "git pull --ff-only" instead. Can you log standard error as well? git pull --ff-only file:///path/to/bare/reposiroty >> temp.txt 2> /tmp/err.txt
Jun 20, 2012
Thanks. You are very cool. I got an error message in err.txt as "fatal: /usr/lib/git-core/git-pull cannot be used without a working tree.". Then I googled for solution and found that environment variable GIT_DIR is set wrongly as "/path/to/bare/reposiroty". So in script I temperialy changed GIT_DIR to a value needed for running "git pull" and restored its original value after that. That works. I cannot understand why Gerrit sets such an environment variable GIT_DIR. However, my problem is solved. Thank you all.
Oct 9, 2014
Am facing a similar problem wherein the change-merged hook has stopped firing. Mainly i want to create a new gerrit on a separate branch after a change is merged in the master branch of gerrit. Any information/help in this regard is appreciated. Thanks, Pratik
Oct 9, 2014
Try to log error information like: git pull --ff-only file:///path/to/bare/reposiroty >> temp.txt 2> /tmp/err.txt Then check it and you may know the reason. Hope this help. |
|
| ► Sign in to add a comment |