-
Notifications
You must be signed in to change notification settings - Fork 2
/
repopick.py
36 lines (30 loc) · 1.28 KB
/
repopick.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import sys
import urllib
import urllib2
import json
import os
for change in sys.argv[1:]:
print change
f = urllib2.urlopen('http://gerrit.omnirom.org/query?q=change:%s' % change)
d = f.read()
# gerrit doesnt actually return json. returns two json blobs, separate lines. bizarre.
print d
d = d.split('\n')[0]
data = json.loads(d)
project = data['project']
project = project.replace('android_', '')
while not os.path.isdir(project):
new_project = project.replace('_', '/', 1)
if new_project == project:
break
project = new_project
print project
number = data['number']
patch_count = 0
junk = number[len(number) - 2:]
while 0 != os.system('cd %s ; git fetch http://gerrit.omnirom.org/%s refs/changes/%s/%s/%s' % (project, data['project'], junk, number, patch_count + 1)):
patch_count = patch_count + 1
while 0 == os.system('cd %s ; git fetch http://gerrit.omnirom.org/%s refs/changes/%s/%s/%s' % (project, data['project'], junk, number, patch_count + 1)):
patch_count = patch_count + 1
os.system('cd %s ; git fetch http://gerrit.omnirom.org/%s refs/changes/%s/%s/%s' % (project, data['project'], junk, number, patch_count))
os.system('cd %s ; git merge --no-edit FETCH_HEAD' % project)