From 7e383c395e248a6d848e50d13ace35851369addf Mon Sep 17 00:00:00 2001 From: o9000 Date: Sun, 26 Nov 2017 18:14:46 +0100 Subject: [PATCH] Include commit hash if possible in versioning script, if a non-stable tree is compiled --- get_version.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/get_version.sh b/get_version.sh index 533443d..8fdd225 100755 --- a/get_version.sh +++ b/get_version.sh @@ -1,8 +1,9 @@ #!/bin/sh +SCRIPT_DIR=$(dirname "$0") DIRTY="" -if git status 1>/dev/null 2>/dev/null +if [ -d ${SCRIPT_DIR}/.git ] && git status 1>/dev/null 2>/dev/null then git update-index -q --ignore-submodules --refresh # Disallow unstaged changes in the working tree @@ -31,8 +32,16 @@ then fi fi VERSION=$(git describe 2>/dev/null)$DIRTY +elif [ -d ${SCRIPT_DIR}/.git ] && git log -n 1 1>/dev/null 2>/dev/null +then + VERSION=$(head -n 1 "${SCRIPT_DIR}/ChangeLog" | cut -d ' ' -f 2) + if [ "$VERSION" = "master" ] + then + PREVIOUS=$(grep '^2' "${SCRIPT_DIR}/ChangeLog" | head -n 2 | tail -n 1 | cut -d ' ' -f 2) + HASH=$(git log -n 1 --pretty=format:"%h" 2>/dev/null) + VERSION=$PREVIOUS-$HASH + fi else - SCRIPT_DIR=$(dirname "$0") VERSION=$(head -n 1 "${SCRIPT_DIR}/ChangeLog" | cut -d ' ' -f 2) if [ "$VERSION" = "master" ] then