git » repo-mgmt.git » main » tree

[main] / push-gits.sh

#!/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