From c7d1b6e4ab372022703feddbc5432cf3928df933 Mon Sep 17 00:00:00 2001 From: Draqoken <67341000+audioses@users.noreply.github.com> Date: Wed, 2 Jul 2025 01:29:29 +0300 Subject: [PATCH] fixed git installer --- cleaner.bat | 35 ----------------------------------- git installer.bat | 23 +++++++++++++++++------ 2 files changed, 17 insertions(+), 41 deletions(-) delete mode 100644 cleaner.bat diff --git a/cleaner.bat b/cleaner.bat deleted file mode 100644 index 6c5600b..0000000 --- a/cleaner.bat +++ /dev/null @@ -1,35 +0,0 @@ -@echo off -echo This script will rewrite git history, keeping only the last commit as the new root. -echo It will also force push to your remote. BACK UP FIRST! -pause - -REM Get the current branch name into a variable -FOR /F "delims=" %%i IN ('git rev-parse --abbrev-ref HEAD') DO set CURRENT_BRANCH=%%i - -echo Current branch is: %CURRENT_BRANCH% -pause - -REM Create a temporary branch from the last commit -git checkout --orphan temp_branch - -REM Reset temp_branch to the last commit (keeps files staged) -git reset --hard HEAD - -REM Delete old branch -git branch -D %CURRENT_BRANCH% - -REM Rename temp_branch to original branch name -git branch -m %CURRENT_BRANCH% - -REM Force garbage collection to remove old commits -git reflog expire --expire=now --all -git gc --prune=now --aggressive - -echo Will now force push to remote! -pause - -REM Force push to remote origin (replace with your remote if needed) -git push -f origin %CURRENT_BRANCH% - -echo Done! The repo now only contains the last commit as the initial release. -pause diff --git a/git installer.bat b/git installer.bat index f2e2206..82f05f8 100644 --- a/git installer.bat +++ b/git installer.bat @@ -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%"