-
Notifications
You must be signed in to change notification settings - Fork 1
/
consolidate_release_page.py
executable file
·137 lines (124 loc) · 4.73 KB
/
consolidate_release_page.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/usr/bin/python
#
# Script to move bugs and blueprints to final release milestone page
#
# Copyright 2011-2013 Thierry Carrez <[email protected]>
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import argparse
import sys
from launchpadlib.launchpad import Launchpad
from lazr.restfulclient.errors import BadRequest
# Parameters
parser = argparse.ArgumentParser(description="Consolidate milestone pages"
" at release time")
parser.add_argument('project', help='project to act on')
parser.add_argument('series', help='series to handle')
parser.add_argument('release', help='release milestone')
parser.add_argument('--copytask', action='store_true',
help='Enable CopyTask mode')
parser.add_argument("--test", action='store_const', const='staging',
default='production', help='Use LP staging server to test')
parser.add_argument('--dryrun', action='store_true',
help='Do not actually do anything')
args = parser.parse_args()
if args.dryrun:
print "Dry run, nothing will actually change."
statuses = ['New', 'Incomplete', 'Confirmed', 'Triaged', 'In Progress',
'Fix Committed', 'Fix Released']
# Connect to Launchpad
print "Connecting to Launchpad..."
launchpad = Launchpad.login_with('openstack-releasing', args.test,
version='devel')
# Retrieve FixCommitted bugs
print "Retrieving %s project..." % args.project
proj = launchpad.projects[args.project]
if not proj:
print "Project %s not found" % args.project
sys.exit(1)
print "Retrieving %s series..." % args.series
series = proj.getSeries(name=args.series)
if not series:
print "Series %s not found in project %s" % (args.series, args.project)
sys.exit(1)
print "Checking %s release milestone..." % args.release
release = proj.getMilestone(name=args.release)
if not release:
print "%s is not a %s milestone!" % (args.release, args.project)
sys.exit(1)
print "Retrieving milestones for %s..." % args.series
seriesmilestones = series.all_milestones
milestones = []
release_is_in_series = False
for milestone in seriesmilestones:
if milestone == release:
release_is_in_series = True
else:
if (args.project == "swift" and
not milestone.name.startswith(release.name+"-rc")):
continue
milestones.insert(0, milestone)
print "Found",
for milestone in milestones:
print milestone.name,
print
if not release_is_in_series:
print "%s is not a %s milestone!" % (args.release, args.series)
sys.exit(1)
# Process blueprints
print "Moving all %s blueprints to %s..." % (series.name, release.name)
for bp in series.valid_specifications:
if bp.milestone in milestones:
print bp.name,
if not args.dryrun:
bp.milestone = release
bp.lp_save()
print " - released",
if not bp.is_complete:
print " (not completed!)",
print
# Process bugs
for milestone in milestones:
if args.copytask:
print "CopyTasking %s bugs to %s..." % (milestone.name, release.name)
else:
print "Moving %s bugs to %s..." % (milestone.name, release.name)
bugsleft = True
while bugsleft:
bugsleft = False
for bt in proj.searchTasks(status=statuses, milestone=milestone):
bug = bt.bug
print bug.id,
if not args.dryrun:
if args.copytask:
try:
newbt = bug.addTask(target=series)
newbt.assignee = bt.assignee
newbt.status = bt.status
newbt.importance = bt.importance
newbt.milestone = release
newbt.lp_save()
print " - copytasked",
bugsleft = True
except BadRequest:
print " - task already exists, skipping",
else:
bt.milestone = release
bt.lp_save()
print " - released",
bugsleft = True
if bt.status != 'Fix Released':
print " (not in FixReleased status!)",
print
print