-
Notifications
You must be signed in to change notification settings - Fork 0
/
gerrit-query.py
executable file
·45 lines (33 loc) · 1.07 KB
/
gerrit-query.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
37
38
39
40
41
42
43
44
45
#!/usr/bin/python3
import json
import requests
import sys
import urllib
# frequently used queries
# hashtag:lacros-move
# owner:ychoi@igalia.com
# mergedbefore:2022-04-01
# mergedafter:2022-04-05
def add_dicts(dicts, key, values):
if key not in dicts:
dicts[key] = list()
dicts[key].append(values)
return add_dicts
SERVER_HOST = "https://chromium-review.googlesource.com"
# create payload
payload = {'q': '+'.join(sys.argv[1:])}
payload_encoded = urllib.parse.urlencode(payload, safe=':+')
response = requests.get(SERVER_HOST+"/changes/", params=payload_encoded)
# print query results
print("GET", response.url)
results = json.loads(response.content[5:])
print("Found", len(results), "CLs from gerrit....")
cl_lists = {}
for data in results:
add_dicts(cl_lists, data['owner']['_account_id'], data['subject'])
for key in cl_lists:
name = (requests.get(SERVER_HOST+"/accounts/"+str(key)+"/name").content[5:]
.decode('ascii')
.strip('\n'))
print("\n", name, "(%d)" % len(cl_lists[key]))
print("\n".join(cl_lists[key]))