Skip to content

Getting latest tag in extra-packages not working correctly #279

@rchl

Description

@rchl

extra-packages allows fetching latest tag of specified package by either not specifying ref or specifying just a tag prefix.

With:

          extra-packages: sublimelsp/LSP@4070-

it fails to sort the tags properly and returns some old one. Checked with equivalent code in terminal:

git ls-remote --tags --heads https://github.com/sublimelsp/LSP | sed -E -n "s%.*refs/tags/(4070-[0-9]+\.[0-9]+\.[0-9]+)\$%\1%p" | grep -v '\^{}$' | sort -t. -k1,1nr -k2,2nr -k3,3nr | head -n1
4070-1.30.0

I think it would need to strip the prefix (4070- in this case or v in some other cases) before sorting. Otherwise it's not sorted correctly. But then the original prefix would have to be also included when returning result.

Relevant code:

gitResolvePrefixToTag() {
local url="$1"
local prefix="$2"
local refs=$(git ls-remote --tags --heads "$url")
local exact_match=$(echo "$refs" | sed -E -n "s%.*refs/(heads|tags)/($prefix)\$%\2%p" | head -n1)
if [ -n "$exact_match" ]; then
echo "$exact_match"
return 0
fi
if [ -z "$prefix" ]; then
prefix="v?"
fi
local matched_tags=$(echo "$refs" | sed -E -n "s%.*refs/tags/($prefix[0-9]+\.[0-9]+\.[0-9]+)\$%\1%p" | grep -v '\^{}$')
echo "$matched_tags" | sort -t. -k1,1nr -k2,2nr -k3,3nr | head -n1
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions