Skip to content
Browse files

Properly support sending email from the commiter instead of the author.

When author and committer differ, we'll put a note in the message body
instead.
  • Loading branch information...
1 parent 7e6a7ee commit 121f24eb169c92b7679c45e1e2b5052d8548c5a4 @mhagander committed Aug 19, 2010
Showing with 10 additions and 8 deletions.
  1. +10 −8 commitmsg.py
View
18 commitmsg.py
@@ -108,7 +108,7 @@ def parse_commit_log(lines):
# Reset our parsing data
commitinfo = ""
authorinfo = ""
- dateinfo = ""
+ committerinfo = ""
mergeinfo = ""
while True:
l = lines.pop().strip()
@@ -118,23 +118,23 @@ def parse_commit_log(lines):
commitinfo = l
elif l.startswith("Author: "):
authorinfo = l
- elif l.startswith("Date: "):
- dateinfo = l
+ elif l.startswith("Commit: "):
+ committerinfo = l
elif l.startswith("Merge: "):
mergeinfo = l
else:
raise Exception("Unknown header line: %s" % l)
- if not (commitinfo or authorinfo or dateinfo):
+ if not (commitinfo or authorinfo):
# If none of these existed, we must've hit the end of the log
return False
# Check for any individual piece that is missing
if not commitinfo:
raise Exception("Could not find commit hash!")
if not authorinfo:
raise Exception("Could not find author!")
- if not dateinfo:
- raise Exception("Could not find commit date!")
+ if not committerinfo:
+ raise Exception("Could not find committer!")
commitmsg = []
# We are in the commit message until we hit one line that doesn't start
@@ -169,6 +169,8 @@ def parse_commit_log(lines):
mail.append("")
mail.append("Commit: %s" % (
c.get('commitmsg', 'gitweb').replace('$action','commitdiff').replace('$commit', commitinfo[7:])))
+ if committerinfo[7:] != authorinfo[7:]:
+ mail.append(authorinfo) # already includes Author: part
mail.append("")
mail.append("Log Message")
mail.append("-----------")
@@ -189,7 +191,7 @@ def parse_commit_log(lines):
mail.append("")
msg = create_message("\n".join(mail),
- authorinfo[7:],
+ committerinfo[7:],
c.get('commitmsg','subject').replace("$shortmsg",
commitmsg[0][:80-len(c.get('commitmsg','subject'))]))
sendmail(msg)
@@ -292,7 +294,7 @@ def parse_annotated_tag(lines):
"Branch %s was removed" % ref)))
else:
# If both are real object ids, we can call git log on them
- cmd = "git log %s..%s --stat" % (oldobj, newobj)
+ cmd = "git log %s..%s --stat --format=full" % (oldobj, newobj)
p = Popen(cmd, shell=True, stdout=PIPE)
lines = p.stdout.readlines()
lines.reverse()

0 comments on commit 121f24e

Please sign in to comment.
Something went wrong with that request. Please try again.