Subversion Repositories DevTools

Rev

Rev 4226 | Blame | Compare with Previous | Last modification | View Log | RSS feed

REM Maintained in package SubversionServerSupport
REM
REM Prevent changes to the /tags/ directory
REM MOST Users are allowed to create a tag, but not to delete or rename them
REM unless the tag ends in the key-text .WIP.
REM
REM Args %1 - Repo Path
REM      %2 - Transaction ID
set REPOS=%1
set TXN=%2

set SVNLOOK="%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)

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

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