Add Windows CMD script
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
:: Clone a git repo as a full mirror and pack it into a zip archive.
|
||||
:: Works on Windows (PowerShell 5.0+).
|
||||
|
||||
if "%~1"=="" (
|
||||
echo Usage: %~nx0 ^<git-repo-url^> [output.zip]
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
set "URL=%~1"
|
||||
set "OUT=%~2"
|
||||
if "!OUT!"=="" set "OUT=repo.zip"
|
||||
set "WORK_DIR=.tmp_git_mirror"
|
||||
|
||||
echo [1/3] Cloning mirror of %URL% ...
|
||||
git clone --mirror "%URL%" "%WORK_DIR%"
|
||||
if errorlevel 1 (
|
||||
echo Git clone failed.
|
||||
rmdir /s /q "%WORK_DIR%" >nul 2>&1
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [2/3] Creating %OUT% with maximum compression ...
|
||||
powershell -NoProfile -Command ^
|
||||
"Compress-Archive -Path '%WORK_DIR%\*' -DestinationPath '%OUT%' -CompressionLevel Optimal -Force"
|
||||
|
||||
echo [3/3] Done: %OUT%
|
||||
|
||||
rmdir /s /q "%WORK_DIR%" >nul 2>&1
|
||||
Reference in New Issue
Block a user