From cdbe4c9b861d3a2daa92593cfe093d95379877b9 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 14 Nov 2022 20:39:34 +0000 Subject: [PATCH] Get only the precise tag number when getting local version, do not show branch name when on master branch(es) Signed-off-by: Adam Warner --- advanced/Scripts/updatecheck.sh | 2 +- advanced/Scripts/version.sh | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/advanced/Scripts/updatecheck.sh b/advanced/Scripts/updatecheck.sh index 938be6cd..6a5324c7 100755 --- a/advanced/Scripts/updatecheck.sh +++ b/advanced/Scripts/updatecheck.sh @@ -17,7 +17,7 @@ function get_local_branch() { function get_local_version() { # Return active version cd "${1}" 2> /dev/null || return 1 - git describe --long --dirty --tags 2> /dev/null || return 1 + git describe --tags --always 2> /dev/null || return 1 } function get_local_hash() { diff --git a/advanced/Scripts/version.sh b/advanced/Scripts/version.sh index 5c74fa05..946c69fe 100755 --- a/advanced/Scripts/version.sh +++ b/advanced/Scripts/version.sh @@ -77,18 +77,27 @@ versionOutput() { [ "$3" = "-c" ] || [ "$3" = "--current" ] || [ -z "$3" ] && curHash=$(getLocalHash "${1}") && branch=$(getLocalBranch "${1}") [ "$3" = "-l" ] || [ "$3" = "--latest" ] || [ -z "$3" ] && latHash=$(getRemoteHash "${1}") && branch=$(getLocalBranch "${1}") fi + + # We do not want to show the branch name when we are on master, + # blank out the variable in this case + if [ "$branch" = "master" ]; then + branch="" + else + branch="$branch " + fi + if [ -n "$current" ] && [ -n "$latest" ]; then - output="${1} version is $branch $current (Latest: $latest)" + output="${1} version is $branch$current (Latest: $latest)" elif [ -n "$current" ] && [ -z "$latest" ]; then - output="Current ${1} version is $branch $current" + output="Current ${1} version is $branch$current" elif [ -z "$current" ] && [ -n "$latest" ]; then output="Latest ${1} version is $latest" elif [ -n "$curHash" ] && [ -n "$latHash" ]; then - output="Local ${1} hash of branch $branch is $curHash (Remote: $latHash)" + output="Local ${1} hash is $curHash (Remote: $latHash)" elif [ -n "$curHash" ] && [ -z "$latHash" ]; then - output="Current local ${1} hash of branch $branch is $curHash" + output="Current local ${1} hash is $curHash" elif [ -z "$curHash" ] && [ -n "$latHash" ]; then - output="Latest remote ${1} hash of branch $branch is $latHash" + output="Latest remote ${1} hash is $latHash" elif [ -z "$curHash" ] && [ -z "$latHash" ]; then output="Hashes for ${1} not available" else