Skip to content

Commit 5422b13

Browse files
authored
fix(cli): ignore floating major tags when resolving latest version (#714)
1 parent f91a50f commit 5422b13

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Unreleased
44

5+
### Fixed
6+
- `bashunit upgrade` resolved the floating `v0` Action tag as the latest version, breaking upgrades; it now only considers exact-version tags
7+
58
## [0.39.0](https://github.com/TypedDevs/bashunit/compare/0.38.0...0.39.0) - 2026-06-09
69

710
### Added

src/helpers.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,12 @@ function bashunit::helper::get_latest_tag() {
322322
return 1
323323
fi
324324

325+
# Floating major tags (e.g. v0) are not releases and must not win
325326
git ls-remote --tags "$BASHUNIT_GIT_REPO" |
326327
awk '{print $2}' |
327328
sed 's|^refs/tags/||' |
328329
grep -v '\^{}' |
330+
grep -E '^[0-9]+\.[0-9]+(\.[0-9]+)?$' |
329331
sort -Vr |
330332
head -n 1
331333
}

tests/unit/helpers_test.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,17 @@ EOF
292292
unset -f git # remove the mock
293293
}
294294

295+
function test_get_latest_tag_ignores_floating_major_tags() {
296+
bashunit::mock git <<EOF
297+
fc9aac40eb8e5ad4483f08d79eb678a3650dcf78 refs/tags/0.38.0
298+
3977be123b0b73cfdf4b4eff46b909f37aa83b3c refs/tags/0.39.0
299+
9bb3726a1bf83fb09ca548a398762ab89baaa9b6 refs/tags/v0
300+
b546c693198870dd75d1a102b94f4ddad6f4f3ea refs/tags/v0^{}
301+
EOF
302+
assert_same "0.39.0" "$(bashunit::helper::get_latest_tag)"
303+
unset -f git # remove the mock
304+
}
305+
295306
function test_to_run_with_filter_matching_string_in_function_name() {
296307
local functions
297308
functions=("test_my_awesome_function" "test_your_awesome_function" "test_so_lala_function")

0 commit comments

Comments
 (0)