This allows us to track what the differences are to the git version We also include it into .gitignore.
64 lines
1.7 KiB
Bash
Executable File
64 lines
1.7 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
|
|
}
|
|
if [ -e ".svn" ]
|
|
then
|
|
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 '^*' | sed 's/^\* *//')"
|
|
SICS_REV="$(git log -1 --oneline | cut -d ' ' -f 1)"
|
|
SICS_PLUS="$(git diff --name-status HEAD | wc -l)"
|
|
if [[ ${SICS_PLUS} > 0 ]]
|
|
then
|
|
SICS_REV="${SICS_REV}+${SICS_PLUS}"
|
|
git diff > PATCH.TXT
|
|
else
|
|
rm PATCH.TXT
|
|
fi
|
|
unset SICS_PLUS
|
|
else
|
|
SICS_VER="$USER"
|
|
SICS_REV="$(date '+%Y-%m-%d-%H-%m-%S')"
|
|
fi
|
|
fi
|
|
export SICS_SITE="ANSTO"
|
|
export SICS_REV
|
|
export SICS_VER
|
|
if [[ ${TARGET} == "SITE" || ${TARGET} == "ALL" ]]; then echo "${SICS_SITE}"; fi
|
|
if [[ ${TARGET} == "BRANCH" || ${TARGET} == "ALL" ]]; then echo "${SICS_VER}"; fi
|
|
if [[ ${TARGET} == "REVISION" || ${TARGET} == "ALL" ]]; then echo "${SICS_REV}"; fi
|