Make sure our four digit tags are excluded from the version number
authorWard Vandewege <ward@curii.com>
Thu, 20 May 2021 21:24:18 +0000 (17:24 -0400)
committerWard Vandewege <ward@curii.com>
Thu, 20 May 2021 21:26:49 +0000 (17:26 -0400)
calculation.

No issue #

Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward@curii.com>

version-at-commit.sh

index 89684cf2abdb32b8b6b749a22cf03caf2bba5bcf..84d7d0b4ae3faa0f96f0291c0202616b6c1a0534 100755 (executable)
@@ -1,4 +1,7 @@
 #!/bin/bash
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
 
 set -e -o pipefail
 commit="$1"
@@ -35,9 +38,10 @@ else
 
     if git merge-base --is-ancestor "$nearest_tag" "$merge_base" ; then
         # x.(y+1).0.devTIMESTAMP, where x.y.z is the newest version that does not contain $commit
-       # grep reads the list of tags (-f) that contain $commit and filters them out (-v)
-       # this prevents a newer tag from retroactively changing the versions of everything before it
-        v=$(git tag | grep -vFf <(git tag --contains "$commit") | sort -Vr | head -n1 | perl -pe 's/\.(\d+)\.\d+/".".($1+1).".0"/e')
+        # grep reads the list of tags (-f) that contain $commit and filters them out (-v)
+        # this prevents a newer tag from retroactively changing the versions of everything before it
+        # We also filter out four-digit faux semantic versioning tags, they gum up the works.
+        v=$(git tag | grep -vFf <(git tag --contains "$commit") |grep -v -P '\d.\d.\d.\d' | sort -Vr | head -n1 | perl -pe 's/\.(\d+)\.\d+/".".($1+1).".0"/e')
     else
         # x.y.(z+1).devTIMESTAMP, where x.y.z is the latest released ancestor of $commit
         v=$(echo $nearest_tag | perl -pe 's/(\d+)$/$1+1/e')