Skip to content

Commit 87f9d55

Browse files
committed
Allow ./getversion and ./getversion --short commands to function as expected when source directory is not a git repo and a VERSION file exists.
``` ./getversion TAG build commit:SHA ./getversion --short TAG ``` Authored-by: Brent Doil <[email protected]> Use ' build ' as the delimiter. Authored-by: Brent Doil <[email protected]>
1 parent 37287a3 commit 87f9d55

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

getversion

+5-1
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@ if type git >/dev/null 2>&1 && [ -d '.git' ] ; then
2828
VERSION+=+
2929
VERSION+=$(git rev-parse --short HEAD)
3030
fi
31+
# If not a git repository and VERSION file exists, use version string from file.
32+
elif [[ -s ./VERSION ]]; then
33+
VERSION=$(awk -F' build ' '{print $1}' ./VERSION)
34+
BUILDNUMBER=$(awk -F' build ' '{print $2}' ./VERSION)
3135
fi
3236

3337
FLAG="${1:-noflag}"
3438
if [ "$FLAG" = '--short' ] ; then
3539
echo "${VERSION}"
3640
else
37-
if [ -f BUILD_NUMBER ] ; then
41+
if [[ ${BUILDNUMBER} = 'dev' && -f BUILD_NUMBER ]] ; then
3842
BUILDNUMBER=`cat BUILD_NUMBER`
3943
fi
4044
echo "${VERSION} build ${BUILDNUMBER}"

0 commit comments

Comments
 (0)