2011-01-13

Setting the sender of git post-receive hooks

There is a nice stackoverflow posting about how to set the sender of git post-receive hooks. I used this, slightly augmented:

#!/bin/sh
# Use the name and email address of the author of the last commit.
USER_EMAIL=$(git log -1 --format=format:%ae HEAD)
USER_NAME=$(git log -1 --format=format:%an HEAD)
. $(dirname $0)/post-receive-email

I then also changed the default post-receive-email script, to look like this in the send_mail() function: