Commits
Ville Suoranta authored 7f5fd5846c3 Merge
1 1 | |
2 2 | |
3 3 | param=$1 |
4 4 | |
5 5 | # Get the hint from an environment variable. This is used for detached head builds |
6 6 | # Default grep is master |
7 7 | headGrep="\\\-mas-" |
8 + | tagid="mas" |
8 9 | #echo $CASABRANCHHINT |
9 10 | if [ ! -z $CASABRANCHHINT ]; then |
10 11 | if [[ $CASABRANCHHINT =~ ^feature.*CAS.* ]] ; then |
11 12 | b1=${CASABRANCHHINT%/*} # part before the slash |
12 13 | b2=${CASABRANCHHINT##*/} # part after the slash |
13 14 | headGrep=$b1-$b2 |
14 15 | elif [[ $CASABRANCHHINT =~ ^bugfix.*CAS.* ]] ; then |
15 16 | b1=${CASABRANCHHINT%/*} # part before the slash |
16 17 | b2=${CASABRANCHHINT##*/} # part after the slash |
17 18 | headGrep=$b1-$b2 |
18 19 | elif [[ $CASABRANCHHINT =~ .*release.* ]] ; then |
19 20 | headGrep=$CASABRANCHHINT |
21 + | tagid="rel" |
20 22 | fi |
21 23 | fi |
22 24 | #echo $headGrep |
23 25 | |
24 26 | # Check where the current "HEAD" points to. |
25 27 | branch=`git rev-parse --abbrev-ref HEAD` |
26 28 | |
27 29 | # Detached HEAD, should have a tag |
28 30 | if [ $branch == "HEAD" ];then |
29 31 | headTag=`git tag --points-at HEAD` |
30 32 | if [[ -z "${headTag// }" ]]; then |
31 33 | # Get the nearest tag and add Desc |
32 34 | headCommit=`git rev-parse HEAD` |
33 35 | headTag=`git tag --points-at HEAD | grep $headGrep | xargs` |
34 36 | fi |
35 37 | CASA_VERSION_DESC=$headTag |
36 38 | # $CASAFORKPOINTHINT is the fork point commit |
37 39 | # You can obtain this by executing "git merge-base --fork-point master" |
38 40 | # while in the branch, but before detaching the HEAD |
39 41 | if [ -z $CASAFORKPOINTHINT ]; then |
40 - | CASAFORKPOINTHINT=`git merge-base master $branch` |
42 + | if [[ $CASABRANCHHINT =~ .*release.* ]]; then |
43 + | CASAFORKPOINTHINT=`git merge-base $CASABRANCHHINT $branch` |
44 + | else |
45 + | CASAFORKPOINTHINT=`git merge-base master $branch` |
46 + | fi |
47 + | fi |
48 + | if [ $tagid == "rel" ]; then |
49 + | headTag=`git describe --abbrev=0 --tags --match='[0-9]*.[0-9]*.[0-9]*-rel-[0-9]*' $(git rev-parse $CASAFORKPOINTHINT)` |
50 + | else |
51 + | headTag=`git describe --abbrev=0 --tags --match='[0-9]*.[0-9]*.[0-9]*-mas-[0-9]*' $(git rev-parse $CASAFORKPOINTHINT)` |
41 52 | fi |
42 - | headTag=`git describe --abbrev=0 --match='[0-9]*.[0-9]*.[0-9]*-mas-[0-9]*' $(git rev-parse $CASAFORKPOINTHINT)` |
43 53 | #echo "${headTag##*-};$CASA_VERSION_DESC" |
44 54 | # --curr #echo "${headTag##*-}; " |
45 55 | if [ "$param" == "--pretty-print" ];then |
46 - | if [ -n "$CASA_VERSION_DESC" ] && [[ "$CASA_VERSION_DESC" != *"-mas-"* ]]; then |
56 + | if [ -n "$CASA_VERSION_DESC" ] && [[ "$CASA_VERSION_DESC" != *"-$tagid-"* ]]; then |
47 57 | #echo "${headTag%-mas*}-${headTag##*-}+" |
48 58 | echo "${headTag}+" |
49 59 | else |
50 60 | echo "${headTag}" |
51 61 | #echo "${headTag%-mas*}-${headTag##*-}" |
52 62 | fi |
53 63 | else |
54 64 | # Don't include version desc for master |
55 - | if [[ $CASA_VERSION_DESC == *"-mas-"* ]];then |
65 + | if [[ $CASA_VERSION_DESC == *"-$tagid-"* ]];then |
56 66 | echo "${headTag##*-};" |
57 67 | else |
58 68 | echo "${headTag##*-};$CASA_VERSION_DESC" |
59 69 | fi |
60 70 | fi |
61 71 | # Master |
62 72 | elif [ $branch == "master" ];then |
63 73 | #echo "Resolving master" |
64 74 | masterTag=`git tag --points-at HEAD | grep \\\-mas- | xargs` |
65 75 | if [[ -z "${masterTag// }" ]]; then |