Files
sics/site_ansto/extract_version.sh
Douglas Clowes 6a49b17dde augment and refactor SICS_* defines
r3738 | dcl | 2012-09-19 11:11:13 +1000 (Wed, 19 Sep 2012) | 1 line
2012-11-15 17:38:16 +11:00

39 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
case "${1^^}" in
"ALL"|"") TARGET=ALL;;
"SITE") TARGET=SITE;;
"BRANCH"|"VERSION") TARGET=BRANCH;;
"REVISION") TARGET=REVISION;;
*) TARGET=ALL
esac
function get_branch {
path="$1"
base="UNKNOWN"
while [ "$path" != "http:" ]
do
resp=$base
if [ "$base" == "trunk" ]
then
echo "trunk"
return 0
fi
base=$(basename $path)
if [ "$base" == "branches" ]
then
echo "${resp}"
return 0
fi
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}" ]
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)"
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