diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d598d77..cf4f5cd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +### Fixed +- `bashunit upgrade` resolved the floating `v0` Action tag as the latest version, breaking upgrades; it now only considers exact-version tags + ## [0.39.0](https://github.com/TypedDevs/bashunit/compare/0.38.0...0.39.0) - 2026-06-09 ### Added diff --git a/src/helpers.sh b/src/helpers.sh index 33a5a0a5..0eb9645e 100755 --- a/src/helpers.sh +++ b/src/helpers.sh @@ -322,10 +322,12 @@ function bashunit::helper::get_latest_tag() { return 1 fi + # Floating major tags (e.g. v0) are not releases and must not win git ls-remote --tags "$BASHUNIT_GIT_REPO" | awk '{print $2}' | sed 's|^refs/tags/||' | grep -v '\^{}' | + grep -E '^[0-9]+\.[0-9]+(\.[0-9]+)?$' | sort -Vr | head -n 1 } diff --git a/tests/unit/helpers_test.sh b/tests/unit/helpers_test.sh index 95fbd527..08b7278e 100644 --- a/tests/unit/helpers_test.sh +++ b/tests/unit/helpers_test.sh @@ -292,6 +292,17 @@ EOF unset -f git # remove the mock } +function test_get_latest_tag_ignores_floating_major_tags() { + bashunit::mock git <