Created
August 12, 2014 12:08
-
-
Save jturcotte/02558ed46ddce0d6ff00 to your computer and use it in GitHub Desktop.
Submit a gerrit patch using it's local SHA1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import subprocess | |
import sys | |
import re | |
import json | |
localCommit = sys.argv[1] | |
gitShow = subprocess.check_output(['git', 'show', '--no-patch', localCommit]) | |
for line in gitShow.decode().splitlines(): | |
m = re.search(r"Change-Id: (\w+)", line) | |
if m: | |
changeId = m.group(1) | |
break | |
changeJson = subprocess.check_output(['ssh', 'codereview.qt-project.org', 'gerrit', 'query', '--format', 'json', '--patch-sets', changeId + ' status:open']) | |
change = json.loads(changeJson.decode().splitlines()[0]) | |
gerritCommit = change['patchSets'][-1]['revision'] | |
print('Submitting gerrit commit', gerritCommit, 'for Change-Id', changeId, 'of local commit', localCommit, '...') | |
subprocess.check_call(['ssh', 'codereview.qt-project.org', 'gerrit', 'review', '--submit', gerritCommit]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment