Skip to content

fix version sorting in release-init.sh#15450

Open
shonfeder wants to merge 1 commit into
mainfrom
fix-release-init
Open

fix version sorting in release-init.sh#15450
shonfeder wants to merge 1 commit into
mainfrom
fix-release-init

Conversation

@shonfeder

Copy link
Copy Markdown
Member

Description

Without setting the versionsort.suffix, alpha-suffixed versions are sorted as later than full releases. This will lead to preparing releases from the wrong (outdated) tag.

With this fix, we should get the expected sorting results.

Related Issue and Motivation

Contributes to #13771

Checklist

Without setting the `versionsort.suffix`, alpha-suffixed versions are
sorted as later than full releases. This will lead to preparing releases
from the wrong (outdated) tag.

With this fix, we should get the expected sorting results.

Signed-off-by: Shon Feder <shon.feder@gmail.com>
@shonfeder shonfeder changed the title fix version sorting fix version sorting in release-init.sh Jul 8, 2026
@shonfeder shonfeder requested a review from Sudha247 July 8, 2026 20:39

function patch_release () {
local last_version=$(git tag --list '*.*.*' --sort=-version:refname | head -n 1 )
local last_version=$(git -c versionsort.suffix="_alpha" tag --list '*.*.*' --sort=-version:refname | head -n 1 )

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to extract the last version extraction into a function that can be used in all the 3 types of releases? It might make it easier to see the next version "calculation", along with code reuse.

@shonfeder shonfeder Jul 9, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using a different pattern to --list for each invocation. When I considered trying to abstract this before, we either end up with something like

latest_version_from_pattern '*.*.*'
latest_version_from_pattern '*.*.0'

or

latest_patch_version
latest_minor_version

and in the former case I fear it seems too cryptic, and doesn't really help with readability, in the latter case it doesn't actually prevent repetition.

We could do like latest_version 'patch', and dispatch on the string, but this feels overengineered for a batch script, IMO. So I'd prefer to just keep the bit of repetition here but also have everything explicit.

Do you have any better ideas that hit the sweet spot between overengineered obscurity (for bash) and avoiding the repetition (with minor variations) here?

@shonfeder shonfeder requested a review from punchagan July 9, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants