i trying write pre-commit hook .bat script windows. code pasted below. runs file till line have written "issue here" below. trying in check if there content in file being checked-in. expectation if findstr able find console.log in file content errorlevel print value 0 , if console.log not found in file content errorlevel print 1. surprise prints 0 regardless of console.log found in file or not. please understand me issue.
thanks
set repos=%1 set txn=%2 rem check blank svn log comments. "svnlook.exe" log -t %txn% %repos% | findstr [a-za-z0-9] if %errorlevel% equ 0 goto ok echo "commit comments required" >&2 exit 1 :ok rem extract list of files committed temp.txt file. "svnlook.exe" changed -t %txn% %repos% >c:\temp.txt setlocal enabledelayedexpansion set count=1 rem loop thru each line of temp.txt file. /f "tokens=* delims= usebackq" %%x in ("%c:\temp.txt%") ( rem split token delimited space. second token file name. /f "tokens=1,2,3 delims= " %%a in ("%%x") set d=%%a&set filename=%%b rem content of file , redirect 1.txt "svnlook.exe" cat -t %txn% %repos% !filename! >c:\1.txt rem "issue here" find console.log string in content type c:\1.txt | findstr "console.log" rem print return value of above command. errorlevel prints 0 regardless of above findstr command finds "console.log" or not. echo errorlevel: %errorlevel% >&2 set /a count=!count!+1 ) endlocal exit 0
Comments
Post a Comment