{"id":94,"date":"2011-01-13T19:06:00","date_gmt":"2011-01-13T19:06:00","guid":{"rendered":"https:\/\/www.root42.de\/blog\/?p=94"},"modified":"2011-01-13T19:06:00","modified_gmt":"2011-01-13T19:06:00","slug":"setting-the-sender-of-git-post-receive-hooks","status":"publish","type":"post","link":"https:\/\/www.root42.de\/blog\/?p=94","title":{"rendered":"Setting the sender of git post-receive hooks"},"content":{"rendered":"<div>There is a nice <a href=\"http:\/\/stackoverflow.com\/questions\/2443908\/how-do-i-make-git-post-receive-emails-be-sent-from-the-commit-author\">stackoverflow posting<\/a> about how to set the sender of git post-receive hooks. I used this, slightly augmented:<\/div>\n<p><\/p>\n<pre>#!\/bin\/sh<br \/><br \/># Use the name and email address of the author of the last commit.<br \/>USER_EMAIL=$(git log -1 --format=format:%ae HEAD)<br \/>USER_NAME=$(git log -1 --format=format:%an HEAD)<br \/>. $(dirname $0)\/post-receive-email<br \/><\/pre>\n<p>I then also changed the default post-receive-email script, to look like this in the send_mail() function:<\/p>\n<pre>send_mail()<br \/>{<br \/>  if [ -n \"$envelopesender\" ]; then<br \/>    \/usr\/sbin\/sendmail -t -f \"$envelopesender\"<br \/>  else<br \/>    \/usr\/sbin\/sendmail -t -F \"$USER_NAME\" -f \"$USER_EMAIL\"<br \/>  fi<br \/>}<br \/><\/pre>\n<div>This will let the emails come from the last user in the git log. This is only a hack, and might break or not make sense under certain circumstances, but is good enough for most of my needs.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>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 &#8211;format=format:%ae HEAD)USER_NAME=$(git log -1 &#8211;format=format:%an HEAD). $(dirname $0)\/post-receive-email I then also changed the default post-receive-email script, to look &hellip; <a href=\"https:\/\/www.root42.de\/blog\/?p=94\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Setting the sender of git post-receive hooks&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7,49,10],"tags":[],"_links":{"self":[{"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/94"}],"collection":[{"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=94"}],"version-history":[{"count":0,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/94\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=94"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=94"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=94"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}