make extract_version work with bot svn and git

r3814 | dcl | 2012-11-22 09:22:34 +1100 (Thu, 22 Nov 2012) | 1 line
This commit is contained in:
Douglas Clowes
2012-11-22 09:22:34 +11:00
parent e9cb798ecc
commit 55325dd704

View File

@ -26,13 +26,26 @@ function get_branch {
path=$(dirname $path)
done
}
SICS_VER="$(svn info .. | grep "URL:" | sort -u | cut -d ' ' -f 2 | head -n 1 | xargs basename)"
if [ "sics" == "${SICS_VER}" ]
if [ -e ".svn" ]
then
SICS_VER="$(svn info .. | grep "URL:" | sort -u | cut -d ' ' -f 2 | head -n 1 | xargs dirname | xargs basename)"
SICS_VER="$(svn info | grep "URL:" | sort -u | cut -d ' ' -f 2 | head -n 1 | xargs basename)"
if [ "sics" == "${SICS_VER}" ]
then
SICS_VER="$(svn info .. | grep "URL:" | sort -u | cut -d ' ' -f 2 | head -n 1 | xargs dirname | xargs basename)"
fi
SICS_VER="$(get_branch "$(svn info .. | grep "URL:" | sort -u | cut -d ' ' -f 2 | head -n 1 )")"
SICS_REV="$(svn info --recursive .. | grep "Revision:" | sort -u | cut -d ' ' -f 2)"
else
git log -1 2>&1 >> /dev/null
if [ $? == 0 ]
then
SICS_VER="$(git branch | grep '^*' | cut -d ' ' -f 2)"
SICS_REV="$(git log -1 --oneline | cut -d ' ' -f 1)"
else
SICS_VER="$USER"
SICS_REV="$(date '+%Y-%m-%d-%H-%m-%S')"
fi
fi
SICS_VER="$(get_branch "$(svn info .. | grep "URL:" | sort -u | cut -d ' ' -f 2 | head -n 1 )")"
SICS_REV="$(svn info --recursive .. | grep "Revision:" | sort -u | cut -d ' ' -f 2)"
if [[ ${TARGET} == "SITE" || ${TARGET} == "ALL" ]]; then echo "ANSTO"; fi
if [[ ${TARGET} == "BRANCH" || ${TARGET} == "ALL" ]]; then echo "${SICS_VER}"; fi
if [[ ${TARGET} == "REVISION" || ${TARGET} == "ALL" ]]; then echo "${SICS_REV}"; fi