From 276d4cd22d45d85f1630df43dbedfb18628a79ea Mon Sep 17 00:00:00 2001 From: Adrian Dombeck Date: Mon, 3 Feb 2025 11:37:30 +0100 Subject: [PATCH] Fix snap releases still having version 0.2.0-pre1 instead of 0.2.0 `git tag --sort=-v:refname` sorts tagnames with the same base version but different suffixes in lexicographical order, causing prerelease tags to be listed as higher than the main release. This results in the snaps still having `0.2.0-pre1+...` versions instead of `0.2.0+...`. Git supports the `versionsort.suffix` option to avoid exactly that, so let's use it. --- snap/get_version | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snap/get_version b/snap/get_version index b5a095ec..b8e3ce6a 100755 --- a/snap/get_version +++ b/snap/get_version @@ -60,14 +60,14 @@ strip_branch_tag_prefix() { current_branch=$(git -C "${SNAPCRAFT_PART_SRC}" branch --show-current) # Get the highest version tag which is prefixed with the current branch name. -tag=$(git tag --sort=-v:refname --merged="${current_branch}" | grep "^${current_branch}-" | head -1) +tag=$(git -c "versionsort.suffix=-pre" tag --sort=-v:refname --merged="${current_branch}" | grep "^${current_branch}-" | head -1) # If there is no tag prefixed with the current branch name, use the most # recent tag that does not have a non-numerical prefix (that's the case # when we're building a snap for testing on a branch that's not # "msentraid" or "google"). if [ -z "${tag}" ]; then - tag=$(git tag --sort=-v:refname --merged="${current_branch}" | grep -E '^[0-9]+' | head -1) + tag=$(git -c "versionsort.suffix=-pre" tag --sort=-v:refname --merged="${current_branch}" | grep -E '^[0-9]+' | head -1) fi version="${tag}"