SVN Pre Commit Hooks

I am currently trying to expand our existing (and working) pre commit batch file for SVN transfer. The first part blocks any commit that has no comments and works as expected. The second part is an attempt to block users sending SUO files, however, they currently block all commits.

My understanding of DOS scripts is not that great, so I suspect it might be my use of FindStr?

Can anyone help?

"C:\Program Files\VisualSVN Server\bin\svnlook.exe" log -t %2 %1 | FindStr [a-zA-Z0-9]
IF %ERRORLEVEL% EQU 0 GOTO OK
echo "Commit Comments are Required" >&2
exit 1
:OK
"C:\Program Files\VisualSVN Server\bin\svnlook.exe" diff -t %2 %1 | FindStr /R "[a-zA-Z]\.suo"
IF %ERRORLEVEL% EQU 0 exit 0
echo "SUO files cannot be committed" >&2
exit 1
+3
source share
2 answers

findstr returns 0 if something is found, and 1 if nothing is found. You just flipped your check.

, Windows , :

>dir | findstr ".sln"
15.01.2009  16:37            33.844 Project.sln

>echo %ERRORLEVEL%
0

>dir | findstr ".slngimpf"

>echo %ERRORLEVEL%
1

Btw,

if errorlevel 0 andthencontinuewithwhatever

, script :

set errorlevel=0

% errorlevel%.

(edit) : , if errorlevel , . , , , :

someCommand
if errorlevel 10 ...
if errorlevel 9 ...
if errorlevel 0 ...
+5

, , *.suo global-ignores.

+3

Source: https://habr.com/ru/post/1703482/


All Articles