Pre-commit problem

akuccputsedut
akuccputsedut
Hi All..I'm new to svn  Now I want to set pre-commit to makesure user keyin comment before commit in svn. I already create a pre-commit.bat with below script in repository/hooks  @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    rem check for an empty log message  svnlook log %REPOS% -t %TXN% | findstr . > nul  if %errorlevel% gtr 0 (goto err) else exit 0    :err  echo. 1>&2  echo Your commit has been blocked because you didn't give any log message 1>&2  echo Please write a log message describing the purpose of your changes and 1>&2  echo then try committing again. -- Thank you 1>&2  exit 1  but it's still not working..is that I am missing any step or my script is wrong or anything to add more inside my script. Please anybody help me...

Last updated

JNiven
JNiven
Hi akuccputsedut    Hook scripts run with no environment, hence no %PATH%. You'll need to provide a full path to svnlook (e.g. "C:\Program Files\Subversion\svnlook" instead of just "svnlook").    Cheers  John
akuccputsedut
akuccputsedut
thanks JNiven...so u means my script look fine, only need to put full path to svnlook..
akuccputsedut
akuccputsedut
@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    rem check for an empty log message  "C:\Program Files\Subversion Server\svnlook.exe" log %REPOS% -t %TXN% | findstr . > nul  if %errorlevel% gtr 0 (goto err) else exit 0    :err  echo. 1>&2  echo Your commit has been blocked because you didn't give any log message 1>&2  echo Please write a log message describing the purpose of your changes and 1>&2  echo then try committing again. -- Thank you 1>&2  exit 1    after I'll tried it out it trown out and error after sucessful commit...          where i'm do wrong..?? please help...
JNiven
JNiven
Hi akuccputsedut    "#!" is the usual content of the first two characters of the first line of a Unix shell script (after the "#!" the script would then specify an interpreter, eg. "/bin/bash" if the script is a "Bource Again" shell script, for example).    If you check the output you posted, you'll see that it's at the *post-commit* stage - your *pre-commit* hook ran fine, but a post-commit hook then ran, and failed because Windows didn't know how to interpret it.    Check your hooks directory, and make sure that only the hooks you want to run are named correctly - other hooks should have a ".tmpl" extension.    Cheers  John
akuccputsedut
akuccputsedut
 this is how my hooks folder looks like...is it correct.???  and below is post-commit script    @ECHO OFF  REM Set all parameters. Even though most are not used, in case you want to add  REM changes that allow, for example, editing of the author or addition of log messages.  set LOGPATH=d:\logs\subversion  set repository=%1  set revision=%2  set userName=%3  set propertyName=%4  set action=%5  set SVNSYNC="C:\Program Files\CollabNet\Subversion Server\svnsync.exe"  set MIRROR="svn://5.5.5.118/"  echo "post-commit hook: calling synchronise on mirror: %MIRROR%" >> %LOGPATH%\hook.log  %SVNSYNC% synchronize %MIRROR% --username=svnsync --password=svnsync-password    and still error on post-commit hook failed (exit code 1) with output: this error that thrown out after I remove all # in my script        please help...
JNiven
JNiven
Hi akuccputsedut    First things first: when you first posted the issue was with your pre-commt hook: is that now resolved? You seem to have disabled your pre-commit hook script...    Turning to your post-commit hook script: follow the usual process for debugging a script. Turn "echo" back on (comment-out the first line, thus:rem @ECHO OFF). Then note at what point the script fails.    Your script seems to expect four arguments. Post-commit hooks only receive two (http://svnbook.red-bean.com/nightly/en/svn.ref.reposhooks.post-commit.html). Without knowing more about where your script fails, my first instinct would be to look at userName=%3 and propertyName=4%. I'm not familiar with scripting on Windows, but is %X the right syntax? I thought Windows tended to use %X% for shell expansion?    Regardless, your first step is to determine where your post-commit script is failing - that'll give you valuable help in determining *why* the script is failing.    Cheers  John

1-7 of 7

Reply to this discussion

You cannot edit posts or make replies: You should be logged in before you can post.