|
44 | 44 | # Partial version matching |
45 | 45 | if [ "$(echo "${GIT_VERSION}" | grep -o '\.' | wc -l)" != "2" ]; then |
46 | 46 | requested_version="${GIT_VERSION}" |
47 | | - 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)" |
48 | | - if [ "${requested_version}" = "latest" ] || [ "${requested_version}" = "lts" ] || [ "${requested_version}" = "current" ]; then |
49 | | - GIT_VERSION="$(echo "${version_list}" | head -n 1)" |
| 47 | + if [ "${requested_version}" = "latest" ]; then |
| 48 | + # For latest, use the releases API to get the actual latest release |
| 49 | + 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 '"')" |
50 | 50 | else |
51 | | - set +e |
52 | | - GIT_VERSION="$(echo "${version_list}" | grep -E -m 1 "^${requested_version//./\\.}([\\.\\s]|$)")" |
53 | | - set -e |
| 51 | + # For other cases (lts, current, partial versions), use the existing tags logic |
| 52 | + 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 |
| 60 | + if [ -z "${GIT_VERSION}" ] || ! echo "${version_list}" | grep "^${GIT_VERSION//./\\.}$" > /dev/null 2>&1; then |
| 61 | + echo "Invalid git version: ${requested_version}" >&2 |
| 62 | + exit 1 |
| 63 | + fi |
54 | 64 | fi |
55 | | - if [ -z "${GIT_VERSION}" ] || ! echo "${version_list}" | grep "^${GIT_VERSION//./\\.}$" > /dev/null 2>&1; then |
| 65 | + if [ -z "${GIT_VERSION}" ]; then |
56 | 66 | echo "Invalid git version: ${requested_version}" >&2 |
57 | 67 | exit 1 |
58 | 68 | fi |
|
0 commit comments