[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Hook scripts for win32

From: Peter McNab <mcnab_p_at_melbpc.org.au>
Date: 2005-05-04 01:32:57 CEST

Glenn R Heard Jr wrote:

>Does anyone have any good hook scripts for win32?
>
>
>
Glenn.

I have a pre-commit hook to disallow commits without comments and
another to allow editing of comments.
 
--------------------
pre-commit.bat
--------------------
@echo off
rem Add path to Subversion executable
set path=%path%;c:\Program Files\Subversion\bin
rem Add path to grep.exe
set path=%path%;c:\Program Files\Borland\Delphi7\Bin
Date /T >> D:\pre-commit.log
Time /T >> D:\pre-commit.log
echo %CMDCMDLINE% >> D:\pre-commit.log
SVNLOOK.exe log -t "%2" "%1" | grep.exe "[a-zA-Z0-9]" > nul || exit 1
echo Committed OK >> D:\pre-commit.log
exit 0

Note. I log commit attempts as shown by the lines containing >>
These can safely be removed.

--------------------
pre-revprop-change.bat
--------------------
@echo off
rem Add path to Subversion executable
set path=%path%;c:\Program Files\Subversion\bin
rem Add path to grep.exe
set path=%path%;c:\Program Files\Borland\Delphi7\Bin
Date /T >> D:\pre-commit.log
Time /T >> D:\pre-commit.log
echo %CMDCMDLINE% >> D:\pre-commit.log
SVNLOOK.exe log -t "%2" "%1" | grep.exe "[a-zA-Z0-9]" > nul || exit 1
echo Committed OK >> D:\pre-commit.log
exit 0

Note. grep.exe on my NT4.0 machine is from my Delphi7 installation,
hence the path

Then, two simple batch files to deploy the scripts. These reside on the
C: drive and the repositories are in D:\svn
reposinit creates a new respoitory and deploys the hook scripts.
Note. I am using the fsfs repository type.

--------------------
reposinit.bat
--------------------
@echo off
if NOT "%1"=="" goto checkname
echo Usage:-
echo reposinit new-repository-name
goto end
:checkname
if not exist d:\svn\%1 goto makerepos
echo Repository %1 already exists.
goto end
:makerepos
d:
cd\svn
svnadmin create --fs-type fsfs %1
if exist d:\svn\%1 goto good
echo Repository %1 failed to create.
goto end
:good
if not exist d:\svn\%1\hooks goto done
if exist d:\svn\pre-revprop-change.bat copy
d:\svn\pre-revprop-change.bat d:\svn\%1\hooks\
if exist d:\svn\pre-commit.bat copy d:\svn\pre-commit.bat d:\svn\%1\hooks\
echo Success. Repository %1 created and pre-revprop-change.bat copied to
hooks folder.
goto end
:done
echo Success. Repository %1 created hook file (pre-revprop-change.bat)
not copied.
:end
cd\
c:

And finally UpdateAll.bat re-deploys the scripts to all repositories in
the event that they need changing.

--------------------
UdateAll.bat
--------------------
rem batch file to put hook script into hook folders
@echo off
echo Update hook scripts >> d:\svn\UpdateAll.log
for /D %%f in (D:\svn\*.*) do if exist %%f\hooks\nul echo %%f\hooks >>
d:\svn\UpdateAll.log
for /D %%f in (D:\svn\*.*) do if exist %%f\hooks\nul copy
d:\svn\pre-revprop-change.bat %%f\hooks\
for /D %%f in (D:\svn\*.*) do if exist %%f\hooks\nul copy
d:\svn\pre-commit.bat %%f\hooks\
echo Finished Updating hook scripts >> d:\svn\UpdateAll.log
:end

Peter

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Wed May 4 01:35:15 2005

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.