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
1=== modified file 'docs/introduction.txt'
2--- docs/introduction.txt 2012-06-25 21:05:28 +0000
3+++ docs/introduction.txt 2013-03-07 17:38:27 +0000
4@@ -151,6 +151,11 @@
5 **reviewer**
6 The display name of the merge proposal reviewer.
7
8+**branch_name**
9+ The short branch name. i.e.: branch_name in "lp:~user/project/branch_name"
10+
11+**\n**
12+ A \n in the commit message template will be rendered as a newline character.
13
14 Command
15 =======
16
17=== modified file 'tarmac/plugins/commitmessage.py'
18--- tarmac/plugins/commitmessage.py 2010-10-25 21:27:39 +0000
19+++ tarmac/plugins/commitmessage.py 2013-03-07 17:38:27 +0000
20@@ -30,18 +30,17 @@
21
22 def run(self, command, target, source, proposal):
23 # pylint: disable-msg=W0613
24-
25 try:
26- template = target.config.commit_message_template
27- template = template.replace('<', '%(').replace('>', ')s')
28+ proposal.commit_message = self.render(
29+ target.config.commit_message_template,
30+ CommitMessageTemplateInfo(proposal))
31 except AttributeError:
32 return
33
34- proposal.commit_message = self.render(
35- template, CommitMessageTemplateInfo(proposal))
36-
37 def render(self, template, info):
38 """Render a template using the given information."""
39+ template = template.replace('<', '%(').replace('>', ')s')
40+ template = template.replace('\\n', '\n')
41 return template % info
42
43
44@@ -77,6 +76,11 @@
45 return self._proposal.commit_message
46
47 @property
48+ def branch_name(self):
49+ """The branch name under review."""
50+ return self._proposal.source_branch.name
51+
52+ @property
53 def reviewer(self):
54 """The display name of the merge proposal reviewer.
55
56
57=== modified file 'tarmac/plugins/tests/test_commitmessage.py'
58--- tarmac/plugins/tests/test_commitmessage.py 2010-10-25 21:27:39 +0000
59+++ tarmac/plugins/tests/test_commitmessage.py 2013-03-07 17:38:27 +0000
60@@ -12,6 +12,7 @@
61 super(TestCommitMessageTemplateInfo, self).setUp()
62 self.proposal = Thing(
63 source_branch=Thing(
64+ name="name",
65 owner=Thing(display_name="Arthur Author", name="arthur"),
66 linked_bugs=[Thing(id=1234), Thing(id=5678)]),
67 commit_message="Awesome",
68@@ -83,8 +84,8 @@
69 return "{info:%s}" % name
70
71
72-class TestCommitMessageTemplate(TarmacTestCase):
73-
74+class TestCommitMessageTemplate(TestCommitMessageTemplateInfo):
75+
76 def test_render(self):
77 message_template = CommitMessageTemplate()
78 message_info = FakeCommitMessageTemplateInfo()
79@@ -99,3 +100,7 @@
80 self.assertEqual(
81 "{info:author} {info:reviewer}",
82 render("%(author)s %(reviewer)s", message_info))
83+ self.assertEqual(
84+ "{info:author} {info:branch_name} {info:reviewer}",
85+ render("<author> <branch_name> <reviewer>", message_info))
86+ self.assertEqual("one\ntwo", render("one\\ntwo", message_info))

Subscribers

People subscribed via source and target branches