Commit eefa7a9e authored by Vitaly Lipatov's avatar Vitaly Lipatov

rpmlog: add support for -v (increment version)

introduce inc_release
parent 643adfeb
......@@ -11,9 +11,9 @@ load_mod spec rpm git etersoft
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echog "rpmlog - update changelog"
echog "Usage: rpmlog [-r|-s] [-l|-t] [SPEC] [TAG]"
echog "Usage: rpmlog [-r|-s|-v] [-l|-t] [SPEC] [TAG]"
echog "Options:"
# echog " -v - increment version"
echog " -v - increment version"
echog " -r - increment release"
echog " -s - increment subrelease"
echog " -l - add changelog from git log (since last release tag or TAG)"
......@@ -24,7 +24,7 @@ fi
is_gear || fatal "rpmlog usable only with gear repo"
INCREMENTMODE=""
if [ "$1" = "-r" ] || [ "$1" = "-s" ] ; then
if [ "$1" = "-r" ] || [ "$1" = "-s" ] || [ "$1" = "-v" ]; then
INCREMENTMODE=$1
shift
fi
......@@ -82,6 +82,8 @@ if [ "$INCREMENTMODE" = "-r" ] ; then
inc_release $SPECNAME
elif [ "$INCREMENTMODE" = "-s" ] ; then
inc_subrelease $SPECNAME
elif [ "$INCREMENTMODE" = "-v" ] ; then
inc_version $SPECNAME
fi
NEWREV=$(get_version $SPECNAME)-$(get_release $SPECNAME)
......
......@@ -127,6 +127,17 @@ set_version()
fi
}
inc_version()
{
local VER=$(get_version "$1")
# fixme: more general and use in other functions (see increment_release test)
local MAJOR=`echo "$VER" | sed -e "s|\.[0-9]*$||"`
local MINOR=`echo "$VER" | sed -e "s|.*\.||"`
[ "$MINOR" = "$VER" ] && MINOR="0"
VER="${MAJOR}.$(($MINOR + 1 ))"
set_version "$1" $VER
}
# decrement release with workaround about non textual release
decrement_release()
{
......
......@@ -15,11 +15,20 @@ get_release()
echo $TESTREL
}
get_version()
{
echo $TESTVER
}
set_release()
{
echo "$2"
}
set_version()
{
echo "$2"
}
TESTREL=alt5
......@@ -39,3 +48,5 @@ check inc_release "alt6" `inc_release ""`
TESTREL=alt6.2
check inc_release "alt7" `inc_release ""`
TESTVER=1.5.7
check inc_version "1.5.8" `inc_version ""`
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment