[packages/rpm-build-tools/purge: 2/3] purge_packages: Check for changes not merged upstream

draenog draenog at pld-linux.org
Sun Mar 24 22:35:31 CET 2013


commit 5e5f625e644ed4b63a231675348d7a22cf517289
Author: Kacper Kornet <draenog at pld-linux.org>
Date:   Sat Mar 23 18:32:01 2013 +0000

    purge_packages: Check for changes not merged upstream

 purge-packages.sh | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/purge-packages.sh b/purge-packages.sh
index 2819921..45c40ed 100755
--- a/purge-packages.sh
+++ b/purge-packages.sh
@@ -17,6 +17,8 @@ install -d $purgedir
 for pkg in */.git; do
 	pkg=${pkg%/.git}
 	cd "$pkg"
+	purge='yes'
+
 	status=$(git status --porcelain)
 	stash=$(git stash list)
 
@@ -24,16 +26,31 @@ for pkg in */.git; do
 	if [ -n "$status" ] || [ -n "$stash" ]; then
 		cat <<-EOF
 		* Package $pkg - Untracked files or stash not empty. Invoke gc
-
 		$status
 		EOF
+		purge='no'
 		git gc
-	else
+	fi
+	git show-ref --heads |\
+	{ while read sha1 branch; do
+		short_branch=${branch#refs/heads/}
+		if ! upstream=$(git rev-parse -q --verify $short_branch@{u}) 2>/dev/null; then
+			echo "* Package $pkg - Branch $short_branch has not defined upstream"
+			purge='no'
+			continue
+		fi
+		if [ -n "$(git rev-list "$branch..$upstream")" ]; then
+			echo "* Package $pkg - Branch $short_branch is not fully merged to its upstream"
+			purge='no'
+			continue
+		fi
+	done
+	if [ "$purge" = 'yes' ]; then
 		cat <<-EOF
 		* Package $pkg - State clean. Removing
 		EOF
 		mv ../$pkg $purgedir
-	fi
+	fi }
 	cd ..
 done
 
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/rpm-build-tools.git/commitdiff/97aad83e634a16e6d9608d1b371e1b92305b5c6a



More information about the pld-cvs-commit mailing list