blob: 12858397d054748728502fd86fdb3b19d6f26cdb [file] [log] [blame]
Olivier Mengué023ed692011-03-20 20:22:51 +01001@echo off
2setlocal
3if not "%~1"=="" set GIT_HOME=%~f1
4if "%GIT_HOME%"=="" call :FindGitHome "git.cmd"
5
6if exist "%GIT_HOME%" goto :GitHomeOK
7
8echo MsysGit installation directory not found.>&2
9echo Try to give the directory name on the command line:>&2
10echo %0 "%ProgramFiles%\Git"
11endlocal
12exit /B 1
13
14:GitHomeOK
15set ERR=0
16
17echo Installing gitflow into "%GIT_HOME%"...
18
19call :ChkGetopt getopt.exe || set ERR=1
20if %ERR%==1 goto :End
21echo getopt.exe... Found
22
23if not exist "%GIT_HOME%\bin\git-flow" goto :Install
24echo GitFlow is already installed.>&2
25choice /C YN /M "Do you want to replace it"
26if errorlevel 255 goto :Abort
27if errorlevel 2 goto :Abort
28if not errorlevel 1 goto :Abort
29
30echo Deleting old files...
31for /F %%i in ("%GIT_HOME%\git-flow*" "%GIT_HOME%\gitflow-*") do if exist "%%~fi" del /F /Q "%%~fi"
32
33:Install
34echo Copying files...
35::goto :EOF
36xcopy "%~dp0\..\git-flow" "%GIT_HOME%\bin" /Y /R /F
37if errorlevel 4 if not errorlevel 5 goto :AccessDenied
38if errorlevel 1 set ERR=1
39xcopy "%~dp0\..\git-flow*" "%GIT_HOME%\bin" /Y /R /F || set ERR=1
40xcopy "%~dp0\..\gitflow-*" "%GIT_HOME%\bin" /Y /R /F || set ERR=1
41xcopy "%~dp0\..\shFlags\src\shflags" "%GIT_HOME%\bin\gitflow-shFlags" /Y /R /F || set ERR=1
42
43if %ERR%==1 choice /T 30 /C Y /D Y /M "Some unexpected errors happened. Sorry, you'll have to fix them by yourself."
44
45:End
46endlocal & exit /B %ERR%
47goto :EOF
48
49:AccessDenied
50set ERR=1
51echo.
52echo You should run this script with "Full Administrator" rights:>&2
53echo - Right-click with Shift on the script from the Explorer>&2
54echo - Select "Run as administrator">&2
55choice /T 30 /C YN /D Y /N >nul
56goto :End
57
58:Abort
59echo Installation canceled.>&2
60set ERR=1
61goto :End
62
63:ChkGetopt
64:: %1 is getopt.exe
65if exist "%GIT_HOME%\bin\%1" goto :EOF
66if exist "%~f$PATH:1" goto :EOF
67echo %GIT_HOME%\bin\%1 not found.>&2
68echo You have to install this file manually. See the GitFlow README.
69exit /B 1
70
71:FindGitHome
72setlocal
73set GIT_CMD_DIR=%~dp$PATH:1
74if "%GIT_CMD_DIR%"=="" endlocal & goto :EOF
75endlocal & set GIT_HOME=%GIT_CMD_DIR:~0,-5%
76goto :EOF