how to advoid error FINDSTR: // ignored

Microsoft Windows ultimate 64-bit 7
January 21, 2010 at 11:43:08
Specs: Windows Server 2008, intel core 2 3.0ghz
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


See More: how to advoid error FINDSTR: // ignored

Report •


#1
January 21, 2010 at 11:51:29
svnlook log %REPOS% -t %TRANSACTION% | findstr /i/c:"I have tested" >nul

Try adding a space between /i and /c, some commands(like dir) will take options that way, findstr doesn't seem to like it so much.

A side note: If you ever need to actually search for "//" with findstr, escape with backslashes "\/\/".


Batch Variable how to


Report •

#2
January 21, 2010 at 12:00:17
Oh, I forgot to mention you lost me on question 2. "svn:needs-lock", you say it's a property of a file, but I have even less chance of knowing how to check for it than you do, seeing as I don't even know what it is that you are referring to....


Batch Variable how to


Report •

#3
January 21, 2010 at 12:17:09
Thank you so much for quick reply! Yes, add space bettwen \i and \c resolved the problem.
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

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. Anyway, I will try to experiment it, and will post back.
Thank again for your kind and quick help. I am trying to leanr bact programming now.
best Regards
lynda


Report •

Related Solutions

#4
January 21, 2010 at 12:45:31
"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


Report •

#5
January 21, 2010 at 13:47:01
Thank you very much! I changed to findstr /e /r "\..*." it works great.
The svn propset still does not work. I am still testing.
Best regards
Lynda

Report •

#6
January 21, 2010 at 14:04:05
After some research I found that it is bad practice to modify in progess commit transaction. So I give up trying to set svn:needs-lock to committed file in the pre-commit process.
Thank you for helping me.
Best Rgeards
Lynda

Report •


Ask Question