forked from tvansteenburgh/cdk-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tag-milestone.py
executable file
·61 lines (46 loc) · 1.46 KB
/
tag-milestone.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
#!/usr/bin/env python3
"""
Apply a tag to all bugs in a milestone that match a given bug status.
Bugs that already have the tag will be skipped.
"""
import argparse
import datetime
import sys
from launchpadlib import errors as lperrors
from launchpadlib import launchpad
def parse_args():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
'milestone',
help='Name of milestone',
)
parser.add_argument(
'--tag',
help='Name of tag to add (default: "backport-needed")',
default='backport-needed',
)
parser.add_argument(
'--status',
help='Bug status filter. Only bugs with this status will be tagged. (default: "Fix Committed")',
default='Fix Committed',
)
return parser.parse_args()
def main():
args = parse_args()
app = 'Charmed Kubernetes Launchpad Bot'
env = 'production'
lp = launchpad.Launchpad.login_with(app, env)
project_group = lp.project_groups['charmed-kubernetes']
milestone = project_group.getMilestone(name=args.milestone)
if not milestone:
sys.exit("Milestone doesn't exist")
bug_tasks = project_group.searchTasks(milestone=milestone, status=args.status)
for bug_task in bug_tasks:
bug = bug_task.bug
if args.tag in bug.tags:
continue
bug.tags += [args.tag]
bug.lp_save()
print('Tagged bug %s' % bug.id)
if __name__ == '__main__':
main()