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 <kasong@tencent.com>
This commit is contained in:
Kairui Song 2022-12-29 14:28:57 +08:00
parent 3c045b7d01
commit e75a45b829
1 changed files with 6 additions and 1 deletions

View File

@ -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