Commits
7 7 | |
8 8 | #if (branch =~ ".*release/[A-Za-z].*") { |
9 9 | # println "A: " + branch |
10 10 | #} |
11 11 | |
12 12 | #if (branch =~ /.*release\/\d+\.\d+\.\d+/) { |
13 13 | # println "B: " + branch |
14 14 | #} |
15 15 | |
16 16 | $casaBranchHint=$ARGV[0]; |
17 - | $headGrep="-mas-"; |
18 - | $tagid="mas"; |
17 + | $tagMatcher="-mas-"; |
18 + | #$tagid="mas"; |
19 19 | |
20 - | $debug=0; |
21 - | print "headGrep: $headGrep\n" if $debug; |
22 - | print "tagId: $tagid\n" if $debug; |
20 + | $debug=1; |
21 + | print "tagMatcher: $tagMatcher\n" if $debug; |
22 + | #print "tagId: $tagid\n" if $debug; |
23 23 | |
24 24 | # Get the hint from an environment variable. This is used for detached head builds |
25 25 | # Default grep is master |
26 26 | |
27 + | # The "default" Casa release that is not tied to any instrument |
28 + | $defaultReleaseMatch = '.*release/\d+\.\d+\.\d'; |
27 29 | |
28 30 | if ($casaBranchHint) { |
29 31 | print "Branch hint provided: $casaBranchHint\n" if $debug; |
30 32 | if ($casaBranchHint =~ "^(feature|bugfix).*CAS.*") { |
31 33 | @splat = split '/', $casaBranchHint; |
32 34 | print "Splat: @splat\n" if $debug; |
33 - | $headGrep = "@splat[0]-@splat[1]"; |
35 + | $tagMatcher = "@splat[0]-@splat[1]"; |
34 36 | } elsif ($casaBranchHint =~ "^CAS-.*" ) { |
35 - | $headGrep = $casaBranchHint; |
36 - | } elsif ($casaBranchHint =~ ".*release/\d+\.\d+\.\d+") { |
37 - | $headGrep = $casaBranchHint; |
38 - | $tagid="rel"; |
37 + | $tagMatcher = $casaBranchHint; |
38 + | } elsif ($casaBranchHint =~ m/$defaultReleaseMatch/) { |
39 + | $tagMatcher = $casaBranchHint; |
40 + | #$tagid="rel"; |
39 41 | } elsif ($casaBranchHint =~ "^bambooprtest.*" ) { |
40 - | $headGrep = "bambooprtest"; |
42 + | $tagMatcher = "bambooprtest"; |
41 43 | } |
42 44 | } else { |
43 45 | print "No branch hint available $casaBranchHint\n" if $debug; |
44 - | |
45 46 | } |
46 - | print "headGrep: $headGrep\n" if $debug; |
47 + | print "tagMatcher: $tagMatcher\n" if $debug; |
47 48 | |
48 49 | # Check where the current "HEAD" points to. |
49 50 | $branch = `git rev-parse --abbrev-ref HEAD`; |
50 51 | chomp($branch); |
51 52 | print "Current branch: $branch\n" if $debug; |
52 53 | |
54 + | $branchTag = ""; |
53 55 | # Figure version for detached HEAD |
54 56 | if ( $branch eq "HEAD") { |
55 57 | print "Detached head.\n" if $debug; |
56 - | $headTag = `git tag --points-at HEAD | grep -- $headGrep`; |
57 - | print "Head tag: $headTag\n" if $debug; |
58 - | # I don't understand what the purpose of the commented out section was |
59 - | #if (headTag) { |
60 - | # if [[ -z "${headTag// }" ]]; then |
61 - | # # Get the nearest tag and add Desc |
62 - | # headCommit=`git rev-parse HEAD` |
63 - | # headTag=`git tag --points-at HEAD | grep $headGrep | xargs` |
64 - | # fi |
65 - | #} |
66 - | $casaVersionDesc = $headTag; |
67 - | print("Version Description: $casaVersionDesc\n") if $debug; |
68 - | # $CASAFORKPOINTHINT is the fork point commit |
69 - | # You can obtain this by executing "git merge-base --fork-point master" |
70 - | # while in the branch, but before detaching the HEAD |
71 - | $forkpoint = `git merge-base master $branch`; |
72 - | print("Default Fork Point: $forkpoint\n") if $debug; |
73 - | if ($casaBranchHint =~ ".*release.*") { |
74 - | $forkpoint=`git merge-base $casaBranchHint $branch`; |
75 - | } |
76 - | print("Fork Point: $forkpoint\n") if $debug; |
77 - | # |
78 - | $headTag=`git describe --abbrev=0 --tags --match='[0-9]*.[0-9]*.[0-9]*-mas-[0-9]*' \$(git rev-parse $forkpoint)`; |
79 - | if ($tagid eq "rel") { |
80 - | $headTag=`git describe --abbrev=0 --tags --match='[0-9]*.[0-9]*.[0-9]*-rel-[0-9]*' \$(git rev-parse $forkpoint)`; |
81 - | } |
82 - | chomp($headTag); |
83 - | print("headTag: $headTag\n") if $debug; |
84 - | |
85 - | @splat = split '-',$headTag; |
86 - | if ($casaVersionDesc =~".*-$tagid-.*") { |
87 - | print "$splat[-1]\n"; |
88 - | } |
89 - | else { |
90 - | print "$splat[-1];$casaVersionDesc\n"; |
91 - | } |
58 + | $branchTag = `git tag --points-at HEAD | grep -- $tagMatcher`; |
59 + | print "Head tag: $branchTag\n" if $debug; |
92 60 | } |
93 - | # Version from branch |
94 61 | else { |
95 - | if ($branch eq "master") { $tagMatcher = "mas"; } |
96 - | elsif ($branch =~ ".*release/\d+\.\d+\.\d+") { $tagMatcher = "rel"; } |
62 + | if ($branch eq "master") { $tagMatcher = "-mas-"; } |
63 + | elsif ($branch =~ m/$defaultReleaseMatch/) { $tagMatcher = "-rel-"; } |
97 64 | else { |
98 65 | $tagMatcher = $branch; |
99 66 | } |
100 67 | |
101 68 | if ($tagMatcher =~ "/") { |
102 - | $tagMatcher =~ s/\//-/; |
69 + | $tagMatcher =~ s/\//-/g; |
103 70 | } |
104 71 | print "tagMatcher: $tagMatcher\n" if $debug; |
105 - | $branchTag=`git tag --points-at HEAD | grep -- -$tagMatcher-`; |
72 + | $branchTag=`git tag --points-at HEAD | grep -- $tagMatcher`; |
106 73 | $headCommit=`git rev-parse HEAD`; |
107 74 | $casaVersionDesc=""; |
108 - | $needsId=0; |
109 - | if (!$branchTag) { |
110 - | $headCommit=`git rev-parse HEAD`; |
111 - | #$branchTag=`git describe --abbrev=0 --match='[0-9]*.[0-9]*.[0-9]*-$tagMatcher-[0-9]*'`; |
112 - | $needsId=1 |
113 - | } |
114 - | chomp ($branchTag); |
115 - | $casaVersionDesc = "ID $headCommit"; |
116 - | chomp($casaVersionDesc); |
117 - | print "needsId: $needsId\n" if $debug; |
118 - | print "branchTag: $branchTag\n" if $debug; |
119 - | print "casaVersionDesc: $casaVersionDesc\n" if $debug; |
120 - | @splat = split '-', $branchTag; |
121 - | if ($needsId) { |
122 - | if ($tagMatcher eq "rel" || $tagMatcher eq "mas") { |
123 - | print "$splat[-1];$casaVersionDesc\n" |
124 - | } |
125 - | else { |
126 - | print ";$casaVersionDesc\n" |
127 - | } |
128 - | } |
129 - | else { |
130 - | if ($tagMatcher eq "rel" || $tagMatcher eq "mas") { |
131 - | print "$splat[-1];\n" |
132 - | } else { |
133 - | print ";$branchTag\n" |
134 - | } |
135 - | } |
75 + | } |
76 + | ## |
77 + | |
78 + | $needsId=0; |
79 + | if (!$branchTag) { |
80 + | $headCommit=`git rev-parse HEAD`; |
81 + | #$branchTag=`git describe --abbrev=0 --match='[0-9]*.[0-9]*.[0-9]*-$tagMatcher-[0-9]*'`; |
82 + | $needsId=1; |
83 + | } |
84 + | chomp ($branchTag); |
85 + | $casaVersionDesc = "ID $headCommit"; |
86 + | chomp($casaVersionDesc); |
87 + | print "needsId: $needsId\n" if $debug; |
88 + | print "branchTag: $branchTag\n" if $debug; |
89 + | print "casaVersionDesc: $casaVersionDesc\n" if $debug; |
90 + | @splat = split '-', $branchTag; |
91 + | if ($needsId) { |
92 + | if ($tagMatcher eq "rel" || $tagMatcher eq "mas" || $tagMatcher =~ /^release-/) { |
93 + | print "$splat[-1];$casaVersionDesc\n" |
94 + | } |
95 + | else { |
96 + | print ";$casaVersionDesc\n" |
97 + | } |
98 + | } |
99 + | else { |
100 + | if ($tagMatcher eq "rel" || $tagMatcher eq "mas" || $tagMatcher =~ /^release-/) { |
101 + | print "$splat[-1];\n" |
102 + | } else { |
103 + | print ";$branchTag\n" |
104 + | } |
136 105 | } |