Source
xxxxxxxxxx
param=$1
# Get the hint from an environment variable. This is used for detached head builds
# Default grep is master
headGrep="\\\-mas-"
tagid="mas"
#echo $CASABRANCHHINT
if [ ! -z $CASABRANCHHINT ]; then
if [[ $CASABRANCHHINT =~ ^feature.*CAS.* ]] ; then
b1=${CASABRANCHHINT%/*} # part before the slash
b2=${CASABRANCHHINT##*/} # part after the slash
headGrep=$b1-$b2
elif [[ $CASABRANCHHINT =~ ^bugfix.*CAS.* ]] ; then
b1=${CASABRANCHHINT%/*} # part before the slash
b2=${CASABRANCHHINT##*/} # part after the slash
headGrep=$b1-$b2
elif [[ $CASABRANCHHINT =~ ^CAS.* ]] ; then
headGrep=$CASABRANCHHINT
elif [[ $CASABRANCHHINT =~ ^ARD.* ]] ; then
headGrep=$CASABRANCHHINT
elif [[ $CASABRANCHHINT =~ .*release.* ]] ; then
headGrep=$CASABRANCHHINT
tagid="rel"
elif [[ $CASABRANCHHINT =~ ^bambooprtest.* ]] ; then
headGrep="bambooprtest"
fi
fi
#echo $headGrep
# Check where the current "HEAD" points to.
branch=`git rev-parse --abbrev-ref HEAD`
# Detached HEAD, should have a tag
if [ $branch == "HEAD" ];then
headTag=`git tag --points-at HEAD | grep $headGrep`
if [[ -z "${headTag// }" ]]; then
# Get the nearest tag and add Desc
headCommit=`git rev-parse HEAD`
headTag=`git tag --points-at HEAD | grep $headGrep | xargs`
fi
CASA_VERSION_DESC=$headTag
# $CASAFORKPOINTHINT is the fork point commit
# You can obtain this by executing "git merge-base --fork-point master"
# while in the branch, but before detaching the HEAD
if [ -z $CASAFORKPOINTHINT ]; then
if [[ $CASABRANCHHINT =~ .*release.* ]]; then
CASAFORKPOINTHINT=`git merge-base $CASABRANCHHINT $branch`
else
CASAFORKPOINTHINT=`git merge-base master $branch`
fi
fi
if [ $tagid == "rel" ]; then
headTag=`git describe --abbrev=0 --tags --match='[0-9]*.[0-9]*.[0-9]*-rel-[0-9]*' $(git rev-parse $CASAFORKPOINTHINT)`
else
headTag=`git describe --abbrev=0 --tags --match='[0-9]*.[0-9]*.[0-9]*-mas-[0-9]*' $(git rev-parse $CASAFORKPOINTHINT)`
fi
#echo "${headTag##*-};$CASA_VERSION_DESC"
# --curr #echo "${headTag##*-}; "
if [ "$param" == "--pretty-print" ];then
if [ -n "$CASA_VERSION_DESC" ] && [[ "$CASA_VERSION_DESC" != *"-$tagid-"* ]]; then
#echo "${headTag%-mas*}-${headTag##*-}+"