From a9b2a6c0570d17214f292080e40d9a5bb961a86f Mon Sep 17 00:00:00 2001 From: Chemaclass Date: Tue, 9 Jun 2026 20:40:46 +0200 Subject: [PATCH] fix(cli): ignore floating major tags when resolving latest version The new v0 floating Action tag sorted above exact versions in get_latest_tag, so 'bashunit upgrade' tried to download a v0 release asset that does not exist. Restrict candidates to exact-version tags. --- CHANGELOG.md | 3 +++ src/helpers.sh | 2 ++ tests/unit/helpers_test.sh | 11 +++++++++++ 3 files changed, 16 insertions(+) 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 <