From e6cc2429b3e167a7fb69f197bfc7fdab93273108 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Wed, 30 Jan 2019 19:33:42 +0000 Subject: [PATCH] [build] When generating image version, handle case where current commit has no reachable tags Signed-off-by: Joe LeVeque --- functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions.sh b/functions.sh index 45812a8dab75..6015704d58dd 100644 --- a/functions.sh +++ b/functions.sh @@ -60,7 +60,7 @@ sonic_get_version() { BUILD_NUMBER=${BUILD_NUMBER:-0} ## Check if we are on tagged commit ## Note: escape the version string by sed: / -> _ - if [ "$describe" == "$latest_tag" ]; then + if [ -n "$latest_tag" ] && [ "$describe" == "$latest_tag" ]; then echo "${latest_tag}${dirty}" | sed 's/\//_/g' else echo "${branch_name}.${BUILD_NUMBER}${dirty:--$(git rev-parse --short HEAD)}" | sed 's/\//_/g'