[PATCH for discussion] release.sh: autodetect current and previous tags

Alan Coopersmith alan.coopersmith at oracle.com
Fri Sep 24 11:21:30 PDT 2010


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---

Inspired by discussion at XDS, this uses git describe to get the current
and previous tags when not specified on the command line.

This has worked for the past few app releases I've pushed, using just
"./release.sh app" - presumably we could automate the section detection
from the git master URL too.

However, these are all simple app releases, and I've not made sure it
works with repos with multiple active branches like xserver, and it
could probably use some more error checking before going upstream.

(Perhaps checking that "$tag_current" == "$(git describe HEAD)" to verify
 the listed tag points to the most recent commit?)

 release.sh |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/release.sh b/release.sh
index ea4d9c9..95424d9 100755
--- a/release.sh
+++ b/release.sh
@@ -16,7 +16,8 @@ remote=origin
 usage()
 {
     cat <<HELP
-Usage: `basename $0` [options] <section> <tag_previous> <tag_current>
+Usage: `basename $0` [options] <section> [<tag_previous> [<tag_current>]]
+Usage: `basename $0` [options] <section> initial [<tag_current>]
 
 Options:
   --force       force overwritting an existing release
@@ -114,9 +115,21 @@ while [ $# != 0 ]; do
         ;;
     *)
         section="$1"
-        tag_previous="$2"
-        tag_current="$3"
-        shift 3
+	shift
+	if [ $# != 0 ]; then
+            tag_previous="$2"
+	    shift
+	else
+	    tag_previous="$(git describe --abbrev=0 HEAD^)"
+	    echo "Detected previous tag: $tag_previous"
+	fi
+        if [ $# != 0 ]; then
+            tag_current="$3"
+            shift
+	else
+	    tag_current="$(git describe --abbrev=0)"
+	    echo "Detected current tag: $tag_current"
+	fi
         if [ $# != 0 ]; then
             echo "error: unknown parameter"
             usage
-- 
1.5.6.5



More information about the xorg-devel mailing list