diff options
author | Paul W. Frields <stickster@gmail.com> | 2006-02-04 16:06:42 +0000 |
---|---|---|
committer | Paul W. Frields <stickster@gmail.com> | 2006-02-04 16:06:42 +0000 |
commit | 0fe8accbfb476dd77db1bba194a4a025f27d06e6 (patch) | |
tree | 1f40bc3073b971d6b947c3f85b9173898bd3b154 /bin | |
parent | 4e4143000f27054b56ade108a010b28eea693f8c (diff) | |
download | fedora-doc-utils-0fe8accbfb476dd77db1bba194a4a025f27d06e6.tar.gz fedora-doc-utils-0fe8accbfb476dd77db1bba194a4a025f27d06e6.tar.xz fedora-doc-utils-0fe8accbfb476dd77db1bba194a4a025f27d06e6.zip |
Make the clog target a little smarter and more helpful
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/insert-changelog | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/bin/insert-changelog b/bin/insert-changelog index 58eff41..95c0673 100755 --- a/bin/insert-changelog +++ b/bin/insert-changelog @@ -7,6 +7,35 @@ OUTPUT="${1:-${PWD}/$RPMINFO.clog$$}" + +# Check whether a number input is valid +# Relying on global scope since this function isn't useful outside me +validnumber() +{ + case "$ROLE" in + 'doc' ) + VALIDCHARS='[^0-9.]' + MSG="Valid characters are digits and '.' only -- please re-enter." + ;; + 'rpm' ) + VALIDCHARS='[^0-9]' + MSG="Valid characters are digits only -- please re-enter." + ;; + * ) + echo "Role '$ROLE' is invalid, cowardly bail-out" + exit 1 + ;; + esac + if test -z "`echo $NUMBER | grep $VALIDCHARS`"; then + RETVAL=0 + else + echo "$MSG" + RETVAL=1 + fi + return $RETVAL +} + + echo -n "Change to [r]pm package or [d]ocument source? [r/D] " while test -z "$ROLE" ; do read -s -n 1 R @@ -34,15 +63,20 @@ else fi LASTREV=$(get_latest_revision "$ROLE") -if [ -z "$LASTREV" ]; then # this is the first revision for this role +if [ -z "$LASTREV" ] || [ "$LASTREV" = "0" ]; then +# this is the first revision for this role LASTREV=$ZEROREV fi -while test -z "$NUMBER"; do +while test -z "$NUMBER" ; do echo -n "Enter $REVDESC greater than $LASTREV: " read NUMBER + if validnumber ; then # Yes, it's perfectly safe to assume Python is present - if test `python -c "from distutils import version; a=version.LooseVersion('$LASTREV') ; b=version.LooseVersion('$NUMBER'); print b>a"` = "False"; then + if test `python -c "from distutils import version; a=version.LooseVersion('$LASTREV') ; b=version.LooseVersion('$NUMBER'); print b>a"` = "False"; then + NUMBER= + fi + else NUMBER= fi done |