Skip to content
This repository was archived by the owner on Apr 30, 2025. It is now read-only.

Commit b742b42

Browse files
dobeyTarmac Traffic Controller
authored andcommitted
Add a --list-approved option to the merge command.
2 parents d1856e9 + 325d1f5 commit b742b42

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

tarmac/bin/commands.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# Copyright 2009-2012 Paul Hummer
2+
# Copyright 2009-2014 Canonical Ltd.
3+
#
4+
# Tarmac is free software: you can redistribute it and/or modify
5+
# it under the terms of the GNU General Public License version 3 as
6+
# published by
7+
# the Free Software Foundation.
8+
#
9+
# Tarmac is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with Tarmac. If not, see <http://www.gnu.org/licenses/>.
116
'''Command handling for Tarmac.'''
217
import httplib2
318
import logging
@@ -158,7 +173,9 @@ class cmd_merge(TarmacCommand):
158173
options.http_debug_option,
159174
options.debug_option,
160175
options.imply_commit_message_option,
161-
options.one_option]
176+
options.one_option,
177+
options.list_approved_option,
178+
]
162179

163180
def _handle_merge_error(self, proposal, failure):
164181
"""Handle TarmacMergeError cases from _do_merges."""
@@ -200,6 +217,11 @@ def _do_merges(self, branch_url):
200217
'branch_url': branch_url})
201218
return
202219

220+
if self.config.list_approved:
221+
for proposal in proposals:
222+
print(get_review_url(proposal))
223+
return
224+
203225
try:
204226
target = Branch.create(lp_branch, self.config, create_tree=True,
205227
launchpad=self.launchpad)

tarmac/bin/options.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# Copyright 2010-2011 Paul Hummer
2+
# Copyright 2010-2014 Canonical Ltd.
3+
#
4+
# Tarmac is free software: you can redistribute it and/or modify
5+
# it under the terms of the GNU General Public License version 3 as
6+
# published by
7+
# the Free Software Foundation.
8+
#
9+
# Tarmac is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with Tarmac. If not, see <http://www.gnu.org/licenses/>.
116
'''Command options.'''
217
from bzrlib.option import Option
318

@@ -18,3 +33,6 @@
1833
one_option = Option(
1934
'one', short_name='1',
2035
help='Merge only one branch and exit.')
36+
list_approved_option = Option(
37+
'list-approved', short_name='l',
38+
help='List Approved merge proposals for the target branch.')

tarmac/tests/test_commands.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,13 @@ def test_run_merge_with_invalid_workingtree(self, mocked):
449449
self.assertEqual(self.error.comment,
450450
invalid_tree_comment)
451451

452+
@patch('tarmac.bin.commands.get_review_url')
453+
def test_run_merge_with_list_approved_option(self, mocked):
454+
"""Test that --list-approved option prints a list and returns."""
455+
self.addProposal('list_approved')
456+
self.command.run(launchpad=self.launchpad, list_approved=True)
457+
self.assertEqual(mocked.call_count, 2)
458+
452459
def test__compare_proposals(self):
453460
"""
454461
_compare_proposals is meant to be a sort routine comparison function

0 commit comments

Comments
 (0)