From 63f0177a375c3c611a95854867be4e11ddd9d112 Mon Sep 17 00:00:00 2001 From: Dhairya Oza Date: Sat, 28 Nov 2026 13:49:09 +0530 Subject: [PATCH 1/4] fix(release): consider every tag on the latest release commit `tag_latest_release.sh` collects the tags that decorate the commit currently tagged `latest` into the `TAGS` array, then iterates it with `for tag in $TAGS`. An unquoted, unsubscripted array expansion yields only the first element, so the loop examines exactly one decoration. `git show --pretty=tformat:%d` decorates a commit with branch names as well as tags, so the first entry is frequently not a version tag. When the released commit is also the tip of a branch the list starts with `HEAD -> master`, the loop rejects it as a non-version tag, never reaches the real version tag, and the script falls through to "Versions are equal" and sets `SKIP_TAG=true` - leaving the `latest` tag on the previous release. Iterate `"${TAGS[@]}"` instead. The existing mock happens to put the version tag first, which is why the suite did not catch this; the mocked decoration is now overridable via `TEST_LATEST_TAG_LIST` and a regression test covers a branch-decorated commit. `docker/tag_latest_release.sh` is a byte-identical copy of the script, so it carries the same fix. --- docker/tag_latest_release.sh | 4 ++-- scripts/tag_latest_release.sh | 4 ++-- tests/unit_tests/fixtures/bash_mock.py | 9 ++++++-- .../scripts/tag_latest_release_test.py | 21 +++++++++++++++++++ 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/docker/tag_latest_release.sh b/docker/tag_latest_release.sh index 362ce4f47ee1..bcef8e8f95d3 100755 --- a/docker/tag_latest_release.sh +++ b/docker/tag_latest_release.sh @@ -46,7 +46,7 @@ git_show_ref () { get_latest_tag_list () { if [[ "$TEST_ENV" == "true" ]] then - echo "(tag: 2.1.0, apache/2.1test)" + echo "${TEST_LATEST_TAG_LIST:-(tag: 2.1.0, apache/2.1test)}" else result=$(git show-ref --tags --dereference latest | awk '{print $2}' | xargs git show --pretty=tformat:%d -s | grep tag:) echo "${result}" @@ -140,7 +140,7 @@ TAGS=($(split_string "$LATEST_TAGS" " ")) compare_result="" # Iterate through the tags of the latest release -for tag in $TAGS +for tag in "${TAGS[@]}" do if [[ $tag == "latest" ]]; then continue diff --git a/scripts/tag_latest_release.sh b/scripts/tag_latest_release.sh index 362ce4f47ee1..bcef8e8f95d3 100755 --- a/scripts/tag_latest_release.sh +++ b/scripts/tag_latest_release.sh @@ -46,7 +46,7 @@ git_show_ref () { get_latest_tag_list () { if [[ "$TEST_ENV" == "true" ]] then - echo "(tag: 2.1.0, apache/2.1test)" + echo "${TEST_LATEST_TAG_LIST:-(tag: 2.1.0, apache/2.1test)}" else result=$(git show-ref --tags --dereference latest | awk '{print $2}' | xargs git show --pretty=tformat:%d -s | grep tag:) echo "${result}" @@ -140,7 +140,7 @@ TAGS=($(split_string "$LATEST_TAGS" " ")) compare_result="" # Iterate through the tags of the latest release -for tag in $TAGS +for tag in "${TAGS[@]}" do if [[ $tag == "latest" ]]; then continue diff --git a/tests/unit_tests/fixtures/bash_mock.py b/tests/unit_tests/fixtures/bash_mock.py index f2512d1270cc..7c3e2b94bc98 100644 --- a/tests/unit_tests/fixtures/bash_mock.py +++ b/tests/unit_tests/fixtures/bash_mock.py @@ -20,13 +20,18 @@ class BashMock: @staticmethod - def tag_latest_release(tag): + def tag_latest_release(tag, latest_tag_list=None): bash_command = f"./scripts/tag_latest_release.sh {tag} --dry-run" + env = {"TEST_ENV": "true"} + if latest_tag_list is not None: + # Overrides the mocked `git show --pretty=%d` decoration that the + # script reads for the commit currently tagged `latest`. + env["TEST_LATEST_TAG_LIST"] = latest_tag_list result = subprocess.run( # noqa: S602 bash_command, shell=True, capture_output=True, text=True, - env={"TEST_ENV": "true"}, + env=env, ) return result diff --git a/tests/unit_tests/scripts/tag_latest_release_test.py b/tests/unit_tests/scripts/tag_latest_release_test.py index 15e33978a62e..518ab03c9f05 100644 --- a/tests/unit_tests/scripts/tag_latest_release_test.py +++ b/tests/unit_tests/scripts/tag_latest_release_test.py @@ -62,3 +62,24 @@ def test_tag_latest_release(tag, expected_output): ) assert expected_output in result.stdout + + +@pytest.mark.parametrize( + "tag, expected_output", + [ + ("2.1.1", "This release tag 2.1.1 is newer than the latest."), + ("1.0.0", "This release tag 1.0.0 is older than the latest."), + ("2.1.0", "Versions are equal"), + ], +) +def test_tag_latest_release_reads_every_decoration(tag, expected_output): + """ + `git show --pretty=%d` decorates a commit with branches as well as tags, so + the version tag is not necessarily the first entry in the list. Every entry + has to be considered, not just the first one. + """ + result = BashMock.tag_latest_release( + tag, latest_tag_list="(HEAD -> master, tag: 2.1.0, tag: latest)" + ) + + assert expected_output in result.stdout From 6b9849e42a3b8cf56cbd19e6ba6b06d11c62710c Mon Sep 17 00:00:00 2001 From: dhairya05 <83921853+Dhairya-007@users.noreply.github.com> Date: Sat, 28 Nov 2026 18:32:51 +0530 Subject: [PATCH 2/4] Update tests/unit_tests/scripts/tag_latest_release_test.py Co-authored-by: Amin Ghadersohi --- tests/unit_tests/scripts/tag_latest_release_test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/unit_tests/scripts/tag_latest_release_test.py b/tests/unit_tests/scripts/tag_latest_release_test.py index 518ab03c9f05..6802bd9c2134 100644 --- a/tests/unit_tests/scripts/tag_latest_release_test.py +++ b/tests/unit_tests/scripts/tag_latest_release_test.py @@ -79,7 +79,8 @@ def test_tag_latest_release_reads_every_decoration(tag, expected_output): has to be considered, not just the first one. """ result = BashMock.tag_latest_release( - tag, latest_tag_list="(HEAD -> master, tag: 2.1.0, tag: latest)" + tag, latest_tag_list="(HEAD -> master, tag: latest, tag: 2.1.0)" ) + assert "The current release with the latest tag is version 2.1.0" in result.stdout assert expected_output in result.stdout From 2313785a0443f07456899de1b9c86ace57ea3614 Mon Sep 17 00:00:00 2001 From: dhairya05 <83921853+Dhairya-007@users.noreply.github.com> Date: Sat, 28 Nov 2026 18:33:03 +0530 Subject: [PATCH 3/4] Update scripts/tag_latest_release.sh Co-authored-by: Amin Ghadersohi --- scripts/tag_latest_release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/tag_latest_release.sh b/scripts/tag_latest_release.sh index bcef8e8f95d3..6d99d9dc08ae 100755 --- a/scripts/tag_latest_release.sh +++ b/scripts/tag_latest_release.sh @@ -140,7 +140,7 @@ TAGS=($(split_string "$LATEST_TAGS" " ")) compare_result="" # Iterate through the tags of the latest release -for tag in "${TAGS[@]}" +for tag in $(printf '%s\n' "${TAGS[@]}" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n 1) do if [[ $tag == "latest" ]]; then continue From 53107c4a75dac9d7bce177c94b880991b9706f0f Mon Sep 17 00:00:00 2001 From: dhairya05 <83921853+Dhairya-007@users.noreply.github.com> Date: Sat, 28 Nov 2026 18:41:22 +0530 Subject: [PATCH 4/4] fix(release): compare against the highest tag in the docker copy too The suggestion applied to `scripts/tag_latest_release.sh` picks the highest X.Y.Z decoration to compare against, so a commit carrying two release tags can no longer let an older candidate win. `docker/tag_latest_release.sh` is a byte-identical copy of that script and had been left on the plain `"${TAGS[@]}"` expansion, so the backwards-tag path was still reachable through it: with `(tag: latest, tag: 3.0.0, tag: 2.1.0)`, release 2.5.0 printed "newer than the latest" and wrote `SKIP_TAG=false`. Sync the line so the two copies match again, and pin the behaviour with a test that asserts the comparison is made against 3.0.0 and never against the lower 2.1.0. Co-Authored-By: Claude Opus 5 --- docker/tag_latest_release.sh | 2 +- .../scripts/tag_latest_release_test.py | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/docker/tag_latest_release.sh b/docker/tag_latest_release.sh index bcef8e8f95d3..6d99d9dc08ae 100755 --- a/docker/tag_latest_release.sh +++ b/docker/tag_latest_release.sh @@ -140,7 +140,7 @@ TAGS=($(split_string "$LATEST_TAGS" " ")) compare_result="" # Iterate through the tags of the latest release -for tag in "${TAGS[@]}" +for tag in $(printf '%s\n' "${TAGS[@]}" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n 1) do if [[ $tag == "latest" ]]; then continue diff --git a/tests/unit_tests/scripts/tag_latest_release_test.py b/tests/unit_tests/scripts/tag_latest_release_test.py index 6802bd9c2134..214f1105ea7b 100644 --- a/tests/unit_tests/scripts/tag_latest_release_test.py +++ b/tests/unit_tests/scripts/tag_latest_release_test.py @@ -84,3 +84,27 @@ def test_tag_latest_release_reads_every_decoration(tag, expected_output): assert "The current release with the latest tag is version 2.1.0" in result.stdout assert expected_output in result.stdout + + +@pytest.mark.parametrize( + "tag, expected_output", + [ + ("2.5.0", "This release tag 2.5.0 is older than the latest."), + ("3.0.1", "This release tag 3.0.1 is newer than the latest."), + ("3.0.0", "Versions are equal"), + ], +) +def test_tag_latest_release_compares_against_the_highest_tag(tag, expected_output): + """ + A release commit can carry more than one version tag. Only the highest one + describes what `latest` currently points at, so that is the version the + candidate is compared against -- comparing against a lower tag as well would + let an older release claim to be newer and move `latest` backwards. + """ + result = BashMock.tag_latest_release( + tag, latest_tag_list="(tag: latest, tag: 3.0.0, tag: 2.1.0)" + ) + + assert "The current release with the latest tag is version 3.0.0" in result.stdout + assert "version 2.1.0" not in result.stdout + assert expected_output in result.stdout