Port bugzilla-close-candidate script to git.
maintainer-scripts/ChangeLog: * bugzilla-close-candidate.py: Support both SVN and GIT messages in PRs. Remove need of usage of the bugzilla API key.
This commit is contained in:
parent
961c2aac7f
commit
c92716b2b1
|
@ -1,19 +1,19 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
# The script is used for finding PRs that have a SVN revision that
|
# The script is used for finding PRs that have a GIT revision that
|
||||||
# mentiones the PR and are not closed. It's done by iterating all
|
# mentiones the PR and are not closed. It's done by iterating all
|
||||||
# comments of a PR and finding SVN commit entries.
|
# comments of a PR and finding GIT commit entries.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Sample output of the script:
|
Sample output of the script:
|
||||||
Bugzilla URL page size: 50
|
Bugzilla URL page size: 50
|
||||||
HINT: bugs with following comment are ignored: Can the bug be marked as resolved?
|
HINT: bugs with following comment are ignored: Can the bug be marked as resolved?
|
||||||
|
|
||||||
Bug URL SVN commits known-to-fail known-to-work Bug summary
|
Bug URL GIT commits known-to-fail known-to-work Bug summary
|
||||||
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88129 trunk Two blockage insns are emited in the function epilogue
|
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88129 master Two blockage insns are emited in the function epilogue
|
||||||
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88122 trunk [9 Regression] g++ ICE: internal compiler error: Segmentation fault
|
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88122 master [9 Regression] g++ ICE: internal compiler error: Segmentation fault
|
||||||
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88084 trunk basic_string_view::copy doesn't use Traits::copy
|
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88084 master basic_string_view::copy doesn't use Traits::copy
|
||||||
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88083 trunk ICE in find_constant_pool_ref_1, at config/s390/s390.c:8231
|
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88083 master ICE in find_constant_pool_ref_1, at config/s390/s390.c:8231
|
||||||
...
|
...
|
||||||
Bugzilla lists:
|
Bugzilla lists:
|
||||||
https://gcc.gnu.org/bugzilla/buglist.cgi?bug_id=88129,88122,88084,88083,88074,88073,88071,88070,88051,88018,87985,87955,87926,87917,87913,87898,87895,87874,87871,87855,87853,87826,87824,87819,87818,87799,87793,87789,87788,87787,87754,87725,87674,87665,87649,87647,87645,87625,87611,87610,87598,87593,87582,87566,87556,87547,87544,87541,87537,87528
|
https://gcc.gnu.org/bugzilla/buglist.cgi?bug_id=88129,88122,88084,88083,88074,88073,88071,88070,88051,88018,87985,87955,87926,87917,87913,87898,87895,87874,87871,87855,87853,87826,87824,87819,87818,87799,87793,87789,87788,87787,87754,87725,87674,87665,87649,87647,87645,87625,87611,87610,87598,87593,87582,87566,87556,87547,87544,87541,87537,87528
|
||||||
|
@ -36,29 +36,38 @@ def get_branches_by_comments(comments):
|
||||||
versions = set()
|
versions = set()
|
||||||
for c in comments:
|
for c in comments:
|
||||||
text = c['text']
|
text = c['text']
|
||||||
if 'URL: https://gcc.gnu.org/viewcvs' in text:
|
lines = text.split('\n')
|
||||||
version = 'trunk'
|
for line in lines:
|
||||||
for l in text.split('\n'):
|
if 'URL: https://gcc.gnu.org/viewcvs' in line:
|
||||||
if 'branches/gcc-' in l:
|
version = 'master'
|
||||||
parts = l.strip().split('/')
|
if 'branches/gcc-' in line:
|
||||||
|
parts = line.strip().split('/')
|
||||||
parts = parts[1].split('-')
|
parts = parts[1].split('-')
|
||||||
assert len(parts) == 3
|
assert len(parts) == 3
|
||||||
versions.add(parts[1])
|
versions.add(parts[1])
|
||||||
versions.add(version)
|
versions.add(version)
|
||||||
|
elif line.startswith('The ') and 'branch has been updated' in line:
|
||||||
|
version = 'master'
|
||||||
|
name = line.strip().split(' ')[1]
|
||||||
|
if '/' in name:
|
||||||
|
name = name.split('/')[1]
|
||||||
|
assert '-' in name
|
||||||
|
version = name.split('-')[1]
|
||||||
|
versions.add(version)
|
||||||
return versions
|
return versions
|
||||||
|
|
||||||
def get_bugs(api_key, query):
|
def get_bugs(query):
|
||||||
u = base_url + 'bug'
|
u = base_url + 'bug'
|
||||||
r = requests.get(u, params = query)
|
r = requests.get(u, params = query)
|
||||||
return r.json()['bugs']
|
return r.json()['bugs']
|
||||||
|
|
||||||
def search(api_key):
|
def search():
|
||||||
chunk = 1000
|
chunk = 1000
|
||||||
ids = []
|
ids = []
|
||||||
print('%-53s%-30s%-40s%-40s%-60s' % ('Bug URL', 'SVN commits', 'known-to-fail', 'known-to-work', 'Bug summary'))
|
print('%-30s%-30s%-40s%-40s%-60s' % ('Bug URL', 'GIT commits', 'known-to-fail', 'known-to-work', 'Bug summary'))
|
||||||
for i in range(start_page, 0, -1):
|
for i in range(start_page, 0, -1):
|
||||||
# print('offset: %d' % (i * chunk), flush = True)
|
# print('offset: %d' % (i * chunk), flush = True)
|
||||||
bugs = get_bugs(api_key, {'api_key': api_key, 'bug_status': statuses, 'limit': chunk, 'offset': i * chunk})
|
bugs = get_bugs({'bug_status': statuses, 'limit': chunk, 'offset': i * chunk})
|
||||||
for b in sorted(bugs, key = lambda x: x['id'], reverse = True):
|
for b in sorted(bugs, key = lambda x: x['id'], reverse = True):
|
||||||
id = b['id']
|
id = b['id']
|
||||||
|
|
||||||
|
@ -66,7 +75,7 @@ def search(api_key):
|
||||||
work = b['cf_known_to_work']
|
work = b['cf_known_to_work']
|
||||||
|
|
||||||
u = base_url + 'bug/' + str(id) + '/comment'
|
u = base_url + 'bug/' + str(id) + '/comment'
|
||||||
r = requests.get(u, params = {'api_key': api_key} ).json()
|
r = requests.get(u).json()
|
||||||
keys = list(r['bugs'].keys())
|
keys = list(r['bugs'].keys())
|
||||||
assert len(keys) == 1
|
assert len(keys) == 1
|
||||||
comments = r['bugs'][keys[0]]['comments']
|
comments = r['bugs'][keys[0]]['comments']
|
||||||
|
@ -77,7 +86,7 @@ def search(api_key):
|
||||||
branches = get_branches_by_comments(comments)
|
branches = get_branches_by_comments(comments)
|
||||||
if len(branches):
|
if len(branches):
|
||||||
branches_str = ','.join(sorted(list(branches)))
|
branches_str = ','.join(sorted(list(branches)))
|
||||||
print('%-53s%-30s%-40s%-40s%-60s' % ('https://gcc.gnu.org/bugzilla/show_bug.cgi?id=%d' % id, branches_str, fail, work, b['summary']))
|
print('%-30s%-30s%-40s%-40s%-60s' % ('https://gcc.gnu.org/PR%d' % id, branches_str, fail, work, b['summary']), flush=True)
|
||||||
ids.append(id)
|
ids.append(id)
|
||||||
|
|
||||||
# print all URL lists
|
# print all URL lists
|
||||||
|
@ -90,7 +99,6 @@ print('Bugzilla URL page size: %d' % url_page_size)
|
||||||
print('HINT: bugs with following comment are ignored: %s\n' % closure_question)
|
print('HINT: bugs with following comment are ignored: %s\n' % closure_question)
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='')
|
parser = argparse.ArgumentParser(description='')
|
||||||
parser.add_argument('api_key', help = 'API key')
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
search(args.api_key)
|
search()
|
||||||
|
|
Loading…
Reference in New Issue