Skip to content

Commit f26b562

Browse files
committed
New wrapper batch script for Windows
The new script acts as the main entrypoint for commands on Windows. It sets up a temporary (local) path where the gin-cli can find all necessary binaries (git, git-annex, etc.) and then runs the command with the user's arguments. If this script is in the user's %path%, the rest of the software doesn't need to be. The bundled binaries take precedent over any existing binaries with the same name in the %path% since the temporary paths are prepended before calling gin.exe. The set-global.bat file has been adjusted to add only the path with the gin.bat in it. It also prompts the user to clean their path of any existing GIN CLI paths, if any are detected. This is better done manually, since parsing and editing the path is too error prone.
1 parent 7d094d7 commit f26b562

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

dorelease

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ def winbundle(binfile, git_pkg, annex_pkg):
439439
shutil.copy("README.md", pkgroot)
440440
shutil.copy(os.path.join("scripts", "gin-shell.bat"), pkgroot)
441441
shutil.copy(os.path.join("scripts", "set-global.bat"), pkgroot)
442+
shutil.copy(os.path.join("scripts", "gin.bat"), pkgroot)
442443

443444
gitdir = os.path.join(pkgroot, "git")
444445
os.makedirs(gitdir)

scripts/gin.bat

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
:: GIN client entry point for Windows
2+
::
3+
:: This file should be part of the gin client Windows bundle.
4+
::
5+
:: The purpose of the file is to act as a wrapper for the GIN CLI binary. It
6+
:: sets the path to use the bundled dependencies without polluting the user's
7+
:: permanent global path.
8+
9+
10+
@echo off
11+
12+
setlocal
13+
set gindir=%~dp0
14+
set ginpaths=%gindir%bin;%gindir%git\usr\bin;%gindir%git\bin
15+
set path=%ginpaths%;%path%
16+
17+
gin.exe %*
18+
endlocal

scripts/set-global.bat

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
11
:: GIN client global setup for Windows
2-
::
2+
::
33
:: This file should be part of the gin client Windows bundle. The purpose of
44
:: the file is to permanently change the user path environment to be able to
55
:: run GIN commands from the command line (cmd and PowerShell).
66

7-
echo off
7+
@echo off
88

9-
set curdir=%~dp0
9+
set ginpath=%~dp0
10+
11+
:: Get user path *only* (No system path)
12+
for /F "skip=2 tokens=1,2*" %%N in ('%SystemRoot%\System32\reg.exe query "HKCU\Environment" /v "Path" 2^>nul') do if /I "%%N" == "Path" call set "userpath=%%P"
13+
14+
echo "Checking"
15+
echo %userpath%|find /I "gin">nul && (
16+
echo Please edit the "Path" variable and remove all previous GIN CLI paths.
17+
echo The environment variables settings window will open automatically.
18+
pause
19+
rundll32 sysdm.cpl,EditEnvironmentVariables
20+
)
21+
22+
:: Read again
23+
for /F "skip=2 tokens=1,2*" %%N in ('%SystemRoot%\System32\reg.exe query "HKCU\Environment" /v "Path" 2^>nul') do if /I "%%N" == "Path" call set "userpath=%%P"
24+
25+
:: Prepend GIN path
26+
echo Prepending "%ginpath%;" to path
27+
setx path "%ginpath%;%userpath%"
1028

11-
set ginbinpath=%curdir%\bin
12-
set gitpaths=%curdir%\git\usr\bin;%curdir%\git\bin
13-
echo Appending "%ginbinpath%;%gitpaths%" to path
14-
echo %path%|find /I "%curdir%">nul || setx path "%path%;%ginbinpath%;%gitpaths%"
1529
echo GIN CLI is ready
1630
pause

0 commit comments

Comments
 (0)