[sysadmin-bin: 64/168] Allow adminstrators to git push --exec=force certain things



commit ce93ce012f23540bbfc257f08874454ec807e6b0
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Thu Mar 19 20:04:58 2009 -0400

    Allow adminstrators to git push --exec=force certain things
    
    If a user is in the gitadmin or sysadmin groups, they can
    
     git push --exec=force
    
    To:
    
     - Make non-fast-forward-updates
     - Delete tags
     - Update tags

 pre-receive-check-policy |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/pre-receive-check-policy b/pre-receive-check-policy
index a7972c9..7a2c43a 100755
--- a/pre-receive-check-policy
+++ b/pre-receive-check-policy
@@ -18,6 +18,10 @@ in_import() {
     test -e "$GIT_DIR/pending"
 }
 
+forced() {
+    test -n "$GNOME_GIT_FORCE"
+}
+
 check_ref_update() {
     oldrev=$1
     newrev=$2
@@ -59,7 +63,7 @@ EOF
 		    fi
 		    ;;
 		update)
-		    if [ `git merge-base $oldrev $newrev` != $oldrev ] ; then
+		    if [ `git merge-base $oldrev $newrev` != $oldrev ] && ! forced ; then
 		        # Non-fast-forward update. Right now we have
 		        # receive.denyNonFastforwards in the git configs for
 		        # our repositories anyways, but catching it here would
@@ -89,7 +93,7 @@ EOF
 			commit)
 			    # Lightweight tag; we allow an import containing these
 			    # tags, but forbid them in general
-			    if ! in_import ; then
+			    if ! in_import && ! forced ; then
 				cat <<EOF >&2
 ---
 You are trying to push the lightweight tag '$tagname'. You should use
@@ -122,7 +126,7 @@ EOF
 		    # tags will cut down on accidentally pushing tags called 'list'
 		    # or whatever. During import we allow the user to clean up
 		    # accidentally pushed tags.
-		    if ! in_import ; then
+		    if ! in_import && ! forced ; then
 			cat <<EOF >&2
 ---
 You are trying to delete the tag '$tagname'.
@@ -134,14 +138,16 @@ EOF
 		    fi
 		    ;;
 		update)
-		    cat <<EOF >&2
+		    if  ! forced ; then
+			cat <<EOF >&2
 ---
 You are trying to replace the tag '$tagname' with a new tag. Please see:
 
   http://live.gnome.org/Git/Help/TagUpdates
 ---
 EOF
-		    return 1
+			return 1
+		    fi
 		    ;;
 	    esac
 	    ;;



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