[PATCH RFC:modular] release.sh: Attempt to autodetect section and current/previous tags

Alan Coopersmith alan.coopersmith at oracle.com
Fri Sep 16 11:11:55 PDT 2011


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 release.sh |   71 ++++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 57 insertions(+), 14 deletions(-)

An update to the version I've been using for about a year - after a discussion
at XDC with Keith about adding section autodetection by having a file in every
repo with the directory name, I realized we basically already have one in the
git origin URL.

Still needs a confirmation prompt, which I haven't had time to add, though
it really should be just a few lines of scripting.   Anyone want to contribute
that?  It could even be a separate patch applied before this one.

diff --git a/release.sh b/release.sh
index c522e1e..073114d 100755
--- a/release.sh
+++ b/release.sh
@@ -17,7 +17,8 @@ moduleset=
 usage()
 {
     cat <<HELP
-Usage: `basename $0` [options] <section> <tag_previous> <tag_current>
+Usage: `basename $0` [options] [<section> [<tag_previous> [<tag_current>]]]
+   or: `basename $0` [options] <section> initial [<tag_current>]
 
 Options:
   --force       force overwritting an existing release
@@ -123,19 +124,68 @@ while [ $# != 0 ]; do
         exit 1
         ;;
     *)
-        if [ $# != 3 ]; then
-            echo "error: invalid argument count"
+        section="$1"
+        shift
+        if [ $# != 0 ]; then
+            tag_previous="$1"
+            shift
+            if [ $# != 0 ]; then
+                tag_current="$1"
+                shift
+            fi
+        fi
+        if [ $# != 0 ]; then
+            echo "error: unknown parameter"
             usage
             exit 1
         fi
-        section="$1"
-        tag_previous="$2"
-        tag_current="$3"
-        shift 3
         ;;
     esac
 done
 
+
+# Attempt to auto-detect values if not specified
+if [ -z "$section" ]; then
+    section="$(git config --get "remote.${remote}.url" | sed -n 's%^.*freedesktop.org/git/xorg/\([^/]*\).*$%\1%p')"
+    echo "Detected section: $section"
+fi
+
+if [ -z "$tag_previous" ]; then
+    tag_previous="$(git describe --abbrev=0 HEAD^)"
+    echo "Detected previous tag: $tag_previous"
+fi
+
+if [ -z "$tag_current" ]; then
+    tag_current="$(git describe --abbrev=0)"
+    echo "Detected current tag: $tag_current"
+fi
+
+
+# Check for required values
+if [ -z "$section" ]; then
+    echo "error: section not found."
+    usage
+    exit 1
+fi
+
+if [ -z "$tag_previous" ] ; then
+    echo "error: previous tag not found."
+    usage
+    exit 1
+fi
+
+if [ -z "$tag_current" ] ; then
+    echo "error: current tag not found."
+    usage
+    exit 1
+fi
+
+if [ "x$tag_previous" = "x$tag_current" ] ; then
+    echo "current tag ($tag_current) must be different than"
+    echo "previous tag ($tag_previous)"
+    exit 1
+fi
+
 # Check for uncommitted/queued changes.
 if [ "x$ignorechanges" != "x1" ]; then
     set +e
@@ -201,13 +251,6 @@ if ! [ -f "$tarball_dir/$tarbz2" ] ||
     exit 1
 fi
 
-if [ -z "$tag_previous" ] ||
-   [ -z "$section" ]; then
-    echo "error: previous tag or section not found."
-    usage
-    exit 1
-fi
-
 if [ -n "$moduleset" ]; then
     echo "checking for moduleset"
     if ! [ -w "$moduleset" ]; then
-- 
1.7.3.2



More information about the xorg-devel mailing list