computing
  • 2

How To Avoid Error FINDSTR: // Ignored

  • 2

I have written a pre-commit.bat file to find string “I have tested” in commit message, the FINDSTR works fine, whoever, if the function does not find a string, it will give error message. most part error message is correct, but I don’t understand why this is in error message “FINDSTR: // ignored”, how can I advoid it?
Question 2 is, when commit an added file, I need to check if the property svn:needs-lock is set or not. However, I don’t know what is the correct syntex to check the file extention right now I am using: for /f “usebackq” %%i in (`findstr /E /I /R “\.*.$” %TEMP%\tempfile%2`) does not give warning or error message. Also, If the file does not have the property svn:needs-lcok, how do I set the lock property to the commited file. Some help on these will be greatly appreciated.
Thank you
Lynda
Here is the script:

@echo off
:: Stops commits that have empty log messages.
REM >nul redirect output to the NULL device, no screnn print out
REM /i ignore case /c search string
@echo off

setlocal

rem Subversion sends through the path to the repository and transaction id
set REPOS=%1
set TRANSACTION=%2
set svnlook_why =”C:\Program Files\BitNamiTrac\subversion\bin\svnlook.exe”
set TEMP =”C:\Program Files\BitNamiTrac\subversion\tmp”

svnlook log %REPOS% -t %TRANSACTION% | findstr /i/c:”I have tested” >nul
if %errorlevel% gtr 0 (goto err)

if exist %TEMP%\temfile%2 del %TEMP%\tempfile%2
for /f “tokens=1,2 usebackq” %%i in (`svnlook changed -t %2 %1`) do @if %%i==A @echo %%j >> %TEMP%\tempfile%2

Rem for /f “usebackq” %%i in (`findstr /E /I /R “\.vb.$ \.cs.$ \.aspx.$ \.*.$ \.bmp.$ \.gif.$ \.ico.$ \.jpeg.$ \.jpg.$ \.png.$ \.tif.$ \.tiff.$ \.doc.$ \.jar.$ \.odt.$ \.pdf.$ \.ppt.$ \.swf.$ \.vsd.$ \.xls.$ \.zip.$” %TEMP%\tempfile%2`) do (
for /f “usebackq” %%i in (`findstr /E /I /R “\.*.$” %TEMP%\tempfile%2`) do (

svnlook propget -t %2 %1 svn:needs-lock %%i 1> nul 2> nul
if ERRORLEVEL 1 (
echo commit denied, binary files must have property svn:needs-lock >&2
type %TEMP%\tempfile%2 >&2
del %TEMP%\tempfile%2
EXIT /B 1
)
)
del %TEMP%\tempfile%2
:NOFILESADDED
EXIT /B 0

exit 0

:err
echo Sorry,
echo Your commit has been blocked because you have not included 1>&2
echo “I have tested” 1>&2
echo in your comment. 1>&2
echo Only tested files are allowed to commit to the repository 1>&2
echo Thank you!. 1>&2

exit 1

Share

1 Answer

  1. “As for the question 2, can I just ask you about the syntax of search all file extension? is it correct?
    for /f “usebackq” %%i in (`findstr /E /I /R “\.*.$” %TEMP%\tempfile%2″”

    That will basically pick up everything with a dot, for file extensions I would use:

    findstr /e /r "\..*."
    

    But it can still pickup false positives.

    “as for add property, I found this script to add every file svn:needs-lock property:
    FOR /R E:\BitNamiTracRepository %%v in (*.*) do svn propset svn:needs-lock yes %%~fv

    I need to modify it so that it fits my purpose. I do not understand %%v means and %%~fv.”

    I suggest you read “for /?”

    for /r – Iterates over every subdirectory of the directory(in this case E:\BitNamiTracRepository) specified and does the command after do.

    %%v – this is just the variable that is being used, in this case it will hold each filename once. it will change every time the loop iterates.

    %%~fv – The ~f is a modifier to the variable that means it will expand to a fully qualified file name.

    in (*.*) – this means every file(except hidden files, ect.) will

    svn propset svn:needs-lock yes %%~fv – the command that will be executed with every filename(in place of %%~fv).

    Batch Variable how to

    • 0