Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
4226 dpurdie 1
REM Maintained in package SubversionServerSupport
2
REM
3
REM Prevent changes to the /tags/ directory
4
REM MOST Users are allowed to create a tag, but not to delete or rename them
5
REM unless the tag ends in the key-text .WIP.
6
REM
7
REM Args %1 - Repo Path
8
REM      %2 - Transaction ID
1291 dpurdie 9
set REPOS=%1
10
set TXN=%2
11
 
12
set SVNLOOK="C:\Program Files (x86)\VisualSVN Server\bin\svnlook.exe"
13
 
14
REM does not contains /tags/ - allowed to commit
15
%SVNLOOK% changed -t %TXN% %REPOS% | findstr /r \/tags\/ >/nul
16
if not %errorlevel%==0 (goto AllowCommit)
17
 
18
REM contains /tags/
19
REM Only allow operations on directories
20
REM If not a directory then fail
21
%SVNLOOK% changed -t %TXN% %REPOS% | findstr /r \/tags\/ | findstr /r /c:".*\/\>" >/nul
22
if not %errorlevel%==0 (goto NotAllowed)
23
 
24
REM Have a directory only operation
25
REM End in .WIP/ then its allowed to ADD and DELETE
26
%SVNLOOK% changed -t %TXN% %REPOS% | findstr /r \/tags\/ | findstr /r /c:"\.WIP/\>" >/nul
27
if %errorlevel%==0 (goto AllowCommit)
28
 
29
REM Not a WIP
30
REM Only allowed to add
31
%SVNLOOK% changed -t %TXN% %REPOS% | findstr /B /V A >/nul
32
if not %errorlevel%==0 (goto AllowCommit)
33
 
4226 dpurdie 34
:NotAllowed
1291 dpurdie 35
REM Who is doing this
36
for /f %%i in ('%SVNLOOK% author -t %TXN% %REPOS%') do set AUTHOR=%%i
37
if %AUTHOR%==buildadm goto AllowCommit
4226 dpurdie 38
if %AUTHOR%==dpurdie goto AllowCommit
1291 dpurdie 39
 
40
echo>&2 User %AUTHOR% is not allowed to modify tags once they are created.
41
%SVNLOOK%>&2 changed -t %TXN% %REPOS%
42
exit 1
43
 
44
:AllowCommit
45
REM All checks passed, so allow the commit.
46
exit 0