Merge lp:~andrea.corbellini/tarmac/save-commit-author into lp:tarmac

Proposed by Andrea Corbellini
Status: Rejected
Rejected by: Paul Hummer
Proposed branch: lp:~andrea.corbellini/tarmac/save-commit-author
Merge into: lp:tarmac
Diff against target: None lines
To merge this branch: bzr merge lp:~andrea.corbellini/tarmac/save-commit-author
Reviewer Review Type Date Requested Status
Paul Hummer Disapprove
Review via email: mp+7105@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Andrea Corbellini (andrea.corbellini) wrote :

This branch allows Tarmac to pick up the author of the candidate branch and save it in the commit.

Revision history for this message
dobey (dobey) wrote :

This picks up the owner and their preferred e-mail, which may not be the e-mail they committed with, nor want to use for the commit. I think what we really want to do is pull the committer name/e-mail from the last commit in the pending merge before committing it to trunk.

Revision history for this message
Paul Hummer (rockstar) wrote :

Andrea-

  I really appreciate your effort in this, and for participating in Tarmac development. There are a number of flaws in this implementation. For instance, what if the user has elected to hide his email address from everyone. What if the user is committing code under a different user name (I do this a lot, since I have Canonical projects and non-Canonical projects).

  I'm quite happy to sit down with you and talk about an implementation that would work, and happy to help you along with it. I really appreciate your help in making Tarmac better.

review: Disapprove
Revision history for this message
Andrea Corbellini (andrea.corbellini) wrote :

No problem! :-)
I haven't much time in this period so I can't work on a different
implementation, for now. Thanks for the review.

Unmerged revisions

106. By Andrea Corbellini

Save the author of the branch in the commit message.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tarmac/bin.py'
2--- tarmac/bin.py 2009-05-28 18:40:35 +0000
3+++ tarmac/bin.py 2009-06-05 14:52:58 +0000
4@@ -99,6 +99,17 @@
5 return [comment.reviewer for comment in candidate.all_comments
6 if comment.vote == u'Approve'].join(', ')
7
8+ def _get_author(self, source_branch):
9+ '''Get the author of the branch and return a string in the form
10+ "Display Name <email@address>"
11+ '''
12+ owner = source_branch.owner
13+ if owner.hide_email_addresses:
14+ return str(owner.display_name)
15+ else:
16+ return '%s <%s>' % (
17+ owner.display_name, owner.preferred_email_address.email)
18+
19 def main(self):
20 '''See `TarmacScript.main`.'''
21
22@@ -152,6 +163,7 @@
23 'commit_message': commit_message}
24
25 source_branch = Branch(candidate.source_branch)
26+ commit_author = self._get_author(source_branch)
27
28 try:
29 trunk.merge(source_branch)
30@@ -168,10 +180,9 @@
31 trunk.cleanup()
32 else:
33 print 'Committing...'
34- trunk.commit(commit_message)
35+ trunk.commit(commit_message, commit_author)
36 except Exception, e:
37 print e
38 trunk.cleanup()
39
40 tarmac_hooks['post_tarmac_commit'].fire()
41-
42
43=== modified file 'tarmac/branch.py'
44--- tarmac/branch.py 2009-05-28 18:40:35 +0000
45+++ tarmac/branch.py 2009-06-05 14:52:58 +0000
46@@ -40,13 +40,16 @@
47 if self.has_tree:
48 self._set_up_working_tree()
49
50- def commit(self, commit_message):
51+ def commit(self, commit_message, commit_author):
52 '''Commit changes.'''
53 if not self.has_tree:
54 raise Exception('This branch has no working tree.')
55- self.tree.commit(commit_message)
56+ self.tree.commit(commit_message, authors=[commit_author])
57
58 @property
59 def landing_candidates(self):
60 return self.lp_branch.landing_candidates
61
62+ @property
63+ def owner(self):
64+ return self.lp_branch.owner

Subscribers

People subscribed via source and target branches