diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-09-15 23:00:23 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-10-21 21:40:57 -0700 |
commit | 920c2e71a2ddfcefdc52e1f57606d5fc077b844c (patch) | |
tree | 93a6979898849c810b238c7b911c88493dad5914 | |
parent | 65d860a187822fdb7fe683b5ea3123765ca8fbf7 (diff) |
release.sh: Attempt to autodetect section and current/previous tags
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
-rwxr-xr-x | release.sh | 71 |
1 files changed, 57 insertions, 14 deletions
@@ -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 |