[X2Go-Commits] [maintenancescripts] 02/04: git/hooks/update-script._check_: use guard to be able to include file multiple times and executing it only once.

git-admin at x2go.org git-admin at x2go.org
Tue Feb 24 00:03:21 CET 2015


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository maintenancescripts.

commit 1f359e93fefc9efe9f1be0f2096f72f99e07db1a
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Mon Feb 23 23:29:23 2015 +0100

    git/hooks/update-script._check_: use guard to be able to include file multiple times and executing it only once.
---
 git/hooks/update-script._check_ |  104 +++++++++++++++++++++------------------
 1 file changed, 55 insertions(+), 49 deletions(-)

diff --git a/git/hooks/update-script._check_ b/git/hooks/update-script._check_
index e485c6a..17ad7f8 100755
--- a/git/hooks/update-script._check_
+++ b/git/hooks/update-script._check_
@@ -2,57 +2,63 @@
 
 . hooks/common.sh
 
-MERGE="0"
-[ "$(basename "${0}")" = "update-script_check+allow-merges_" ] && MERGE="1"
+if [ -z "${UPDATE_DONE}" ]; then
+  UPDATE_DONE="1"
 
-case "$1" in
-  (refs/tags/*)
-    [ -f "$GIT_DIR/$1" ] && deny >/dev/null "You can't overwrite an existing tag"
-    ;;
-  (refs/heads/*)
-    BRANCH="${1#refs/heads/}"
+  MERGE="0"
+  [ "$(basename "${0}")" = "update-script_check+allow-merges_" ] && MERGE="1"
 
-    # No rebasing or rewinding on release, build or master branches.
-    if expr "$2" : '0*$' >/dev/null; then
-      case "${BRANCH}" in
-        (release/*|build-*|master|feature/*|bugfix/*) info "The branch '$1' is new..." ;;
-        (*) deny >/dev/null "ERROR: Branch name does not meet the project policies. Please contact git-admin at x2go.org." ;;
-      esac
-    else
-      case "${BRANCH}" in
-        (release/*|build-*|master)
-          # updating -- check for merge commit and deny or warn
-          [ -n "$(git rev-list --merges $2..$3)" ] && {
-            if [ "${MERGE}" = "0" ]; then
-              deny > /dev/null "ERROR: update contains a merge."
-            else
-              echowarn "WARNING: update contains a merge. Allowing merges by special policies for this project."
-            fi
-          }
+  case "$1" in
+    (refs/tags/*)
+      [ -f "$GIT_DIR/$1" ] && deny >/dev/null "You can't overwrite an existing tag"
+      ;;
+    (refs/heads/*)
+      BRANCH="${1#refs/heads/}"
 
-          # updating -- make sure it is a fast forward
-          mb=$(git merge-base "$2" "$3")
-          case "$mb,$2" in
-            ("$2,$mb") info "Update is fast-forward" ;;
-            (*)        deny > /dev/null "ERROR: This is not a fast-forward update. History has been rewritten." ;;
-          esac
-          ;;
-        (feature/*|bugfix/*) info "Not checking for non-fast-forwards or merges on ${BRANCH}." ;;
-        (*) deny >/dev/null "ERROR: Branch name does not meet the project policies. Please contact git-admin at x2go.org." ;;
-      esac
-    fi
-    for REVISION in $(git rev-list --reverse "$2..$3") ; do
-      # Make sure that the log message contains some text.
-      check_log_message
+      # No rebasing or rewinding on release, build or master branches.
+      if expr "$2" : '0*$' >/dev/null; then
+        case "${BRANCH}" in
+          (release/*|build-*|master|feature/*|bugfix/*) info "The branch '$1' is new..." ;;
+          (*) deny >/dev/null "ERROR: Branch name does not meet the project policies. Please contact git-admin at x2go.org." ;;
+        esac
+      else
+        case "${BRANCH}" in
+          (release/*|build-*|master)
+            # updating -- check for merge commit and deny or warn
+            [ -n "$(git rev-list --merges $2..$3)" ] && {
+              if [ "${MERGE}" = "0" ]; then
+                deny > /dev/null "ERROR: update contains a merge."
+              else
+                echowarn "WARNING: update contains a merge. Allowing merges by special policies for this project."
+              fi
+            }
 
-      # Enforce some style guidelines on commits: Trailing whitespace, tabs (outside
-      # of Makefiles) and DOS line endings are forbidden, all files must end in
-      # newlines.
-      check_trailing_whitespace ""
-      check_tabs ""
-      check_dos_linebreaks ""
-      check_ending_newline ""
-    done
-    ;;
-esac
+            # updating -- make sure it is a fast forward
+            mb="$(git merge-base "$2" "$3")"
+            case "$mb,$2" in
+              ("$2,$mb") info "Update is fast-forward" ;;
+              (*)        deny > /dev/null "ERROR: This is not a fast-forward update. History has been rewritten." ;;
+            esac
+            ;;
+          (feature/*|bugfix/*) info "Not checking for non-fast-forwards or merges on ${BRANCH}." ;;
+          (*) deny >/dev/null "ERROR: Branch name does not meet the project policies. Please contact git-admin at x2go.org." ;;
+        esac
+      fi
+      for REVISION in $(git rev-list --reverse "$2..$3") ; do
+        # Make sure that the log message contains some text.
+        check_log_message
 
+        # Enforce some style guidelines on commits: Trailing whitespace, tabs (outside
+        # of Makefiles) and DOS line endings are forbidden, all files must end in
+        # newlines.
+        check_trailing_whitespace ""
+        check_tabs ""
+        check_dos_linebreaks ""
+        check_ending_newline ""
+      done
+      ;;
+    (*)
+      deny >/dev/null "Branch is not under refs/heads or refs/tags.  What are you trying to do?"
+      ;;
+  esac
+fi

--
Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/maintenancescripts.git


More information about the x2go-commits mailing list