File 1291-scripts-pre-push-Rename-color-functions.patch of Package erlang

From 52aab6413ad7eba2e2b8fefb6ca81ff8ca70065a Mon Sep 17 00:00:00 2001
From: Sverker Eriksson <sverker@erlang.org>
Date: Thu, 8 Jun 2023 12:04:42 +0200
Subject: [PATCH 1/2] scripts/pre-push: Rename color functions

---
 scripts/pre-push | 72 ++++++++++++++++++++++++------------------------
 1 file changed, 36 insertions(+), 36 deletions(-)

diff --git a/scripts/pre-push b/scripts/pre-push
index f5763646c8..a37e26d9ee 100755
--- a/scripts/pre-push
+++ b/scripts/pre-push
@@ -57,23 +57,23 @@ null=0000000000000000000000000000000000000000
 #echo "pre-push hook: remote=$remote"
 #echo "pre-push hook: url=$url"
 
-red_on() {
+error_color() {
     printf '%b' "\033[31m"
 }
 
-red_off() {
+reset_color() {
     printf '%b' "\033[0m"
 }
 
 if [ "$url" = 'https://github.com/erlang/otp.git' -o "$url" = 'git@github.com:erlang/otp.git' -o "$url" = 'git@github.com:erlang/otp' ]
 then
     if [ $remote = "$url" ]; then
-	red_on
+	error_color
         echo "$0 says:"
         echo "***"
         echo "*** Push to $url without using a named remote is NOT ALLOWED!!!!"
         echo "***"
-	red_off
+	reset_color
         exit 1
     fi
     IFS=' '
@@ -86,22 +86,22 @@ then
 
 	if [ "$local_sha" = $null ]
 	then
-	    red_on
+	    error_color
             echo "$0 says:"
             echo "***"
             echo "*** DELETE push to '$remote' NOT ALLOWED!!!!!"
             echo "***"
-	    red_off
+	    reset_color
             exit 1
 	fi
 	if [ "$local_ref" != "$remote_ref" ]
 	then
-	    red_on
+	    error_color
 	    echo "$0 says:"
 	    echo "***"
 	    echo "*** RENAME push: $local_ref pushed as $remote_ref to '$remote' NOT ALLOWED!!!!"
 	    echo "***"
-	    red_off
+	    reset_color
 	    exit 1
 	fi
 	case "$remote_ref" in
@@ -109,34 +109,34 @@ then
 		branch=${remote_ref#refs/heads/}
                 if [ "$remote_sha" = $null ]
                 then
-		    red_on
+		    error_color
                     echo "$0 says:"
 		    echo "***"
 		    echo "*** UNKNOWN BRANCH: '$branch' does not exist at '$remote'!!!!"
 		    echo "***"
-		    red_off
+		    reset_color
 		    exit 1
                 fi
 		if ! git log -1 --oneline $remote_sha > /dev/null 2>&1
 		then
-		    red_on
+		    error_color
 		    echo "$0 says:"
 		    echo "***"
 		    echo "*** The top of '$branch' at '$remote' ($remote_sha)"
 		    echo "*** does not exist locally!!!"
 		    echo "*** You probably need to refresh local '$branch' and redo merge."
 		    echo "***"
-		    red_off
+		    reset_color
 		    exit 1
 		fi
 		if ! git merge-base --is-ancestor $remote_sha $local_sha
 		then
-		    red_on
+		    error_color
 		    echo "$0 says:"
 		    echo "***"
 		    echo "*** FORCE push branch to '$remote' NOT ALLOWED!!!"
 		    echo "***"
-		    red_off
+		    reset_color
 		    exit 1
 		fi
                 if [ $remote_ref != refs/heads/master -a "$MASTER_ONLY" ] && git merge-base --is-ancestor $MASTER_ONLY $local_sha
@@ -145,16 +145,16 @@ then
 		    THIS_SCRIPT=`realpath $THIS_SCRIPT`
 		    if git show refs/remotes/$remote/master:scripts/pre-push | diff -q --context=0 $THIS_SCRIPT - > /dev/null 2>&1
 		    then
-			red_on
+			error_color
 			echo "$0 says:"
 			echo "***"
 			echo "*** INVALID MERGE: Commit $MASTER_ONLY should not be reachable from '$branch'!!!!"
 			echo "***                You have probably merged master into '$branch' by mistake"
 			echo "***"
-			red_off
+			reset_color
 			exit 1
 		    else
-			red_on
+			error_color
 			echo "$0 says:"
 			echo "***"
 			echo "*** The pre-push hook of this OTP repo needs updating."
@@ -164,19 +164,19 @@ then
 			echo "***"
 			echo "*** And then retry the push."
 			echo "***"
-			red_off
+			reset_color
 			exit 1
 		    fi
                 fi
                 if [ ${remote_ref#refs/heads/maint-} != $remote_ref ] && git merge-base --is-ancestor refs/remotes/$remote/maint $local_sha
                 then
-		    red_on
+		    error_color
 		    echo "$0 says:"
 		    echo "***"
 		    echo "*** INVALID MERGE: Branch maint should not be reachable from '$branch'!!!!"
                     echo "***                You have probably merged maint into '$branch' by mistake."
 		    echo "***"
-		    red_off
+		    reset_color
 		    exit 1
                 fi
                 if [ $remote_ref = refs/heads/maint -o $remote_ref = refs/heads/master ]; then
@@ -192,35 +192,35 @@ then
                 fi
                 if [ $remote_ref = refs/heads/master ] && ! git merge-base --is-ancestor refs/remotes/$remote/maint $local_sha
                 then
-		    red_on
+		    error_color
                     echo "$0 says:"
 		    echo "***"
 		    echo "*** INVALID PUSH: Branch '$remote/maint' is not reachable from master!!!!"
                     echo "***               Someone needs to merge maint forward to master and push."
 		    echo "***"
-		    red_off
+		    reset_color
 		    exit 1
                 fi
 		NCOMMITS=`git rev-list --count $remote_sha..$local_sha`
 		if [ $NCOMMITS -gt $NCOMMITS_MAX ]
 		then
-		    red_on
+		    error_color
 		    echo "$0 says:"
 		    echo "***"
 		    echo "*** HUGE push: $NCOMMITS commits (> $NCOMMITS_MAX) to '$branch' at '$remote' NOT ALLOWED!!!!"
 		    echo "***"
-		    red_off
+		    reset_color
 		    exit 1
 		fi
 		NFILES=`git diff --name-only $remote_sha $local_sha | wc -l`
 		if [ $NFILES -gt $NFILES_MAX ]
 		then
-		    red_on
+		    error_color
 		    echo "$0 says:"
 		    echo "***"
 		    echo "*** HUGE push: $NFILES changed files (> $NFILES_MAX) to '$branch' at '$remote' NOT ALLOWED!!!!"
 		    echo "***"
-		    red_off
+		    reset_color
 		    exit 1
 		fi
 		;;
@@ -236,53 +236,53 @@ then
 		done
 		if [ $REL = "UNKNOWN" ]
 		then
-		    red_on
+		    error_color
 		    echo "$0 says:"
 		    echo "***"
 		    echo "*** Unknown OTP release number in tag '$tag'"
 		    echo "***"
-		    red_off
+		    reset_color
 		    exit 1
 		fi
 		if [ "$remote_sha" != $null ]
 		then
-		    red_on
+		    error_color
 		    echo "$0 says:"
 		    echo "***"
 		    echo "*** FORCE push tag to '$remote' NOT ALLOWED!!!"
 		    echo "*** Tag '$tag' already exists at '$remote'."
 		    echo "***"
-		    red_off
+		    reset_color
 		    exit 1
 		fi
 		;;
             refs/heads/*)
 		branch=${remote_ref#refs/heads/}
-		red_on
+		error_color
 		echo "$0 says:"
 		echo "***"
 		echo "*** UNKNOWN branch name: '$branch' pushed to '$remote' NOT ALLOWED!!!!"
 		echo "***"
-		red_off
+		reset_color
 		exit 1
 		;;
 	    refs/tags/*)
 		tag=${remote_ref#refs/tags/}
-		red_on
+		error_color
 		echo "$0 says:"
 		echo "***"
 		echo "*** UNKNOWN tag name: '$tag' pushed to '$remote' NOT ALLOWED!!!!"
 		echo "***"
-		red_off
+		reset_color
 		exit 1
 		;;
 	    *)
-		red_on
+		error_color
 		echo "$0 says:"
 		echo "***"
 		echo "*** STRANGE ref: '$remote_ref' pushed to '$remote' NOT ALLOWED!!!!"
 		echo "***"
-		red_off
+		reset_color
 		exit 1
 		;;
 	esac
-- 
2.35.3

openSUSE Build Service is sponsored by