From 19e4f70244e09ddc8e351430686a96bd1a3c10a4 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Thu, 25 Jul 2019 13:57:18 -0700 Subject: [PATCH] Change default behavior to remove a prerelease tag if present instead of a minor version bump --- scripts/increment-cargo-version.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/scripts/increment-cargo-version.sh b/scripts/increment-cargo-version.sh index 0ac376b951..7e729eacf7 100755 --- a/scripts/increment-cargo-version.sh +++ b/scripts/increment-cargo-version.sh @@ -6,7 +6,9 @@ usage() { usage: $0 [major|minor|patch|-preXYZ] Increments the Cargo.toml version. -A minor version increment is the default + +Default: +* Removes the prerelease tag if present, otherwise the minor version is incremented. EOF exit 0 } @@ -47,10 +49,19 @@ semverParseInto "$(readCargoVariable version "${Cargo_tomls[0]}")" MAJOR MINOR P [[ -n $MAJOR ]] || usage currentVersion="$MAJOR.$MINOR.$PATCH$SPECIAL" + +bump=$1 +if [[ -z $bump ]]; then + if [[ -n $SPECIAL ]]; then + bump=dropspecial # Remove prerelease tag + else + bump=minor + fi +fi SPECIAL="" # Figure out what to increment -case ${1:-minor} in +case $bump in patch) PATCH=$((PATCH + 1)) ;; @@ -60,6 +71,8 @@ major) minor) MINOR=$((MINOR+ 1)) ;; +dropspecial) + ;; -*) if [[ $1 =~ ^-[A-Za-z0-9]*$ ]]; then SPECIAL="$1"