views:

267

answers:

2

I'm using the post-receive-email script included with git. (Source is here.) It works just fine, but I want each email to be sent from the author of the commits pushed. How do I do it?

My post-receive file currently looks like this, and I want to customize the from-email-address.

#!/bin/sh

export [email protected]
$(dirname $0)/post-receive-email
+1  A: 

You can try another hook system like http://github.com/jtek/git-hook-update-notify-email

shingara
A: 

Use git log to pull out the email address.

For example, in post-receive:

#!/bin/sh

# Use the email address of the author of the last commit.
export USER_EMAIL=$(git log -1 --format=format:%ae HEAD)
$(dirname $0)/post-receive-email

You could also map the email addresses, if for example, people are using their gmail or personal domain addresses, but you would like to map them to a single domain.

#!/bin/sh

# Use the mapped email address (specified in .mailmap) of the author of the last commit.
export USER_EMAIL=$(git log -1 --format=format:%aE HEAD)
$(dirname $0)/post-receive-email

You can read more about .mailmap here.

Jonathan Tran