From b1380baa9f8b3bebe5e21905b75c1c2fd04c7476 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Mon, 5 Mar 2018 22:14:36 +0000 Subject: [PATCH] Update versioning to v1.2.3 where derived from the tag and 3 is commits since last tag --- contrib/semver/version.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/contrib/semver/version.sh b/contrib/semver/version.sh index 62acd62c..1839a67b 100644 --- a/contrib/semver/version.sh +++ b/contrib/semver/version.sh @@ -1,7 +1,7 @@ #!/bin/sh # Get the last tag -TAG=$(git describe --abbrev=0 --tags --match="v[0-9]*\.[0-9]*\.[0-9]*" 2>/dev/null) +TAG=$(git describe --abbrev=0 --tags --match="v[0-9]*\.[0-9]*" 2>/dev/null) # Get the number of commits from the last tag COUNT=$(git rev-list $TAG..HEAD --count 2>/dev/null) @@ -10,17 +10,17 @@ COUNT=$(git rev-list $TAG..HEAD --count 2>/dev/null) if [ $? != 0 ]; then COUNT=$(git rev-list HEAD --count 2>/dev/null) - printf 'v0.0.0-%d' "$COUNT" + printf 'v0.0.%d' "$COUNT" exit -1 fi -# Trim the "v" off the front -TAG=$(echo $TAG | cut -c 2-) - # Split out into major, minor and patch numbers -MAJOR=$(echo $TAG | cut -d "." -f 1) -MINOR=$(echo $TAG | cut -d "." -f 2) -PATCH=$(echo $TAG | cut -d "." -f 3) +MAJOR=$(echo $TAG | cut -c 2- | cut -d "." -f 1) +MINOR=$(echo $TAG | cut -c 2- | cut -d "." -f 2) # Output in the desired format -printf 'v%d.%d.%d-%d' "$MAJOR" "$MINOR" "$PATCH" "$COUNT" +if [ $COUNT = 0 ]; then + printf 'v%d.%d' "$MAJOR" "$MINOR" +else + printf 'v%d.%d.%d' "$MAJOR" "$MINOR" "$COUNT" +fi