Add script for mapping reviews to bugs and their milestones
Change-Id: Iaca8ee0e0bdd353e28ab819b561b550b58e075e2
This commit is contained in:
parent
639450956e
commit
41e8f1876e
|
@ -18,6 +18,7 @@ for project in ${projects} ; do
|
|||
(date -u && echo && ./openreviews.py -p ${project}) > results/${project_base}-openreviews.txt
|
||||
./openreviews.py -p ${project} --html > results/${project_base}-openreviews.html
|
||||
(date -u && echo && ./openapproved.py -p ${project}) > results/${project_base}-openapproved.txt
|
||||
(date -u && echo && ./reviews_for_bugs.py -p ${project}) > results/${project_base}-reviews-for-bugs.txt
|
||||
done
|
||||
|
||||
if [ "${all}" = "1" ] ; then
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright 2013 Russell Bryant <rbryant@redhat.com>
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
from argparse import ArgumentParser
|
||||
import getpass
|
||||
from launchpadlib.launchpad import Launchpad
|
||||
import re
|
||||
import sys
|
||||
|
||||
import utils
|
||||
|
||||
|
||||
def main():
|
||||
parser = ArgumentParser(
|
||||
description="Get reviews for open bugs against a milestone")
|
||||
parser.add_argument('-p', '--project', default='projects/nova.json',
|
||||
help='JSON file describing the project to generate stats for')
|
||||
parser.add_argument('-u', '--user', default=getpass.getuser(),
|
||||
help='gerrit user')
|
||||
parser.add_argument('-k', '--key', default=None, help='ssh key for gerrit')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
projects = utils.get_projects_info(args.project, False)
|
||||
project_name = projects[0]['name']
|
||||
|
||||
if not projects:
|
||||
print "Please specify a project."
|
||||
return 1
|
||||
|
||||
launchpad = Launchpad.login_with('openstack-releasing', 'production')
|
||||
proj = launchpad.projects[project_name]
|
||||
statuses = ['New', 'Incomplete', 'Confirmed', 'Triaged', 'In Progress']
|
||||
bugtasks = proj.searchTasks(status=statuses)
|
||||
bugs_by_id = {}
|
||||
for bt in bugtasks:
|
||||
bugs_by_id[str(bt.bug.id)] = bt
|
||||
|
||||
milestones = {}
|
||||
|
||||
changes = utils.get_changes(projects, args.user, args.key, only_open=True)
|
||||
bug_regex = re.compile('bug/(\d+)')
|
||||
for change in changes:
|
||||
if 'topic' not in change:
|
||||
continue
|
||||
match = bug_regex.match(change['topic'])
|
||||
if not match:
|
||||
continue
|
||||
bugid = match.group(1)
|
||||
try:
|
||||
bugtask = bugs_by_id[bugid]
|
||||
milestone = str(bugtask.milestone).split('/')[-1]
|
||||
if milestone == 'None':
|
||||
milestone = 'Untargeted'
|
||||
except KeyError:
|
||||
milestone = 'Bug does not exist for this project'
|
||||
|
||||
milestones.setdefault(milestone, [])
|
||||
milestones[milestone].append((change['url'], bugid))
|
||||
|
||||
print 'Reviews for bugs grouped by milestone for project: %s\n' % (
|
||||
project_name)
|
||||
|
||||
for milestone, reviews in milestones.items():
|
||||
print 'Milestone: %s' % milestone
|
||||
for review, bugid in reviews:
|
||||
print '--> %s -- https://bugs.launchpad.net/%s/+bug/%s' % (review,
|
||||
project_name, bugid)
|
||||
print
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
Loading…
Reference in New Issue