From e75a45b8294f1d2cbf6508299d526c745c458a99 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 29 Dec 2022 14:28:57 +0800 Subject: [PATCH] dist: fix a rare corner case when HEAD is tagged multiple time Upstream: no If HEAD is tagged multiple times with valid and invalid tags, prefer the valid tags. Signed-off-by: Kairui Song --- dist/scripts/lib-version.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dist/scripts/lib-version.sh b/dist/scripts/lib-version.sh index d6e8c773f..b16f504fe 100755 --- a/dist/scripts/lib-version.sh +++ b/dist/scripts/lib-version.sh @@ -103,7 +103,12 @@ _get_last_git_tag_of() { for tag in $(git "$@" tag --points-at "$gitref"); do tagged=1 last_tag="$tag" - if [[ "$last_tag" == "$gitref" ]]; then + if [[ "$tag" == "$gitref" ]]; then + break + fi + # If HEAD is tagged with multiple tags and user is not asking to use one of them, + # use the first one found matching release info. + if [[ "$gitref" == HEAD ]] && _get_rel_info_from_tag "$tag" > /dev/null; then break fi done