[sysadmin-bin] Take log-push bash, it was erroneously substituted by an empty file.



commit 5a53ef1329e44cd417919997cea3ce8ca2574422
Author: Andrea Veri <av gnome org>
Date:   Wed Jun 26 12:24:54 2013 +0200

    Take log-push bash, it was erroneously substituted by an empty file.

 git/log-push |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)
---
diff --git a/git/log-push b/git/log-push
index e69de29..5a539bb 100755
--- a/git/log-push
+++ b/git/log-push
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+# Log who pushed a ref to a repository and when. The input is expected to be the
+# same as for a git post-receive hook - a series of one line for each pushed ref
+#
+#  old_revision_hash new_revision_hash refname
+
+# Set GIT_DIR either from the working directory, or from the environment variable.
+GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
+if [ -z "$GIT_DIR" ]; then
+     echo >&2 "fatal: post-receive: GIT_DIR not set"
+     exit 1
+fi
+
+LOG_FILE="$GIT_DIR/gnome_pushlog"
+
+user=$(whoami)
+# RFC 822 date with a fixed UTC timezone (Thu, 05 Feb 2009 19:25:44 +0000)
+date=$(TZ=UTC date -R)
+
+# We use a log file since the '>>' append is not guaranteed to be atomic, though
+# it almost certainly is in practice.
+LOCK_FILE=$LOG_FILE.lock
+
+count=0
+while ! ln -s $$ $LOCK_FILE > /dev/null 2>&1 ; do
+    if [ $count = 0 ] ; then
+       echo "Waiting for lock file '$LOCK_FILE'" 1>&2
+    fi
+    if [ $count = 30 ] ; then
+       echo "Timed out" 1>&2
+       exit 1
+    fi
+    sleep 1
+    count=$((count+1))
+done
+
+# successfuly created lock file
+trap "rm -f $LOCK_FILE; exit" INT TERM EXIT
+
+umask 0002
+
+while read oldrev newrev refname
+do
+       echo "$oldrev   $newrev $refname        $user   $date" >> $LOG_FILE
+done


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]