post-receive-hudson: Default USER_EMAIL to the committer's email address.
authorStephen Haberman <stephen@exigencecorp.com>
Thu, 14 Apr 2011 23:41:57 +0000 (18:41 -0500)
committerStephen Haberman <stephen@exigencecorp.com>
Thu, 14 Apr 2011 23:45:11 +0000 (18:45 -0500)
Patch by Aaron Boxer.

server/post-receive-hudson

index 2e2ea07..45ce301 100755 (executable)
@@ -14,7 +14,8 @@
 #   Whitespace separated list of branches to not make jobs for.
 # USER_EMAIL
 #   Environment variable that should be set by your repository-specific
-#   post-receive hook. E.g. export USER_EMAIL=${USER}@example.com
+#   post-receive hook. E.g. export USER_EMAIL=${USER}@example.com. If
+#   unset, defaults to the email by of the pushed commit.
 #
 
 . $(dirname $0)/functions
@@ -39,6 +40,10 @@ while read oldrev newrev refname ; do
                exit 0
        fi
 
+       if [ -z "$USER_EMAIL" ] ; then
+               USER_EMAIL=$(git log -1 --pretty=format:'%ce' $newrev)
+       fi
+
        branch_config=$(wget -O - $hudson_url/job/${short_refname}/config.xml 2>/dev/null)
        if [ $? -ne 0 ] ; then
                # Create the job