51
51
subparsers = parser.add_subparsers(help='sub-command help', dest="command")
52
52
check_parser = subparsers.add_parser(
53
53
'check', help='Check if merges are blocked for a branch.')
54
check_parser.add_argument(
55
'branch', default='master', nargs='?', type=str.lower,
56
help='The branch to merge into.')
54
check_parser.add_argument('branch', default='master', nargs='?',
55
help='The branch to merge into.')
57
56
check_parser.add_argument('pull_request', default=None, nargs='?',
58
57
help='The pull request to be merged')
59
block_ci_testing_parser = subparsers.add_parser(
61
help='Check if ci testing is blocked for the branch.')
62
block_ci_testing_parser.add_argument(
63
'branch', type=str.lower, help='The branch to merge into.')
64
58
update_parser = subparsers.add_parser(
65
59
'update', help='Update blocking for a branch that passed CI.')
66
60
update_parser.add_argument(
67
61
'-d', '--dry-run', action='store_true', default=False,
68
62
help='Do not make changes.')
69
update_parser.add_argument(
70
'branch', type=str.lower, help='The branch that passed.')
63
update_parser.add_argument('branch', help='The branch that passed.')
71
64
update_parser.add_argument(
72
65
'build', help='The build-revision build number.')
73
args = parser.parse_args(args)
74
if not getattr(args, 'pull_request', None):
75
args.pull_request = None
79
def get_lp_bugs(lp, branch, tags):
66
return parser.parse_args(args)
69
def get_lp_bugs(lp, branch, with_ci=False):
80
70
"""Return a dict of blocker critical bug tasks for the branch."""
82
raise ValueError('tags must be a list of bug tags')
85
if branch.startswith('1.'):
87
project = lp.projects['juju-core']
90
project = lp.projects['juju']
72
project = lp.projects['juju-core']
91
73
if branch == 'master':
92
74
# Lp implicitly assigns bugs to trunk, which is not a series query.
133
119
"""Update the critical blocker+ci bugs for the branch to Fix Released."""
135
121
for bug_id, bug_task in bugs.items():
136
if 'intermittent-failure' in bug_task.bug.tags:
137
changes.append('Skipping intermittent-failure %s' % bug_task.title)
139
122
changes.append('Updated %s' % bug_task.title)
140
123
bug_task.status = 'Fix Released'
153
136
args = parse_args(argv)
154
137
lp = get_lp('check_blockers', credentials_file=args.credentials_file)
155
138
if args.command == 'check':
156
bugs = get_lp_bugs(lp, args.branch, ['blocker'])
157
code, reason = get_reason(bugs, args)
159
if args.command == 'block-ci-testing':
160
bugs = get_lp_bugs(lp, args.branch, ['block-ci-testing'])
139
bugs = get_lp_bugs(lp, args.branch, with_ci=False)
161
140
code, reason = get_reason(bugs, args)
163
142
elif args.command == 'update':
164
bugs = get_lp_bugs(lp, args.branch, ['blocker', 'ci'])
143
bugs = get_lp_bugs(lp, args.branch, with_ci=True)
165
144
code, changes = update_bugs(
166
145
bugs, args.branch, args.build, dry_run=args.dry_run)