-
Notifications
You must be signed in to change notification settings - Fork 0
SVN pre commit hook
ythy edited this page Jan 10, 2018
·
3 revisions
此文件针对版本库别设置
setlocal enabledelayedexpansion
set REPOS=%1
set TXN=%2
set SVNLOOK="D:\Program Files\csvn\bin\SVNlook.exe"
set WORK_DIR=D:\temp1
set TSLINT="C:\Program Files\nodejs\node" "C:\Users\itcompile\AppData\Roaming\npm\node_modules\tslint\bin\tslint"
set UTILS=D:\compile\mxUtils
set PROJECT=
set TIMESTAMP=
set TSLINT_DIR=
set TEMP_VAR=
set CALL_CODE=
set FILE_PATH=
rem Make sure that the log message contains some text.
%SVNLOOK% log -t %TXN% %REPOS% | FindStr . > nul
IF %ERRORLEVEL% EQU 0 GOTO OK
echo Your commit has been blocked because you didn't provide a log message 1>&2
echo Please write a log message describing the purpose of your changes and 1>&2
echo then try committing again. -- Thank you 1>&2
exit 1
:OK
Rem Check log length.
%SVNLOOK% log -t %TXN% %REPOS% | FindStr ........ > nul
IF %ERRORLEVEL% EQU 0 GOTO OK1
echo You must input reversion log, and not less than 8 characters! 1>&2
exit 1
:OK1
Rem Check log content.
%SVNLOOK% log -t %TXN% %REPOS% | FindStr /C:"Type commit message here…" > nul
IF %ERRORLEVEL% GTR 0 GOTO OK2
echo You must input reversion log, excluded 'Type commit message here…' 1>&2
exit 1
:OK2
Rem Check commit files.
set TIMESTAMP=%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%%time:~9,2%
set TSLINT_DIR=%WORK_DIR%\%TIMESTAMP%
FOR /F "tokens=1,2 delims= " %%i in ('%SVNLOOK% changed -t %TXN% %REPOS%') do (
set TEMP_VAR=%%j
)
call "%UTILS%\indexOf.bat" %TEMP_VAR%
set CALL_CODE=%ERRORLEVEL%
set PROJECT="!TEMP_VAR:~0,%CALL_CODE%!"
if %PROJECT%=="LightBoxApp" (
call :StartCopyFiles
call :StartTSLint
IF !CALL_CODE!==0 GOTO End
echo Linting failed with one or more rule violations 1>&2
exit 1
) else (
GOTO End
)
:StartTSLint
%TSLINT% -c %UTILS%/tslint.json '%TSLINT_DIR%/**/*.ts?'
rd /s /q "%TSLINT_DIR%"
set CALL_CODE=%ERRORLEVEL%
GOTO:EOF
:StartCopyFiles
FOR /F "tokens=1,2 delims= " %%i in ('%SVNLOOK% changed -t %TXN% %REPOS%') do (
IF %%i==U (
call :StartCreateFile %%j %%i
)
IF %%i==A (
call :StartCreateFile %%j %%i
)
)
GOTO:EOF
:StartCreateFile
call "%UTILS%\lastIndexOf.bat" %1
set CALL_CODE=%ERRORLEVEL%
set FILE_PATH=%1
if not exist "%TSLINT_DIR%\!FILE_PATH:~0,%CALL_CODE%!" mkdir "%TSLINT_DIR%\!FILE_PATH:~0,%CALL_CODE%!"
%SVNLOOK% cat -t %TXN% %REPOS% %FILE_PATH% > %TSLINT_DIR%/%FILE_PATH%
GOTO:EOF
:End
rem All checks passed, so allow the commit.
exit 0
tell me how get back to sunshine