Merge lp:~james-w/tarmac/commit-message into lp:~ubuntuone-hackers/tarmac/trunk

Proposed by James Westby
Status: Merged
Approved by: Jonathan Lange
Approved revision: 416
Merged at revision: 418
Proposed branch: lp:~james-w/tarmac/commit-message
Merge into: lp:~ubuntuone-hackers/tarmac/trunk
Prerequisite: lp:~james-w/tarmac/utf8
Diff against target: 28 lines (+24/-0)
1 file modified
tarmac/plugins/commit.py (+24/-0)
To merge this branch: bzr merge lp:~james-w/tarmac/commit-message
Reviewer Review Type Date Requested Status
Jonathan Lange (community) Approve
Review via email: mp+140555@code.launchpad.net

This proposal supersedes a proposal from 2012-12-18.

Description of the change

Hi,

This adds the commit message plugin that CA used to set the [r=<reviewer>] and [bug=] things.

It might not be needed with the template plugin used by u1.

Thanks,

James

To post a comment you must log in.
Revision history for this message
Jonathan Lange (jml) wrote :

Personally, I like the commit messages this gives, and the way it means we could ditch the commit message template boilerplate out of our configs.

Have I mentioned recently how much I hate launchpadlib?

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'tarmac/plugins/commit.py'
2--- tarmac/plugins/commit.py 1970-01-01 00:00:00 +0000
3+++ tarmac/plugins/commit.py 2012-12-18 21:25:43 +0000
4@@ -0,0 +1,24 @@
5+import re
6+
7+from tarmac.hooks import tarmac_hooks
8+from tarmac.plugins import TarmacPlugin
9+
10+
11+class CommitMessage(TarmacPlugin):
12+
13+ def run(self, command, target, source, proposal):
14+ if not re.match(r'^\[.+?\].*$', proposal.commit_message):
15+ params = ["[r=%s]" % proposal.reviewer.name]
16+ for bug in proposal.source_branch.linked_bugs:
17+ params.append("[bug=%s]" % bug.id)
18+
19+ proposal.commit_message = ("%s " % ",".join(params) +
20+ proposal.commit_message)
21+ self.logger.debug("Setting commit_message to %s",
22+ proposal.commit_message)
23+ else:
24+ self.logger.debug("%s has already right commit message",
25+ proposal)
26+
27+tarmac_hooks['tarmac_pre_commit'].hook(CommitMessage(),
28+ 'Commit messsage template editor.')

Subscribers

People subscribed via source and target branches