Browse Source

Fix lasttag expression to get "latest tag *so far*"

Turns out that the old version has always shown the last tag available
instead of last tag available *so far*, i.e. up to the current HEAD.

This made it impossible to determine version correctly when an older
version was checked out, i.e. installing or packaging an older version
would result in broken versioning.
Alois Mahdal 9 years ago
parent
commit
6aa79bb312
1 changed files with 9 additions and 2 deletions
  1. 9
    2
      src/include/build.sh

+ 9
- 2
src/include/build.sh View File

212
     grep ":" <<<"$prerl" && warn "colon in PRERELEASE may corrupt version data: $prerl"
212
     grep ":" <<<"$prerl" && warn "colon in PRERELEASE may corrupt version data: $prerl"
213
     if git rev-parse HEAD >&/dev/null;
213
     if git rev-parse HEAD >&/dev/null;
214
     then    # we are in git repo... so we can get smart
214
     then    # we are in git repo... so we can get smart
215
-        local lasttag=$(git tag | grep ^v | sort -V | tail -n1)
215
+        local latest_tag=$(
216
+            git log --format="%D" \
217
+              | sed 's/,/\n/g' \
218
+              | sed 's/^[[:blank:]]*//; ' \
219
+              | grep -E '^tag: v[[:digit:]]+\.' \
220
+              | cut -d' ' -f2 \
221
+              | head -1
222
+        )
216
         if ! git describe --tags --exact-match HEAD >&/dev/null;
223
         if ! git describe --tags --exact-match HEAD >&/dev/null;
217
         then    # we are at a later commit than the last tag
224
         then    # we are at a later commit than the last tag
218
             local sha=g$(git log -1 --pretty=format:%h HEAD)
225
             local sha=g$(git log -1 --pretty=format:%h HEAD)
223
         then    # the tree is "dirty", i.e. has been edited
230
         then    # the tree is "dirty", i.e. has been edited
224
             local dirty=dirty
231
             local dirty=dirty
225
         fi
232
         fi
226
-        test -n "$lasttag" && version=${lasttag:1}
233
+        test -n "$latest_tag" && version=${latest_tag:1}
227
         local suffix=""
234
         local suffix=""
228
         case "$commit:$dirty" in
235
         case "$commit:$dirty" in
229
             :)       suffix=""                ;;
236
             :)       suffix=""                ;;