git » repo-mgmt.git » commit 283371e

one more lil tool

author Urja (ARMLFS builder)
2024-06-25 12:46:50 UTC
committer Urja (ARMLFS builder)
2024-06-25 12:46:50 UTC
parent a2629c7a95229b8f1d078a3c573d17a4f14f1253

one more lil tool

git-set-upstream.sh +47 -0

diff --git a/git-set-upstream.sh b/git-set-upstream.sh
new file mode 100755
index 0000000..02fa151
--- /dev/null
+++ b/git-set-upstream.sh
@@ -0,0 +1,47 @@
+#!/bin/sh
+if [ "$1" = "--help" ]; then
+	echo "usage $0 [upstream-base] [remote-name]"
+	exit 1
+fi
+SRV=${1:-"/mnt/nfs/git"}
+RMT=${2:-"publish"}
+echo Setting remote $RMT of every git repo to $SRV/folder/repo.git
+echo Enter to continue
+read dummy
+
+
+asowner() {
+	if [[ -O . ]]; then
+		$1
+	else
+		su builder -c "$1"
+	fi
+}
+
+doagit() {
+	local g=$(basename ${2::-5})
+	echo /$3/$g
+	cd /$3/$g
+	if grep -q "remote \"$RMT\"" .git/config; then
+		local CMD="git remote remove $RMT"
+		asowner "$CMD"
+	fi
+	local CMD="git remote add $RMT $SRV/$1/$g.git"
+	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
+
+#./git-arr-all.sh