我有一个预提交挂钩,如下所示。钩子的目标是确保日志消息的长度至少为20个字符,但有一个例外是带有Adding Directory
的日志消息。在这种情况下,钩子应该允许提交,但它不允许。
REM Start
REM Pre Commit hook for having a comment of at least 20 characters.
setlocal enabledelayedexpansion
set REPOS=%1
set TXN=%2
set SVNLOOK="%VISUALSVN_SERVER%\bin\svnlook.exe"
SET LOGSTRING=
REM Concatenate all the lines in the commit message
FOR /F "usebackq delims==" %%g IN (`%SVNLOOK% log -t %TXN% %REPOS%`) DO SET LOGSTRING=!LOGSTRING!%%g
REM Make sure LOGSTRING is defined
SET LOGSTRING=0%LOGSTRING%
REM EA String Exception Added here
IF %LOGSTRING%" == "Adding Directory"
echo "Exceptional Commit with a Small Message (Generated From EA)"
goto NORMAL_EXIT
REM Here the 20 is the length we require
IF NOT "%LOGSTRING:~20,1%"==""
goto NORMAL_EXIT
:ERROR_TOO_SHORT
echo "Commit note must be at least 20 letters" >&2
goto ERROR_EXIT
:ERROR_EXIT
exit /b 1
REM All checks passed, so allow the commit.
:NORMAL_EXIT
exit 0
问题是当我有一条日志消息Adding Directory
时。我得到错误输出,255(-1)
作为输出。我不习惯这个剧本。它是通过使用来自不同网站的一些逻辑和副本放在一起的代码。我错过了一些非常基本的东西。