Le 28/07/2010 14:50, Guillaume Lelarge a écrit :
> Le 28/07/2010 13:26, Dave Page a écrit :
>> On Tue, Jul 27, 2010 at 5:36 PM, Guillaume Lelarge
>> <guilla...@lelarge.info> wrote:
>>
>>> Here is a patch to fix this. Can you try it? Thanks.
>>
>> Looks OK (except for the spelling of committerinfo). But it didn't
>> work when I tried it (no email was produced), and I can't seem to get
>> it to show me any debug info. So it got reverted again for now.
>>
> 
> What kind of error do you get?
> 

Worked a bit on it, and here is a new patch (checked with the debug
config). The issue with the previous patch was that full format doesn't
include the date of the commit. So, we need to use the format "fuller".
Anyway, hope this one will have better results.


-- 
Guillaume
 http://www.postgresql.fr
 http://dalibo.com
>From 7cda241ddd754235f67b891d1e56b6d1bd4f2b40 Mon Sep 17 00:00:00 2001
From: Guillaume Lelarge <guilla...@lelarge.info>
Date: Tue, 27 Jul 2010 18:33:50 +0200
Subject: [PATCH] FROM mail address is the commiter's one.

The author's name and email address are in the mail's body if they differ from
commiter's.
---
 commitmsg.py |   31 ++++++++++++++++++++++---------
 1 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/commitmsg.py b/commitmsg.py
index e9036d9..2c2cea0 100755
--- a/commitmsg.py
+++ b/commitmsg.py
@@ -107,8 +107,10 @@ def parse_commit_log(lines):
 	
 	# Reset our parsing data
 	commitinfo = ""
+	committerinfo = ""
 	authorinfo = ""
-	dateinfo = ""
+	commitdateinfo = ""
+	authordateinfo = ""
 	mergeinfo = ""
 	while True:
 		l = lines.pop().strip()
@@ -116,24 +118,30 @@ def parse_commit_log(lines):
 			break
 		elif l.startswith("commit "):
 			commitinfo = l
-		elif l.startswith("Author: "):
+		elif l.startswith("Commit:     "):
+			committerinfo = l
+		elif l.startswith("CommitDate: "):
+			commitdateinfo = l
+		elif l.startswith("Author:     "):
 			authorinfo = l
-		elif l.startswith("Date:   "):
-			dateinfo = l
-		elif l.startswith("Merge: "):
+		elif l.startswith("AuthorDate: "):
+			authordateinfo = 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 committerinfo or authorinfo or commitdateinfo):
 		# 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 committerinfo:
+		raise Exception("Could not find committer!")
 	if not authorinfo:
 		raise Exception("Could not find author!")
-	if not dateinfo:
+	if not commitdateinfo:
 		raise Exception("Could not find commit date!")
 	
 	commitmsg = []
@@ -174,6 +182,11 @@ def parse_commit_log(lines):
 	mail.append("-----------")
 	mail.extend(commitmsg)
 	mail.append("")
+	if authorinfo[7:].strip() != committerinfo[7:].strip():
+	    mail.append("Author")
+	    mail.append("------")
+	    mail.append(authorinfo[7:].strip())
+	    mail.append("")
 	if len(branches) > 1:
 		mail.append("Branches")
 		mail.append("--------")
@@ -189,7 +202,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 +305,7 @@ if __name__ == "__main__":
 																	"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=fuller" % (oldobj, newobj)
 			p = Popen(cmd, shell=True, stdout=PIPE)
 			lines = p.stdout.readlines()
 			lines.reverse()
-- 
1.7.0.4

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

Reply via email to