Merge lp:~davidpbritton/tarmac/ls-fixes into lp:~ubuntuone-hackers/tarmac/trunk

Proposed by David Britton on 2013-03-07
Status: Merged
Approved by: James Westby on 2013-03-07
Approved revision: 426
Merged at revision: 430
Proposed branch: lp:~davidpbritton/tarmac/ls-fixes
Merge into: lp:~ubuntuone-hackers/tarmac/trunk
Diff against target: 86 lines (+22/-8)
3 files modified
docs/introduction.txt (+5/-0)
tarmac/plugins/commitmessage.py (+10/-6)
tarmac/plugins/tests/test_commitmessage.py (+7/-2)
To merge this branch: bzr merge lp:~davidpbritton/tarmac/ls-fixes
Reviewer Review Type Date Requested Status
James Westby (community) 2013-03-07 Approve on 2013-03-07
Review via email: mp+152235@code.launchpad.net

Description of the change

Formatting changes: allow specification of the branch name, allow newlines characters.

To post a comment you must log in.
James Westby (james-w) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'docs/introduction.txt'
--- docs/introduction.txt 2012-06-25 21:05:28 +0000
+++ docs/introduction.txt 2013-03-07 17:38:27 +0000
@@ -151,6 +151,11 @@
151**reviewer**151**reviewer**
152 The display name of the merge proposal reviewer.152 The display name of the merge proposal reviewer.
153153
154**branch_name**
155 The short branch name. i.e.: branch_name in "lp:~user/project/branch_name"
156
157**\n**
158 A \n in the commit message template will be rendered as a newline character.
154159
155Command160Command
156=======161=======
157162
=== modified file 'tarmac/plugins/commitmessage.py'
--- tarmac/plugins/commitmessage.py 2010-10-25 21:27:39 +0000
+++ tarmac/plugins/commitmessage.py 2013-03-07 17:38:27 +0000
@@ -30,18 +30,17 @@
3030
31 def run(self, command, target, source, proposal):31 def run(self, command, target, source, proposal):
32 # pylint: disable-msg=W061332 # pylint: disable-msg=W0613
33
34 try:33 try:
35 template = target.config.commit_message_template34 proposal.commit_message = self.render(
36 template = template.replace('<', '%(').replace('>', ')s')35 target.config.commit_message_template,
36 CommitMessageTemplateInfo(proposal))
37 except AttributeError:37 except AttributeError:
38 return38 return
3939
40 proposal.commit_message = self.render(
41 template, CommitMessageTemplateInfo(proposal))
42
43 def render(self, template, info):40 def render(self, template, info):
44 """Render a template using the given information."""41 """Render a template using the given information."""
42 template = template.replace('<', '%(').replace('>', ')s')
43 template = template.replace('\\n', '\n')
45 return template % info44 return template % info
4645
4746
@@ -77,6 +76,11 @@
77 return self._proposal.commit_message76 return self._proposal.commit_message
7877
79 @property78 @property
79 def branch_name(self):
80 """The branch name under review."""
81 return self._proposal.source_branch.name
82
83 @property
80 def reviewer(self):84 def reviewer(self):
81 """The display name of the merge proposal reviewer.85 """The display name of the merge proposal reviewer.
8286
8387
=== modified file 'tarmac/plugins/tests/test_commitmessage.py'
--- tarmac/plugins/tests/test_commitmessage.py 2010-10-25 21:27:39 +0000
+++ tarmac/plugins/tests/test_commitmessage.py 2013-03-07 17:38:27 +0000
@@ -12,6 +12,7 @@
12 super(TestCommitMessageTemplateInfo, self).setUp()12 super(TestCommitMessageTemplateInfo, self).setUp()
13 self.proposal = Thing(13 self.proposal = Thing(
14 source_branch=Thing(14 source_branch=Thing(
15 name="name",
15 owner=Thing(display_name="Arthur Author", name="arthur"),16 owner=Thing(display_name="Arthur Author", name="arthur"),
16 linked_bugs=[Thing(id=1234), Thing(id=5678)]),17 linked_bugs=[Thing(id=1234), Thing(id=5678)]),
17 commit_message="Awesome",18 commit_message="Awesome",
@@ -83,8 +84,8 @@
83 return "{info:%s}" % name84 return "{info:%s}" % name
8485
8586
86class TestCommitMessageTemplate(TarmacTestCase):87class TestCommitMessageTemplate(TestCommitMessageTemplateInfo):
8788
88 def test_render(self):89 def test_render(self):
89 message_template = CommitMessageTemplate()90 message_template = CommitMessageTemplate()
90 message_info = FakeCommitMessageTemplateInfo()91 message_info = FakeCommitMessageTemplateInfo()
@@ -99,3 +100,7 @@
99 self.assertEqual(100 self.assertEqual(
100 "{info:author} {info:reviewer}",101 "{info:author} {info:reviewer}",
101 render("%(author)s %(reviewer)s", message_info))102 render("%(author)s %(reviewer)s", message_info))
103 self.assertEqual(
104 "{info:author} {info:branch_name} {info:reviewer}",
105 render("<author> <branch_name> <reviewer>", message_info))
106 self.assertEqual("one\ntwo", render("one\\ntwo", message_info))

Subscribers

People subscribed via source and target branches