Subversion Repositories DevTools

Rev

Rev 4226 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

REM !/bin/sh

set REPOS=%1
set TXN=%2

set SVNLOOK="C:\Program Files (x86)\VisualSVN Server\bin\svnlook.exe"

REM does not contains /tags/ - allowed to commit
%SVNLOOK% changed -t %TXN% %REPOS% | findstr /r \/tags\/ >/nul
if not %errorlevel%==0 (goto AllowCommit)

REM contains /tags/
REM Only allow operations on directories
REM If not a directory then fail
%SVNLOOK% changed -t %TXN% %REPOS% | findstr /r \/tags\/ | findstr /r /c:".*\/\>" >/nul
if not %errorlevel%==0 (goto NotAllowed)

REM Have a directory only operation
REM End in .WIP/ then its allowed to ADD and DELETE
%SVNLOOK% changed -t %TXN% %REPOS% | findstr /r \/tags\/ | findstr /r /c:"\.WIP/\>" >/nul
if %errorlevel%==0 (goto AllowCommit)

REM Not a WIP
REM Only allowed to add
%SVNLOOK% changed -t %TXN% %REPOS% | findstr /B /V A >/nul
if not %errorlevel%==0 (goto AllowCommit)

REM Who is doing this
for /f %%i in ('%SVNLOOK% author -t %TXN% %REPOS%') do set AUTHOR=%%i
if %AUTHOR%==buildadm goto AllowCommit
rem if %AUTHOR%==dpurdie goto AllowCommit

:NotAllowed
echo>&2 User %AUTHOR% is not allowed to modify tags once they are created.
%SVNLOOK%>&2 changed -t %TXN% %REPOS%
exit 1

:AllowCommit
REM All checks passed, so allow the commit.
exit 0