fix version sorting in release-init.sh#15450
Conversation
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>
|
|
||
| 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 ) |
There was a problem hiding this comment.
This config param is explained at https://git-scm.com/docs/git-config#Documentation/git-config.txt-versionsortsuffix
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
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