Merge lp:~dobey/tarmac/lp-committer into lp:tarmac

Proposed by dobey
Status: Merged
Approved by: dobey
Approved revision: 424
Merged at revision: 424
Proposed branch: lp:~dobey/tarmac/lp-committer
Merge into: lp:tarmac
Diff against target: 106 lines (+31/-6)
4 files modified
tarmac/bin/commands.py (+2/-1)
tarmac/branch.py (+12/-4)
tarmac/tests/test_branch.py (+15/-0)
tarmac/tests/test_commands.py (+2/-1)
To merge this branch: bzr merge lp:~dobey/tarmac/lp-committer
Reviewer Review Type Date Requested Status
Chris Johnston Approve
Review via email: mp+194388@code.launchpad.net

Commit message

Use the display name for the bot/person running tarmac, as committer.

To post a comment you must log in.
Revision history for this message
Chris Johnston (cjohnston) wrote :

Looks fine

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tarmac/bin/commands.py'
2--- tarmac/bin/commands.py 2013-11-05 16:39:20 +0000
3+++ tarmac/bin/commands.py 2013-11-07 17:30:48 +0000
4@@ -190,7 +190,8 @@
5 return
6
7 try:
8- target = Branch.create(lp_branch, self.config, create_tree=True)
9+ target = Branch.create(lp_branch, self.config, create_tree=True,
10+ launchpad=self.launchpad)
11 except TarmacMergeError as failure:
12 self._handle_merge_error(proposals[0], failure)
13 return
14
15=== modified file 'tarmac/branch.py'
16--- tarmac/branch.py 2013-11-06 21:46:43 +0000
17+++ tarmac/branch.py 2013-11-07 17:30:48 +0000
18@@ -34,7 +34,7 @@
19
20 class Branch(object):
21
22- def __init__(self, lp_branch, config=False, target=None):
23+ def __init__(self, lp_branch, config=False, target=None, launchpad=None):
24 self.lp_branch = lp_branch
25 self.bzr_branch = bzr_branch.Branch.open(self.lp_branch.bzr_identity)
26 if config:
27@@ -42,6 +42,7 @@
28 else:
29 self.config = None
30
31+ self.launchpad = launchpad
32 self.target = target
33 self.logger = logging.getLogger('tarmac')
34
35@@ -55,8 +56,10 @@
36 pass
37
38 @classmethod
39- def create(cls, lp_branch, config, create_tree=False, target=None):
40- clazz = cls(lp_branch, config, target)
41+ def create(cls, lp_branch, config, create_tree=False, target=None,
42+ launchpad=None):
43+ clazz = cls(lp_branch, config=config, target=target,
44+ launchpad=launchpad)
45 if create_tree:
46 clazz.create_tree()
47 return clazz
48@@ -166,8 +169,13 @@
49 'review identity or vote.')
50 revprops['reviews'] = '\n'.join(reviews)
51
52+ if self.launchpad is not None:
53+ committer = self.launchpad.me.display_name
54+ else:
55+ committer = 'Tarmac'
56+
57 try:
58- self.tree.commit(commit_message, committer='Tarmac',
59+ self.tree.commit(commit_message, committer=committer,
60 revprops=revprops, authors=authors)
61 except AssertionError as error:
62 raise TarmacMergeError(str(error))
63
64=== modified file 'tarmac/tests/test_branch.py'
65--- tarmac/tests/test_branch.py 2013-11-06 21:46:43 +0000
66+++ tarmac/tests/test_branch.py 2013-11-07 17:30:48 +0000
67@@ -28,6 +28,7 @@
68 from tarmac.tests import (
69 BranchTestCase,
70 MockLPBranch,
71+ Thing,
72 )
73
74
75@@ -223,3 +224,17 @@
76 a_branch.bzr_branch.user_url = 'lp:invalid'
77 self.assertRaises(InvalidWorkingTree,
78 a_branch.create_tree)
79+
80+ def test_committer_is_launchpad_user(self):
81+ """Test that the committer when committing, is the LP user's name."""
82+ tree_dir = os.path.join(self.TEST_ROOT, 'test_lp_committer')
83+ self.add_branch_config(tree_dir)
84+ self.addCleanup(self.remove_branch_config, tree_dir)
85+ self.addCleanup(shutil.rmtree, tree_dir)
86+
87+ committer = 'LP User'
88+ a_branch = branch.Branch.create(MockLPBranch(tree_dir), self.config,
89+ create_tree=True, launchpad=Thing(
90+ me=Thing(display_name=committer)))
91+ a_branch.commit('Test LP User.')
92+ self.assertEqual(committer, a_branch.authors[0])
93
94=== modified file 'tarmac/tests/test_commands.py'
95--- tarmac/tests/test_commands.py 2013-11-05 16:39:20 +0000
96+++ tarmac/tests/test_commands.py 2013-11-07 17:30:48 +0000
97@@ -172,7 +172,8 @@
98 reviewer=Thing(display_name=u'Reviewer2'))])]
99 self.branches[1].landing_candidates = self.proposals
100
101- self.launchpad = Thing(branches=Thing(getByUrl=self.getBranchByUrl))
102+ self.launchpad = Thing(branches=Thing(getByUrl=self.getBranchByUrl),
103+ me=Thing(display_name='Tarmac'))
104 self.error = None
105 registry = CommandRegistry(config=self.config)
106 registry.register_command('merge', commands.cmd_merge)

Subscribers

People subscribed via source and target branches