[tor-commits] [tor/master] scripts/git: Make spaces consistent in pre-push.git-hook

teor at torproject.org teor at torproject.org
Fri Oct 25 06:15:24 UTC 2019


commit 1094389d8215ce5398a4cd145560bb2686cbf0f5
Author: teor <teor at torproject.org>
Date:   Thu Oct 24 14:03:48 2019 +1000

    scripts/git: Make spaces consistent in pre-push.git-hook
    
    Part of 31919.
---
 scripts/git/pre-push.git-hook | 94 ++++++++++++++++++++-----------------------
 1 file changed, 43 insertions(+), 51 deletions(-)

diff --git a/scripts/git/pre-push.git-hook b/scripts/git/pre-push.git-hook
index 1b88f1d5d..2f3608029 100755
--- a/scripts/git/pre-push.git-hook
+++ b/scripts/git/pre-push.git-hook
@@ -33,30 +33,27 @@ remote_name=$(git remote --verbose | grep "$2" | awk '{print $1}' | head -n 1)
 
 
 ref_is_upstream_branch() {
-        if [ "$1" == "refs/heads/master" ] ||
-                [[ "$1" == refs/heads/release-* ]] ||
-                [[ "$1" == refs/heads/maint-* ]]
-        then
-                return 1
-        fi
+    if [ "$1" == "refs/heads/master" ] ||
+        [[ "$1" == refs/heads/release-* ]] ||
+        [[ "$1" == refs/heads/maint-* ]]; then
+        return 1
+    fi
 }
 
 # shellcheck disable=SC2034
 while read -r local_ref local_sha remote_ref remote_sha
 do
-	if [ "$local_sha" = $z40 ]
-	then
-		# Handle delete
-		:
-	else
-		if [ "$remote_sha" = $z40 ]
-		then
-			# New branch, examine commits not in master
-			range="master...$local_sha"
-		else
-			# Update to existing branch, examine new commits
-			range="$remote_sha..$local_sha"
-		fi
+    if [ "$local_sha" = $z40 ]; then
+        # Handle delete
+        :
+    else
+        if [ "$remote_sha" = $z40 ]; then
+            # New branch, examine commits not in master
+            range="master...$local_sha"
+        else
+            # Update to existing branch, examine new commits
+            range="$remote_sha..$local_sha"
+        fi
 
         # Call the pre-commit hook for the common checks, if it is executable
         # Only check the files newly modified in this branch
@@ -95,39 +92,34 @@ do
             continue
         fi
 
+        if (ref_is_upstream_branch "$local_ref" == 0 ||
+                ref_is_upstream_branch "$remote_ref"  == 0) &&
+            [ "$local_ref" != "$remote_ref" ]; then
+            if [ "$remote" == "origin" ]; then
+                echo >&2 "Not pushing: $local_ref to $remote_ref"
+                echo >&2 "If you really want to push this, use --no-verify."
+                exit 1
+            else
+                continue
+            fi
+        fi
+
+        # Check for fixup! commit
+        commit=$(git rev-list -n 1 --grep '^fixup!' "$range")
+        if [ -n "$commit" ]; then
+            echo >&2 "Found fixup! commit in $local_ref, not pushing"
+            echo >&2 "If you really want to push this, use --no-verify."
+            exit 1
+        fi
 
-                if (ref_is_upstream_branch "$local_ref" == 0 ||
-                        ref_is_upstream_branch "$remote_ref"  == 0) &&
-                        [ "$local_ref" != "$remote_ref" ]
-                then
-                        if [ "$remote" == "origin" ]
-                        then
-                                echo >&2 "Not pushing: $local_ref to $remote_ref"
-			        echo >&2 "If you really want to push this, use --no-verify."
-                                exit 1
-                        else
-                                continue
-                        fi
-                fi
-
-                # Check for fixup! commit
-                commit=$(git rev-list -n 1 --grep '^fixup!' "$range")
-		if [ -n "$commit" ]
-		then
-			echo >&2 "Found fixup! commit in $local_ref, not pushing"
-			echo >&2 "If you really want to push this, use --no-verify."
-			exit 1
-		fi
-
-                # Check for squash! commit
-                commit=$(git rev-list -n 1 --grep '^squash!' "$range")
-		if [ -n "$commit" ]
-		then
-			echo >&2 "Found squash! commit in $local_ref, not pushing"
-			echo >&2 "If you really want to push this, use --no-verify."
-			exit 1
-		fi
-	fi
+        # Check for squash! commit
+        commit=$(git rev-list -n 1 --grep '^squash!' "$range")
+        if [ -n "$commit" ]; then
+            echo >&2 "Found squash! commit in $local_ref, not pushing"
+            echo >&2 "If you really want to push this, use --no-verify."
+            exit 1
+        fi
+    fi
 done
 
 exit 0





More information about the tor-commits mailing list