[packages/rpm-build-tools] shrc: refuse to delete AC-branch if that branch point is unassociated (has no tag on the same hash)

glen glen at pld-linux.org
Sun Aug 12 22:48:41 CEST 2012


commit 1f4470d7ee53cb82673323333fe8dceba564a8a1
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Sun Aug 12 23:48:28 2012 +0300

    shrc: refuse to delete AC-branch if that branch point is unassociated (has no tag on the same hash)

 rpm-build.sh | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/rpm-build.sh b/rpm-build.sh
index 312248f..ddde765 100755
--- a/rpm-build.sh
+++ b/rpm-build.sh
@@ -20,15 +20,19 @@ alias $dist-requires=dist-requires
 
 # move AC-branch tag to current checkout
 # if AC-branch as branch exists, it is first removed
-# TODO: refuse to delete AC-branch if that branch point is unassociated (has no tag on the same hash)
 ac-tag() {
 	# see if remote has branch present
-	if [ -n "$(git branch -r | grep AC-branch)" ]; then
-		git push --delete origin AC-branch
+	local branch=AC-branch
+	if [ -n "$(git branch -r | grep $branch)" ]; then
+		if [ -z "$(git tag --points-at $branch)" ]; then
+			echo >&2 "There's no tag pointing to current $branch; refusing to delete branch"
+			return 1
+		fi
+		git push --delete origin $branch
 	fi
 
-	git tag -f AC-branch
-	git push origin AC-branch
+	git tag -f $branch
+	git push origin $branch
 }
 
 # undo spec utf8


More information about the pld-cvs-commit mailing list