Le 27/07/2010 14:12, Dave Page a écrit :
> On Tue, Jul 27, 2010 at 1:10 PM, Guillaume Lelarge
> <guilla...@lelarge.info> wrote:
>> Le 27/07/2010 13:08, Dave Page a écrit :
>>> On Tue, Jul 27, 2010 at 11:16 AM, Guillaume Lelarge
>>> <guilla...@lelarge.info> wrote:
>>>> Le 27/07/2010 11:37, Dave Page a écrit :
>>>>> On Tue, Jul 27, 2010 at 10:30 AM, Guillaume Lelarge
>>>>> <guilla...@lelarge.info> wrote:
>>>>>
>>>>>> Did you fix the script? do you need help? I can probably take some time
>>>>>> to look at it.
>>>>>
>>>>> Not yet. Feel free. It's in commitmsg.py iirc:
>>>>>
>>>>> http://github.com/mhagander/pg_githooks
>>>>>
>>>>
>>>> Well, I could be completely wrong but I think you just need to change
>>>> one parameter in hook/policyenforce.ini: committerequalsauthor must be
>>>> equal to 0. If you do this, the hook won't try to match commiter's and
>>>> author's name, but it will still enforce commiters. Which is what we
>>>> want, right?
>>>
>>> That isn't the problem (and committerequalsauthor is already zero).
>>> The problem is that the commitmsg script sends the email "from" the
>>> author, not the committer.
>>>
>>
>> Oh OK. I thought I still couldn't use the --author CLI option. Now, I
>> understand the issue. I'll try to work on this today.
> 
> Well you shouldn't, as it will send email in someone else's name until
> this is fixed.
> 

Here is a patch to fix this. Can you try it? Thanks.


-- 
Guillaume
 http://www.postgresql.fr
 http://dalibo.com
>From 06b043b230be7452482fcd32d9d9fd21b19af028 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 |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/commitmsg.py b/commitmsg.py
index e9036d9..5c53c62 100755
--- a/commitmsg.py
+++ b/commitmsg.py
@@ -107,6 +107,7 @@ def parse_commit_log(lines):
 	
 	# Reset our parsing data
 	commitinfo = ""
+	commiterinfo = ""
 	authorinfo = ""
 	dateinfo = ""
 	mergeinfo = ""
@@ -116,6 +117,8 @@ def parse_commit_log(lines):
 			break
 		elif l.startswith("commit "):
 			commitinfo = l
+		elif l.startswith("Commit: "):
+			commiterinfo = l
 		elif l.startswith("Author: "):
 			authorinfo = l
 		elif l.startswith("Date:   "):
@@ -125,12 +128,14 @@ def parse_commit_log(lines):
 		else:
 			raise Exception("Unknown header line: %s" % l)
 
-	if not (commitinfo or authorinfo or dateinfo):
+	if not (commitinfo or commiterinfo or authorinfo or dateinfo):
 		# 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 commiterinfo:
+		raise Exception("Could not find commiter!")
 	if not authorinfo:
 		raise Exception("Could not find author!")
 	if not dateinfo:
@@ -174,6 +179,11 @@ def parse_commit_log(lines):
 	mail.append("-----------")
 	mail.extend(commitmsg)
 	mail.append("")
+	if authorinfo != committerinfo:
+	    mail.append("Author")
+	    mail.append("------")
+	    mail.extend(authorinfo)
+	    mail.append("")
 	if len(branches) > 1:
 		mail.append("Branches")
 		mail.append("--------")
@@ -189,7 +199,7 @@ def parse_commit_log(lines):
 	mail.append("")
 
 	msg = create_message("\n".join(mail),
-						 authorinfo[7:],
+						 commiterinfo[7:],
 						 c.get('commitmsg','subject').replace("$shortmsg",
 															  commitmsg[0][:80-len(c.get('commitmsg','subject'))]))
 	sendmail(msg)
@@ -292,7 +302,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=full" % (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