Change default behavior to remove a prerelease tag if present instead of a minor version bump

This commit is contained in:
Michael Vines 2019-07-25 13:57:18 -07:00
parent a233a1c822
commit 19e4f70244
No known key found for this signature in database
GPG Key ID: 33F4FDEC4E0E88BD
1 changed files with 15 additions and 2 deletions

View File

@ -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"