Skip to content

Commit 3d2b5b5

Browse files
committed
Sort git tags when determining prerelease version
Tags are sorted lexicographically by default, not by version, so for example right now `git ls-remote` for this repo shows: ``` $ git ls-remote --tags \ https://github.com/github/copilot-cli \ | tail -3 | awk -F/ '{print$NF}' v1.0.8 v1.0.8-0 v1.0.9 ``` With the sort option, it shows the correct latest prerelease tags: ``` $ git ls-remote --tags --sort "version:refname" \ https://github.com/github/copilot-cli \ | tail -3 | awk -F/ '{print$NF}' v1.0.12-0 v1.0.12-1 v1.0.12-2 ``` This option for git ls-remote was added in git version 2.18.0 in June 2018: https://github.com/git/git/blob/v2.18.0/Documentation/RelNotes/2.18.0.txt#L69-L70
1 parent 2a03ddf commit 3d2b5b5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ elif [ "${VERSION}" = "prerelease" ]; then
5454
echo "Error: git is required to install prerelease versions" >&2
5555
exit 1
5656
fi
57-
VERSION="$(git ls-remote --tags "$GIT_REMOTE" | tail -1 | awk -F/ '{print $NF}')"
57+
VERSION="$(git ls-remote --tags --sort "version:refname" "$GIT_REMOTE" | tail -1 | awk -F/ '{print $NF}')"
5858
if [ -z "$VERSION" ]; then
5959
echo "Error: Could not determine prerelease version" >&2
6060
exit 1

0 commit comments

Comments
 (0)