-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfilter_opened_bug_issues.py
114 lines (89 loc) · 2.67 KB
/
filter_opened_bug_issues.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import argparse
from tqdm import tqdm
from release_utils import (
GH_REPO,
GH_USER,
get_github,
get_milestone,
get_repo,
get_split_date,
setup_cache,
)
parser = argparse.ArgumentParser(usage=__doc__)
parser.add_argument('from_commit', help='The starting tag.')
parser.add_argument('to_commit', help='The head branch.')
parser.add_argument(
'--milestone',
help='if present then filter issues with a given milestone',
default=None,
type=str,
)
parser.add_argument(
'--skip-triaged',
action='store_true',
default=False,
help='if present then skip triaged PRs',
)
parser.add_argument('--label', help='The label', action='append')
args = parser.parse_args()
if args.label is None:
args.label = ['bug']
setup_cache()
repository = get_repo()
if args.milestone is not None:
if args.milestone.lower() == 'none':
milestone_search_string = 'no:milestone'
milestone = None
else:
milestone = get_milestone(args.milestone)
milestone_search_string = f'milestone:"{milestone.title}"'
else:
milestone_search_string = ''
milestone = None
previous_tag_date = get_split_date(args.from_commit, args.to_commit)
probably_solved = repository.get_label('probably solved')
need_to_reproduce = repository.get_label('need to reproduce')
if args.skip_triaged:
triage_labels = [
x for x in repository.get_labels() if x.name.startswith('triaged')
]
else:
triage_labels = []
labels = [repository.get_label(label) for label in args.label]
search_string = (
f'repo:{GH_USER}/{GH_REPO} is:issue is:open '
f'created:>{previous_tag_date.isoformat()} '
'sort:updated-desc ' + milestone_search_string
)
# print(search_string, file=sys.stderr)
for label in labels:
search_string += f' label:"{label.name}"'
iterable = get_github().search_issues(search_string)
issue_list = []
for issue in tqdm(
iterable,
desc='issues...',
total=iterable.totalCount,
):
if '[test-bot]' in issue.title:
continue
if probably_solved in issue.labels:
continue
if need_to_reproduce in issue.labels:
continue
if args.skip_triaged and any(x in issue.labels for x in triage_labels):
continue
issue_list.append(issue)
if len(labels) > 1:
label_string = 'labels ' + ', '.join([x.name for x in labels])
else:
label_string = f'label {labels[0].name}'
header = f'## {len(issue_list)} Opened Issues with {label_string}'
if milestone:
if milestone_search_string.startswith('no:'):
header += ' and no milestone'
else:
header += f' and milestone {milestone.title}'
print(header)
for issue in issue_list:
print(f' * [ ] #{issue.number}')