git » repo-mgmt.git » commit b3d5271

push-gits: perf improvement and notify of uncommitted changes

author Urja (ARMLFS builder)
2024-07-15 06:00:32 UTC
committer Urja (ARMLFS builder)
2024-07-15 06:00:32 UTC
parent 6ee3917758f5876f7496112a4c58781b463f2721

push-gits: perf improvement and notify of uncommitted changes

gits-push.sh +0 -33
push-gits.sh +45 -0

diff --git a/gits-push.sh b/gits-push.sh
deleted file mode 100755
index e89cac8..0000000
--- a/gits-push.sh
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/sh
-asowner() {
-	set -e
-	if [[ -O . ]]; then
-		$1
-	else
-		su builder -c "$1"
-	fi
-	set +e
-}
-
-doagit() {
-	local g=$(basename ${2::-5})
-	echo /$3/$g
-	cd /$3/$g
-	local CMD="git push origin"
-	asowner "$CMD"
-}
-
-doatree() {
-	cd /$1
-	local GITS=$(find -mindepth 2 -maxdepth 2 -name '.git' -type d)
-
-	for g in $GITS; do
-		doagit $2 $g $1 "$3"
-	done
-}
-
-doatree sources sources
-for repo in core base kde5; do
-	doatree sources/$repo-pkgbuilds $repo-pkgbuilds
-done
-
diff --git a/push-gits.sh b/push-gits.sh
new file mode 100755
index 0000000..e4d6f84
--- /dev/null
+++ b/push-gits.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+asowner() {
+	if [[ -O . ]]; then
+		$1
+		R=$?
+	else
+		su builder -c "$1"
+		R=$?
+	fi
+	return $R
+}
+
+doagit() {
+	local g=$(basename ${2::-5})
+	cd /$3/$g
+	PLACE=$(echo /$3/$g)
+	STAT1="$(asowner "git status --branch --porcelain")"
+	if echo $STAT1 | grep -q '^##.*\[ahead .*\]'; then
+		local CMD="git push origin"
+		if ! asowner "$CMD"; then
+			echo "$PLACE: Push failed."
+			exit 1
+		fi
+	else
+		local CMD="git status --porcelain"
+		if [ -n "$(asowner "$CMD")" ]; then
+			echo "$PLACE: NOTE: Uncommitted changes found."
+		fi
+	fi
+}
+
+doatree() {
+	cd /$1
+	local GITS=$(find -mindepth 2 -maxdepth 2 -name '.git' -type d)
+
+	for g in $GITS; do
+		doagit $2 $g $1 "$3"
+	done
+}
+
+doatree sources sources
+for repo in core base kde5; do
+	doatree sources/$repo-pkgbuilds $repo-pkgbuilds
+done
+