Skip to content

Commit ba76547

Browse files
Copilotmarkphip
andcommitted
Treat lts, current, and latest as synonyms using releases API
All three version types (latest, lts, current) now use the GitHub releases API to get the actual latest release, ensuring they all get properly released versions instead of potentially unreleased development tags. Co-authored-by: markphip <933108+markphip@users.noreply.github.com>
1 parent 99d0063 commit ba76547

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/microsoft-git/install.sh

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,15 @@ fi
4444
# Partial version matching
4545
if [ "$(echo "${GIT_VERSION}" | grep -o '\.' | wc -l)" != "2" ]; then
4646
requested_version="${GIT_VERSION}"
47-
if [ "${requested_version}" = "latest" ]; then
48-
# For latest, use the releases API to get the actual latest release
47+
if [ "${requested_version}" = "latest" ] || [ "${requested_version}" = "lts" ] || [ "${requested_version}" = "current" ]; then
48+
# For latest, lts, and current, use the releases API to get the actual latest release
4949
GIT_VERSION="$(curl -sSL -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/microsoft/git/releases/latest" | grep -oP '"tag_name":\s*"v\K[0-9]+\.[0-9]+\.[0-9]+\.vfs\.[0-9]+\.[0-9]+"' | tr -d '"')"
5050
else
51-
# For other cases (lts, current, partial versions), use the existing tags logic
51+
# For partial versions, use the existing tags logic
5252
version_list="$(curl -sSL -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/microsoft/git/tags?per_page=100" | grep -oP '"name":\s*"v\K[0-9]+\.[0-9]+\.[0-9]+\.vfs\.[0-9]+\.[0-9]+"' | tr -d '"' | sort -rV)"
53-
if [ "${requested_version}" = "lts" ] || [ "${requested_version}" = "current" ]; then
54-
GIT_VERSION="$(echo "${version_list}" | head -n 1)"
55-
else
56-
set +e
57-
GIT_VERSION="$(echo "${version_list}" | grep -E -m 1 "^${requested_version//./\\.}([\\.\\s]|$)")"
58-
set -e
59-
fi
53+
set +e
54+
GIT_VERSION="$(echo "${version_list}" | grep -E -m 1 "^${requested_version//./\\.}([\\.\\s]|$)")"
55+
set -e
6056
if [ -z "${GIT_VERSION}" ] || ! echo "${version_list}" | grep "^${GIT_VERSION//./\\.}$" > /dev/null 2>&1; then
6157
echo "Invalid git version: ${requested_version}" >&2
6258
exit 1

0 commit comments

Comments
 (0)