I am trying to cherry-pick gerrit reviews using a python script. I already have the string required to cherry-pick a review. I have used pexpect to automate the password input step.
Here is an example. For each review I have to execute the following 2 commands:
- git fetch "ssh://myusername@my-gerrit.server.net:34343/project" refs/changes/45/255645/38
- git cherry-pick FETCH_HEAD
Only the first command asks for a password. Here is the code i have written:
child = pexpect.spawn('git fetch "ssh://myusername@my-gerrit.server.net:34343/project" refs/changes/45/255645/38')
child.logfile_read = sys.stdout
child.expect(r'Enter passphrase for key(.*?):', timeout=10)
child.sendline('mypwd')
child.expect([pexpect.TIMEOUT, 'host$', pexpect.EOF])
child.sendline('git cherry-pick FETCH_HEAD')
child.expect([pexpect.TIMEOUT, 'host$', pexpect.EOF])
When i run the script i dont see any error. However the second command (git cherry-pick FETCH_HEAD) doesnt seem to be executed. I say this because when i run these commands manually the second command throws a git merge conflict. When i run the script i dont see cherry-pick in progress (git status shows all clean). I tried some variants but cannot get it to work. Please help.
Thanks in advance