I'm trying to get a pre-commit hook script to work on our old SVN box. It's very old, running Ubuntu Server 8.04.
This script: @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
I think it's not working because the command findstr does not exist. What does work is this:
if [[ -n "" ]] ; then echo "yes"; else echo "no"; fi
So I changed the script to:
@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 (goto exitgood)
::svnlook log %REPOS% -t %TXN% | findstr . > ""
::if %errorlevel% gtr 0 (goto err) else (goto exitgood)
SET LOG=`svnlook log %REPOS% -t %TXN%`
if [[ -n %LOG% ]]; then
(goto exitgood)
else
(goto err)
fi
: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
:exitgood
exit 0
But that doesn't work either, they both exit with code 255. Can somebody tell me what I'm doing wrong?
cmd.exe
batch scripts. What are they doing on your Linux box? – Mat May 7 at 9:52