comparison maintainer-scripts/bugzilla-close-candidate.py @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 #!/usr/bin/env python3
2
3 # The script is used for finding PRs that have a SVN revision that
4 # mentiones the PR and are not closed. It's done by iterating all
5 # comments of a PR and finding SVN commit entries.
6
7 """
8 Sample output of the script:
9 Bugzilla URL page size: 50
10 HINT: bugs with following comment are ignored: Can the bug be marked as resolved?
11
12 Bug URL SVN commits known-to-fail known-to-work Bug summary
13 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88129 trunk Two blockage insns are emited in the function epilogue
14 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88122 trunk [9 Regression] g++ ICE: internal compiler error: Segmentation fault
15 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88084 trunk basic_string_view::copy doesn't use Traits::copy
16 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88083 trunk ICE in find_constant_pool_ref_1, at config/s390/s390.c:8231
17 ...
18 Bugzilla lists:
19 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
20 https://gcc.gnu.org/bugzilla/buglist.cgi?bug_id=87486
21 """
22
23 import argparse
24 import json
25
26 import requests
27
28 base_url = 'https://gcc.gnu.org/bugzilla/rest.cgi/'
29 statuses = ['UNCONFIRMED', 'ASSIGNED', 'SUSPENDED', 'NEW', 'WAITING', 'REOPENED']
30 regex = '(.*\[)([0-9\./]*)( [rR]egression])(.*)'
31 closure_question = 'Can the bug be marked as resolved?'
32 start_page = 20
33 url_page_size = 50
34
35 def get_branches_by_comments(comments):
36 versions = set()
37 for c in comments:
38 text = c['text']
39 if 'URL: https://gcc.gnu.org/viewcvs' in text:
40 version = 'trunk'
41 for l in text.split('\n'):
42 if 'branches/gcc-' in l:
43 parts = l.strip().split('/')
44 parts = parts[1].split('-')
45 assert len(parts) == 3
46 versions.add(parts[1])
47 versions.add(version)
48 return versions
49
50 def get_bugs(api_key, query):
51 u = base_url + 'bug'
52 r = requests.get(u, params = query)
53 return r.json()['bugs']
54
55 def search(api_key):
56 chunk = 1000
57 ids = []
58 print('%-53s%-30s%-40s%-40s%-60s' % ('Bug URL', 'SVN commits', 'known-to-fail', 'known-to-work', 'Bug summary'))
59 for i in range(start_page, 0, -1):
60 # print('offset: %d' % (i * chunk), flush = True)
61 bugs = get_bugs(api_key, {'api_key': api_key, 'bug_status': statuses, 'limit': chunk, 'offset': i * chunk})
62 for b in sorted(bugs, key = lambda x: x['id'], reverse = True):
63 id = b['id']
64
65 fail = b['cf_known_to_fail']
66 work = b['cf_known_to_work']
67
68 u = base_url + 'bug/' + str(id) + '/comment'
69 r = requests.get(u, params = {'api_key': api_key} ).json()
70 keys = list(r['bugs'].keys())
71 assert len(keys) == 1
72 comments = r['bugs'][keys[0]]['comments']
73 for c in comments:
74 if closure_question in c['text']:
75 continue
76
77 branches = get_branches_by_comments(comments)
78 if len(branches):
79 branches_str = ','.join(sorted(list(branches)))
80 print('%-53s%-30s%-40s%-40s%-60s' % ('https://gcc.gnu.org/bugzilla/show_bug.cgi?id=%d' % id, branches_str, fail, work, b['summary']))
81 ids.append(id)
82
83 # print all URL lists
84 print('\nBugzilla lists:')
85 while len(ids) > 0:
86 print('https://gcc.gnu.org/bugzilla/buglist.cgi?bug_id=%s' % ','.join([str(x) for x in ids[:url_page_size]]))
87 ids = ids[url_page_size:]
88
89 print('Bugzilla URL page size: %d' % url_page_size)
90 print('HINT: bugs with following comment are ignored: %s\n' % closure_question)
91
92 parser = argparse.ArgumentParser(description='')
93 parser.add_argument('api_key', help = 'API key')
94
95 args = parser.parse_args()
96 search(args.api_key)