Skip to content

Commit

Permalink
move bugs fetch into build_package, drop make_release_notes
Browse files Browse the repository at this point in the history
  • Loading branch information
nskaggs committed Dec 6, 2017
1 parent 311dab4 commit 10fad20
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 222 deletions.
30 changes: 27 additions & 3 deletions releasetests/build_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from argparse import ArgumentParser
from collections import namedtuple
from launchpadlib.launchpad import Launchpad
import os
import re
import shutil
Expand Down Expand Up @@ -448,7 +449,7 @@ def create_source_package(source_dir, spb, series, version,
sign_source_package(source_dir, gpgcmd, debemail, debfullname)


def build_source(tarfile_path, location, series, bugs,
def build_source(tarfile_path, location, series, milestone,
debemail=None, debfullname=None, gpgcmd=None,
branch=None, upatch=1, verbose=False,
date=None, build=None, revid=None, epoch=None):
Expand Down Expand Up @@ -476,6 +477,7 @@ def build_source(tarfile_path, location, series, bugs,
:param epoch: The epoch to pass in version name
:return: the exit code (which is 0 or else an exception was raised).
"""
bugs = get_bugs("juju-build-package", milestone)
if not isinstance(series, list):
series = [series]
tarfile_name = os.path.basename(tarfile_path)
Expand Down Expand Up @@ -504,6 +506,28 @@ def build_source(tarfile_path, location, series, bugs,
return 0


def get_lp_bug_tasks(script, milestone_name):
"""Return an iterators of Lp BugTasks,"""
lp = Launchpad.login_anonymously(
script, service_root='https://api.launchpad.net', version='devel')
if milestone_name.startswith('1.'):
project = lp.projects['juju-core']
else:
project = lp.projects['juju']
milestone = project.getMilestone(name=milestone_name)
return milestone.searchTasks(status=['Fix Committed'])


def get_bugs(script, milestone):
"""Return a list of bug tuples (id, title)."""
bug_tasks = get_lp_bug_tasks(script, milestone)
bugs = []
for bugtask in bug_tasks:
bug = bugtask.bug
bugs.append((bug.id, bug.title.capitalize()))
return bugs


def print_series_info(package_version=None):
exitcode = 1
if package_version:
Expand All @@ -520,7 +544,7 @@ def main(argv):
args = get_args(argv)
if args.command == 'source':
exitcode = build_source(
args.tar_file, args.location, args.series, args.bugs,
args.tar_file, args.location, args.series, args.milestone,
debemail=args.debemail, debfullname=args.debfullname,
gpgcmd=args.gpgcmd, branch=args.branch, upatch=args.upatch,
verbose=args.verbose, date=args.date, build=args.build,
Expand Down Expand Up @@ -569,7 +593,7 @@ def get_args(argv=None):
src_parser.add_argument(
'--revid', default=None, help="The short hash for revid")
src_parser.add_argument(
'bugs', nargs='*', help="Bugs this version will fix in the release.")
'milestone', default=None, help="The milestone this release is for.")
bin_parser = subparsers.add_parser('binary', help='Build a binary package')
bin_parser.add_argument(
'--ppa', default=None, help="The PPA that provides package deps.")
Expand Down
30 changes: 27 additions & 3 deletions releasetests/build_package_lxd.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from argparse import ArgumentParser
from collections import namedtuple
from launchpadlib.launchpad import Launchpad
import os
import re
import shutil
Expand Down Expand Up @@ -454,7 +455,7 @@ def create_source_package(source_dir, spb, series, version,
sign_source_package(source_dir, gpgcmd, debemail, debfullname)


def build_source(tarfile_path, location, series, bugs,
def build_source(tarfile_path, location, series, milestone,
debemail=None, debfullname=None, gpgcmd=None,
branch=None, upatch=1, verbose=False,
date=None, build=None, revid=None, epoch=None):
Expand Down Expand Up @@ -482,6 +483,7 @@ def build_source(tarfile_path, location, series, bugs,
:param epoch: The epoch to pass in version name
:return: the exit code (which is 0 or else an exception was raised).
"""
bugs = get_bugs("juju-build-package", milestone)
if not isinstance(series, list):
series = [series]
tarfile_name = os.path.basename(tarfile_path)
Expand Down Expand Up @@ -510,6 +512,28 @@ def build_source(tarfile_path, location, series, bugs,
return 0


def get_lp_bug_tasks(script, milestone_name):
"""Return an iterators of Lp BugTasks,"""
lp = Launchpad.login_anonymously(
script, service_root='https://api.launchpad.net', version='devel')
if milestone_name.startswith('1.'):
project = lp.projects['juju-core']
else:
project = lp.projects['juju']
milestone = project.getMilestone(name=milestone_name)
return milestone.searchTasks(status=['Fix Committed'])


def get_bugs(script, milestone):
"""Return a list of bug tuples (id, title)."""
bug_tasks = get_lp_bug_tasks(script, milestone)
bugs = []
for bugtask in bug_tasks:
bug = bugtask.bug
bugs.append((bug.id, bug.title.capitalize()))
return bugs


def print_series_info(package_version=None):
exitcode = 1
if package_version:
Expand All @@ -526,7 +550,7 @@ def main(argv):
args = get_args(argv)
if args.command == 'source':
exitcode = build_source(
args.tar_file, args.location, args.series, args.bugs,
args.tar_file, args.location, args.series, args.milestone,
debemail=args.debemail, debfullname=args.debfullname,
gpgcmd=args.gpgcmd, branch=args.branch, upatch=args.upatch,
verbose=args.verbose, date=args.date, build=args.build,
Expand Down Expand Up @@ -575,7 +599,7 @@ def get_args(argv=None):
src_parser.add_argument(
'--revid', default=None, help="The short hash for revid")
src_parser.add_argument(
'bugs', nargs='*', help="Bugs this version will fix in the release.")
'milestone', default=None, help="The milestone this release is for.")
bin_parser = subparsers.add_parser('binary', help='Build a binary package')
bin_parser.add_argument(
'--ppa', default=None, help="The PPA that provides package deps.")
Expand Down
216 changes: 0 additions & 216 deletions releasetests/make_release_notes.py

This file was deleted.

0 comments on commit 10fad20

Please sign in to comment.