|
@@ -130,8 +130,8 @@ get_version() {
|
130
|
130
|
# 2. if we are in git, override the version with last tag
|
131
|
131
|
# 3. if set, add STAGE (from config.mk) as pre-release ID
|
132
|
132
|
# (afer dash)
|
133
|
|
- # 4. if we are at a later commit than the last tag, add commit
|
134
|
|
- # sha1 to build metadata (after plus sign)
|
|
133
|
+ # 4. if we are at a later commit than the last tag, add branch
|
|
134
|
+ # name and commit sha1 to build metadata (after plus sign)
|
135
|
135
|
# 5. if the tree is "dirty", i.e. has uncommited changes,
|
136
|
136
|
# add "dirty" to build metadata
|
137
|
137
|
#
|
|
@@ -141,8 +141,9 @@ get_version() {
|
141
|
141
|
#
|
142
|
142
|
# myprog v1.0.7 # all clear
|
143
|
143
|
# myprog v1.0.7-alpha # STAGE="alpha"
|
144
|
|
- # myprog v1.0.7-alpha+g1aef811 # ^^ + some commits after
|
145
|
|
- # myprog v1.0.7-alpha+g1aef811.dirty # ^^ + tree edited
|
|
144
|
+ # myprog v1.0.7-alpha+g1aef811.master # ^^ + some commits after
|
|
145
|
+ # myprog v1.0.7-alpha+gf14fc4f.api2 # ^^ + on a feature branch
|
|
146
|
+ # myprog v1.0.7-alpha+gf14fc4f.api2.dirty # ^^ + tree edited
|
146
|
147
|
# myprog v1.0.7-alpha+dirty # tag OK but tree edited
|
147
|
148
|
# myprog v1.0.7+dirty # ^^ but no stage
|
148
|
149
|
#
|
|
@@ -172,6 +173,8 @@ get_version() {
|
172
|
173
|
if ! git describe --tags --exact-match HEAD >&/dev/null;
|
173
|
174
|
then # we are at a later commit than the last tag
|
174
|
175
|
local sha=g$(git log -1 --pretty=format:%h HEAD)
|
|
176
|
+ local curbranch=$(git rev-parse --abbrev-ref HEAD)
|
|
177
|
+ local commit="$curbranch.$sha"
|
175
|
178
|
fi
|
176
|
179
|
if test "$(git diff --shortstat 2>/dev/null)" != "";
|
177
|
180
|
then # the tree is "dirty", i.e. has been edited
|
|
@@ -179,15 +182,15 @@ get_version() {
|
179
|
182
|
fi
|
180
|
183
|
version=${lasttag:1}
|
181
|
184
|
local suffix=""
|
182
|
|
- case $stage:$sha:$dirty in
|
183
|
|
- ::) suffix="" ;;
|
184
|
|
- ::dirty) suffix="+$dirty" ;;
|
185
|
|
- :g*:) suffix="+$sha" ;;
|
186
|
|
- :g*:dirty) suffix="+$sha.dirty" ;;
|
187
|
|
- *::) suffix="-$stage" ;;
|
188
|
|
- *::dirty) suffix="-$stage+$dirty" ;;
|
189
|
|
- *:g*:) suffix="-$stage+$sha" ;;
|
190
|
|
- *:g*:dirty) suffix="-$stage+$sha.$dirty" ;;
|
|
185
|
+ case $stage:$commit:$dirty in
|
|
186
|
+ ::) suffix="" ;;
|
|
187
|
+ ::dirty) suffix="+$dirty" ;;
|
|
188
|
+ :*:) suffix="+$commit" ;;
|
|
189
|
+ :*:dirty) suffix="+$commit" ;;
|
|
190
|
+ *::) suffix="-$stage" ;;
|
|
191
|
+ *::dirty) suffix="-$stage+$dirty" ;;
|
|
192
|
+ *:*:) suffix="-$stage+$commit" ;;
|
|
193
|
+ *:*:dirty) suffix="-$stage+$commit.$dirty" ;;
|
191
|
194
|
esac
|
192
|
195
|
version=$version$suffix
|
193
|
196
|
fi
|