[packages/rpm-build-tools/tag_checking: 1/2] tag_exist accepts preexisting tag pointing to HEAD

draenog draenog at pld-linux.org
Wed Jul 11 02:40:17 CEST 2012


commit 8fc2c42bbe75c195c4b0bf41a02d2185f36b622f
Author: Kacper Kornet <draenog at pld-linux.org>
Date:   Tue Jul 10 21:54:18 2012 +0100

    tag_exist accepts preexisting tag pointing to HEAD
    
    Sometimes it is necessary to rebuild once more existing auto tag.
    So the tag_exist shouldn't exist with error when it finds that
    the requested tag exist and points to the HEAD.

 builder.sh | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/builder.sh b/builder.sh
index 900bd6a..44aaac8 100755
--- a/builder.sh
+++ b/builder.sh
@@ -1322,14 +1322,20 @@ get_files() {
 }
 
 tag_exist() {
+# If tag exists and points to other commit exit with error
+# If it existsts and points to HEAD return 1
+# If it doesn't exist return 0
 	local _tag="$1"
+	local sha1=$(git rev-parse HEAD)
 	echo "Searching for tag $_tag..."
 	if [ -n "$DEPTH" ]; then
-		local ref=`git ls-remote $REMOTE_PLD "refs/tags/$_tag"`
-		[ -n  "$ref" ] && echo "$ref" && Exit_error err_tag_exists "$_tag"
+		local ref=$(git ls-remote $REMOTE_PLD "refs/tags/$_tag"  | cut -c -40)
 	else
-		git show-ref "refs/tags/$_tag" && Exit_error err_tag_exists "$_tag"
+		local ref=$(git show-ref "refs/tags/$_tag" | cut -c -40)
 	fi
+	[ -z "$ref" ] && return 0
+	[ "$ref" = "$sha1" ] || Exit_error err_tag_exists "$_tag"
+	return 1
 }
 
 make_tagver() {


More information about the pld-cvs-commit mailing list