-1

I want to force commit comment so I make a pre-commit.bat and setting under hook folder It's working well abort no comment commit message. but I have a problem that i can't see any error message from svn server.

my environment is windows7 and use eclipse, subversion

and server os is windows server 2008

and pre-commit.bat source is

@echo off
:: Stops commits that have empty log messages.
@echo off

setlocal

REM Subversion sends through the path to the repository and transaction id
SET "REPOS=%~1"
SET "TXN=%~2"
SET "SVNLOOK=C:\Progra~\Subversion\bin\svnlook.exe"

for /f "tokens=1 delims=/" %%i in ('%SVNLOOK% log -t "%TXN%" "%REPOS%"') do set "COMMENT=%%i"
if "%COMMENT%" == "" (goto comment_err)

for /f "tokens=2 delims=/" %%j in ('%SVNLOOK% log -t "%TXN%" "%REPOS%"') do set "ID=%%j"
if "%ID%" == "" (goto id_err)

for /f "tokens=3 delims=/" %%k in ('%SVNLOOK% log -t "%TXN%" "%REPOS%"') do set "MYDATE=%%k"
if "%MYDATE%" == "" (goto date_err)


exit 0


:comment_err
echo. 1>&2
echo Committing has been blocked! 1>&2
echo Because comment is empty! 1>&2
echo Please write a comment and try committing again. 1>&2
echo Message format is [comment]/[author]/[YYYY-MM-DD] 1>&2
echo Thank you 1>&2
exit 1

:id_err
echo. 1>&2
echo Committing has been blocked! 1>&2
echo Because author is empty! 1>&2
echo Please write a author and try committing again. 1>&2
echo Message format is [comment]/[author]/[YYYY-MM-DD] 1>&2
echo Thank you 1>&2
exit 1

:date_err
echo. 1>&2
echo Committing has been blocked! 1>&2
echo Because date is empty! 1>&2
echo Please write a date and try committing again. 1>&2
echo Message format is [comment]/[author]/[YYYY-MM-DD] 1>&2
echo Thank you 1>&2
exit 1

ps. I already check. echo "text" 1>&2 and It's very strange things. when i test on local the error message is dispalying well. but i set on my svn server. I can't see any error message on my eclipse.

1 Answers1

0

There are two possible culprits here: your script, or Eclipse. We need to narrow down the problem before we can solve it.

Try a commit from the command-line svn client and see if you can see the error message. If you can, then your script should be fine and the problem is with Eclipse.

If you don't see it on the command-line, then there's a problem in your script. I'd recommend replacing the script with a simple placeholder:

echo Fail 1>&2
exit 1

If you can see this output from the command-line client, then there's probably a logic problem in your script. You're trying to do string parsing in batch, which is notoriously difficult. I recommend writing a script/program in a higher-level language to do that part, and have your batch script simply check the return value for success or failure.

If you still can't see the error message with the placeholder script, then you have some sort of problem piping communication between the script running on your server and the client. If this is the case, then I recommend turning your server's error logging up to max, re-running the test, and inspecting the Subversion logs for hints to the problem.

A general comment on the log format that you're trying to enforce: you shouldn't need to put the author or date in the commit message. Subversion already keeps track of that for you. If the author/date in the log don't match what the repository recorded, it's hard to know which to trust.

bta
  • 43,959
  • 6
  • 69
  • 99
  • Thanks..your relpy. but I haven't solved the problem. If I set svn repository on my local. I can see the message in eclipse but set on server. I can see that. and I already test simple echo message. but i can't see the message I think piping communication problem, so if you can... explain detail. Thank you again your reply – Shin DongWoo Aug 28 '15 at 01:17
  • @ShinDongWoo Do the Subversion server's logs have any relevant information in them? Also, what OS is running on the server and on your local machine? – bta Aug 28 '15 at 15:26