|
@ -4,18 +4,17 @@ |
|
|
# |
|
|
# |
|
|
|
|
|
|
|
|
usage() { |
|
|
usage() { |
|
|
echo "Usage: $0 [short]" |
|
|
echo "Usage: $0 [short|hash]" |
|
|
echo |
|
|
echo |
|
|
echo "Determine the correct version number for the current build" |
|
|
echo "Determine the correct version number for the current build" |
|
|
exit 0 |
|
|
exit 0 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
# TODO: search for the top dir that contains the VERSION file? |
|
|
VER_FILE_DIR=$(dirname "$0")/.. |
|
|
VER_FILE_SHORT=$(cat VERSION) |
|
|
VER_FILE_SHORT=$(cat "${VER_FILE_DIR}/VERSION") |
|
|
|
|
|
|
|
|
if git status >/dev/null; then |
|
|
if git status >/dev/null; then |
|
|
VER_GIT_SHORT=$(git describe --abbrev=0) |
|
|
VER_GIT_SHORT=$(git describe --abbrev=0) |
|
|
VER_GIT=$(git describe --abbrev=7 --dirty) |
|
|
|
|
|
|
|
|
|
|
|
if [ "$VER_FILE_SHORT" != "$VER_GIT_SHORT" ]; then |
|
|
if [ "$VER_FILE_SHORT" != "$VER_GIT_SHORT" ]; then |
|
|
echo "Error: VERSION file does not match tag version ($VER_FILE_SHORT != $VER_GIT_SHORT)" |
|
|
echo "Error: VERSION file does not match tag version ($VER_FILE_SHORT != $VER_GIT_SHORT)" |
|
@ -23,13 +22,18 @@ if git status >/dev/null; then |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
VER_SHORT="$VER_GIT_SHORT" |
|
|
VER_SHORT="$VER_GIT_SHORT" |
|
|
VER="$VER_GIT" |
|
|
VER_HASH=$(git rev-parse --short HEAD) |
|
|
|
|
|
VER=$(git describe --abbrev=7 --dirty) |
|
|
else |
|
|
else |
|
|
VER_SHORT="$VER_FILE_SHORT" |
|
|
VER_SHORT="$VER_FILE_SHORT" |
|
|
|
|
|
VER_HASH="HEAD" |
|
|
VER="$VER_FILE_SHORT" |
|
|
VER="$VER_FILE_SHORT" |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
case "$1" in |
|
|
case "$1" in |
|
|
|
|
|
hash) |
|
|
|
|
|
echo "$VER_HASH" |
|
|
|
|
|
;; |
|
|
short) |
|
|
short) |
|
|
echo "$VER_SHORT" |
|
|
echo "$VER_SHORT" |
|
|
;; |
|
|
;; |
|
|