Add tool that annotates bug numbers with details from LP

Change-Id: If751e1e50a52a93fc3afd56e5f8f4021c14817cc
This commit is contained in:
Ihar Hrachyshka 2016-03-23 15:20:28 +01:00
parent 9ee1cb3c08
commit 5c8601bf77
2 changed files with 76 additions and 0 deletions

View File

@ -927,3 +927,16 @@ Example::
List bugs that are fixed in master since 8.0.0 that don't have relevant fixes
merged in stable/mitaka.
annotate-lp-bugs.py
-------------------
Reads the list of Launchpad bug numbers on stdin and writes out a nice and
detailed description for each of them.
Example::
./bugs-fixed-since.py --start=8.0.0 | ./annotate-lp-bugs neutron
Pull in detailed description for bugs that are fixed in master since 8.0.0.

63
annotate-lp-bugs.py Executable file
View File

@ -0,0 +1,63 @@
#!/usr/bin/env python
#
# 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.
"""
This tool will transform bug numbers into proper Launchpad links.
"""
import argparse
import sys
from launchpadlib.launchpad import Launchpad
def _parse_args():
parser = argparse.ArgumentParser(
description='Dump useful bug info.')
parser.add_argument(
'project', help='Launchpad project name')
return parser.parse_args()
def _annotate_bug(lp, project, bugnum):
bug = lp.bugs[bugnum]
for task in bug.bug_tasks:
if task.bug_target_name == project:
break
else:
return
assignee = task.assignee.name if task.assignee else 'Unassigned'
print(
'%(url)s "%(title)s" (%(importance)s,%(status)s) [%(tags)s] [%(assignee)s]' %
{'url': 'https://bugs.launchpad.net/bugs/%s' % bugnum,
'title': bug.title,
'importance': task.importance,
'status': task.status,
'tags': ','.join(bug.tags),
'assignee': assignee})
def main():
args = _parse_args()
lp = Launchpad.login_with('openstack-releasing', 'production')
for line in sys.stdin.readlines():
bugnum = line.strip()
_annotate_bug(lp, args.project, bugnum)
if __name__ == '__main__':
main()