Merge lp:~rockstar/tarmac/review-url-commit-message into lp:tarmac

Proposed by Paul Hummer
Status: Merged
Approved by: Paul Hummer
Approved revision: 377
Merged at revision: 378
Proposed branch: lp:~rockstar/tarmac/review-url-commit-message
Merge into: lp:tarmac
Diff against target: 94 lines (+24/-5)
4 files modified
tarmac/bin/commands.py (+2/-4)
tarmac/plugins/commitmessage.py (+5/-0)
tarmac/plugins/tests/test_commitmessage.py (+7/-1)
tarmac/utility.py (+10/-0)
To merge this branch: bzr merge lp:~rockstar/tarmac/review-url-commit-message
Reviewer Review Type Date Requested Status
dobey Approve
Review via email: mp+39322@code.launchpad.net

Commit message

Add the review url to the commit message template plugin.

Description of the change

This branch just adds support for putting the review url in the commit message.

To post a comment you must log in.
Revision history for this message
dobey (dobey) :
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 2010-10-12 19:58:22 +0000
3+++ tarmac/bin/commands.py 2010-10-25 21:34:41 +0000
4@@ -2,7 +2,6 @@
5 import httplib2
6 import logging
7 import os
8-import re
9
10 from bzrlib.commands import Command
11 from bzrlib.errors import PointlessMerge
12@@ -17,6 +16,7 @@
13 from tarmac.exceptions import (TarmacMergeError, TarmacCommandError,
14 UnapprovedChanges)
15 from tarmac.plugin import load_plugins
16+from tarmac.utility import get_review_url
17
18
19 class TarmacCommand(Command):
20@@ -233,9 +233,7 @@
21 target.cleanup()
22 continue
23
24- urlp = re.compile('http[s]?://api\.(.*)launchpad\.net/[^/]+/')
25- merge_url = urlp.sub(
26- 'http://code.launchpad.net/', proposal.self_link)
27+ merge_url = get_review_url(proposal)
28 revprops = {'merge_url': merge_url}
29
30 commit_message = proposal.commit_message
31
32=== modified file 'tarmac/plugins/commitmessage.py'
33--- tarmac/plugins/commitmessage.py 2010-07-21 07:25:47 +0000
34+++ tarmac/plugins/commitmessage.py 2010-10-25 21:34:41 +0000
35@@ -17,6 +17,7 @@
36 '''Tarmac plugin for enforcing a commit message format.'''
37 from tarmac.hooks import tarmac_hooks
38 from tarmac.plugins import TarmacPlugin
39+from tarmac.utility import get_review_url
40
41
42 class CommitMessageTemplate(TarmacPlugin):
43@@ -107,6 +108,10 @@
44 return ",".join(
45 str(bug.id) for bug in self._proposal.source_branch.linked_bugs)
46
47+ @property
48+ def review_url(self):
49+ return get_review_url(self._proposal)
50+
51
52 tarmac_hooks['tarmac_pre_commit'].hook(CommitMessageTemplate(),
53 'Commit messsage template editor.')
54
55=== modified file 'tarmac/plugins/tests/test_commitmessage.py'
56--- tarmac/plugins/tests/test_commitmessage.py 2010-09-02 22:56:39 +0000
57+++ tarmac/plugins/tests/test_commitmessage.py 2010-10-25 21:34:41 +0000
58@@ -25,7 +25,8 @@
59 comment=Thing(vote=u"Approve"),
60 reviewer=Thing(
61 display_name="Virginia Voter", name="virginia")),
62- ])
63+ ],
64+ self_link=u"http://api.launchpad.net/1.0/~rockstar/tarmac/tarmac/+merge/1")
65 self.info = CommitMessageTemplateInfo(self.proposal)
66
67 def test_author(self):
68@@ -45,6 +46,11 @@
69 "Virgil Voter, Virginia Voter",
70 self.info.approved_by)
71
72+ def test_review_url(self):
73+ self.assertEqual(
74+ u"http://code.launchpad.net/~rockstar/tarmac/tarmac/+merge/1",
75+ self.info.review_url)
76+
77 def test_approved_by_nicks(self):
78 self.assertEqual(
79 "virgil,virginia",
80
81=== added file 'tarmac/utility.py'
82--- tarmac/utility.py 1970-01-01 00:00:00 +0000
83+++ tarmac/utility.py 2010-10-25 21:34:41 +0000
84@@ -0,0 +1,10 @@
85+"""Utilities for Tarmac."""
86+import re
87+
88+
89+def get_review_url(proposal):
90+ """Return the web url for a given proposal."""
91+ urlp = re.compile('http[s]?://api\.(.*)launchpad\.net/[^/]+/')
92+ merge_url = urlp.sub(
93+ 'http://code.launchpad.net/', proposal.self_link)
94+ return merge_url

Subscribers

People subscribed via source and target branches