Skip to content

Commit c84656c

Browse files
authored
Merge pull request #77 from microsoft/copilot/fix-75
Fix Microsoft Git install to use releases API for latest, lts, and current versions
2 parents c59303b + b08f4cd commit c84656c

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/microsoft-git/devcontainer-feature.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
22
"name": "Microsoft Git for monorepo with GVFS support",
33
"id": "microsoft-git",
4-
"version": "1.0.6",
4+
"version": "1.0.7",
55
"description": "A fork of Git containing Microsoft-specific patches",
66
"options": {
77
"version": {
88
"type": "string",
99
"proposals": [
1010
"latest",
11-
"2.43.0.vfs.0.0",
12-
"2.42.0.vfs.0.3",
13-
"2.40.1.vfs.0.2",
14-
"2.39.2.vfs.0.0",
15-
"2.38.1.vfs.0.1"
11+
"2.50.1.vfs.0.2",
12+
"2.50.1.vfs.0.1",
13+
"2.50.1.vfs.0.0",
14+
"2.49.0.vfs.0.4",
15+
"2.49.0.vfs.0.3"
1616
],
1717
"default": "latest",
1818
"description": "Select version of Microsoft Git, if not latest."

src/microsoft-git/install.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,21 @@ fi
4444
# Partial version matching
4545
if [ "$(echo "${GIT_VERSION}" | grep -o '\.' | wc -l)" != "2" ]; then
4646
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)"
4847
if [ "${requested_version}" = "latest" ] || [ "${requested_version}" = "lts" ] || [ "${requested_version}" = "current" ]; then
49-
GIT_VERSION="$(echo "${version_list}" | head -n 1)"
48+
# For latest, lts, and current, 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 '"')"
5050
else
51+
# For 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)"
5153
set +e
5254
GIT_VERSION="$(echo "${version_list}" | grep -E -m 1 "^${requested_version//./\\.}([\\.\\s]|$)")"
5355
set -e
56+
if [ -z "${GIT_VERSION}" ] || ! echo "${version_list}" | grep "^${GIT_VERSION//./\\.}$" > /dev/null 2>&1; then
57+
echo "Invalid git version: ${requested_version}" >&2
58+
exit 1
59+
fi
5460
fi
55-
if [ -z "${GIT_VERSION}" ] || ! echo "${version_list}" | grep "^${GIT_VERSION//./\\.}$" > /dev/null 2>&1; then
61+
if [ -z "${GIT_VERSION}" ]; then
5662
echo "Invalid git version: ${requested_version}" >&2
5763
exit 1
5864
fi

0 commit comments

Comments
 (0)