Update git installer.bat
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
@echo off
|
||||
setlocal
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
:: Define variables
|
||||
set "GIT_URL=https://github.com/git-for-windows/git/releases/latest/download/PortableGit-2.49.0-64-bit.7z.exe"
|
||||
set "GIT_ARCHIVE=PortableGit.7z.exe"
|
||||
set "SCRIPT_DIR=%~dp0"
|
||||
set "EXTRACT_DIR=%SCRIPT_DIR%gitportable"
|
||||
set "GIT_ARCHIVE=PortableGit.7z.exe"
|
||||
set "API_URL=https://api.github.com/repos/git-for-windows/git/releases/latest"
|
||||
|
||||
:: Check if Git is available in the PATH
|
||||
where git >nul 2>nul
|
||||
@@ -20,9 +20,20 @@ if exist "%EXTRACT_DIR%\" (
|
||||
goto :EOF
|
||||
)
|
||||
|
||||
:: Download Portable Git
|
||||
echo Downloading Portable Git...
|
||||
powershell -Command "Invoke-WebRequest -Uri '%GIT_URL%' -OutFile '%SCRIPT_DIR%%GIT_ARCHIVE%'"
|
||||
:: Use PowerShell to get the download URL dynamically
|
||||
echo Fetching latest Portable Git release info...
|
||||
for /f "usebackq delims=" %%i in (`powershell -NoProfile -Command ^
|
||||
"(Invoke-RestMethod -Uri '%API_URL%').assets | Where-Object { $_.name -like '*64-bit.7z.exe' } | Select-Object -First 1 -ExpandProperty browser_download_url"`) do (
|
||||
set "GIT_URL=%%i"
|
||||
)
|
||||
|
||||
if not defined GIT_URL (
|
||||
echo Failed to find download URL from GitHub API.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo Downloading Portable Git from: %GIT_URL%
|
||||
powershell -NoProfile -Command "Invoke-WebRequest -Uri '%GIT_URL%' -OutFile '%SCRIPT_DIR%%GIT_ARCHIVE%'"
|
||||
|
||||
:: Create extraction directory
|
||||
mkdir "%EXTRACT_DIR%"
|
||||
|
||||
Reference in New Issue
Block a user