2016-09-06 15:31:41 -04:00
|
|
|
REM Usage:
|
|
|
|
REM call get-git-ref.bat Variable [Branch]
|
|
|
|
|
|
|
|
setlocal
|
|
|
|
|
|
|
|
set Variable=%~1
|
|
|
|
if "%Variable%"=="" (
|
|
|
|
echo.
|
|
|
|
echo Parameter error
|
|
|
|
exit /B 1
|
|
|
|
)
|
|
|
|
|
|
|
|
set Ref=
|
|
|
|
|
|
|
|
:: Check git executable
|
|
|
|
set GitPath=
|
|
|
|
call "%~dp0find-in-path.bat" GitPath git.exe
|
|
|
|
if "%GitPath%"=="" (
|
|
|
|
echo.
|
|
|
|
echo Git executable not found in PATH.
|
2020-08-08 09:05:05 -04:00
|
|
|
exit /B 1
|
2016-09-06 15:31:41 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
set GitParameter=
|
|
|
|
set Branch=%~2
|
|
|
|
if "%Branch%"=="" (
|
|
|
|
set Branch=HEAD
|
|
|
|
set GitParameter=--head
|
|
|
|
)
|
|
|
|
|
|
|
|
for /F "tokens=1*" %%A in ('git show-ref %GitParameter% %Branch%') do (
|
|
|
|
if "%%B"=="%Branch%" (
|
|
|
|
set Ref=%%A
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
:exit
|
|
|
|
endlocal & set %Variable%=%Ref%
|
|
|
|
exit /B 0
|