| 1291 |
dpurdie |
1 |
REM !/bin/sh
|
|
|
2 |
|
|
|
3 |
set REPOS=%1
|
|
|
4 |
set TXN=%2
|
|
|
5 |
|
|
|
6 |
set SVNLOOK="C:\Program Files (x86)\VisualSVN Server\bin\svnlook.exe"
|
|
|
7 |
|
|
|
8 |
REM does not contains /tags/ - allowed to commit
|
|
|
9 |
%SVNLOOK% changed -t %TXN% %REPOS% | findstr /r \/tags\/ >/nul
|
|
|
10 |
if not %errorlevel%==0 (goto AllowCommit)
|
|
|
11 |
|
|
|
12 |
REM contains /tags/
|
|
|
13 |
REM Only allow operations on directories
|
|
|
14 |
REM If not a directory then fail
|
|
|
15 |
%SVNLOOK% changed -t %TXN% %REPOS% | findstr /r \/tags\/ | findstr /r /c:".*\/\>" >/nul
|
|
|
16 |
if not %errorlevel%==0 (goto NotAllowed)
|
|
|
17 |
|
|
|
18 |
REM Have a directory only operation
|
|
|
19 |
REM End in .WIP/ then its allowed to ADD and DELETE
|
|
|
20 |
%SVNLOOK% changed -t %TXN% %REPOS% | findstr /r \/tags\/ | findstr /r /c:"\.WIP/\>" >/nul
|
|
|
21 |
if %errorlevel%==0 (goto AllowCommit)
|
|
|
22 |
|
|
|
23 |
REM Not a WIP
|
|
|
24 |
REM Only allowed to add
|
|
|
25 |
%SVNLOOK% changed -t %TXN% %REPOS% | findstr /B /V A >/nul
|
|
|
26 |
if not %errorlevel%==0 (goto AllowCommit)
|
|
|
27 |
|
|
|
28 |
REM Who is doing this
|
|
|
29 |
for /f %%i in ('%SVNLOOK% author -t %TXN% %REPOS%') do set AUTHOR=%%i
|
|
|
30 |
if %AUTHOR%==buildadm goto AllowCommit
|
|
|
31 |
rem if %AUTHOR%==dpurdie goto AllowCommit
|
|
|
32 |
|
|
|
33 |
:NotAllowed
|
|
|
34 |
echo>&2 User %AUTHOR% is not allowed to modify tags once they are created.
|
|
|
35 |
%SVNLOOK%>&2 changed -t %TXN% %REPOS%
|
|
|
36 |
exit 1
|
|
|
37 |
|
|
|
38 |
:AllowCommit
|
|
|
39 |
REM All checks passed, so allow the commit.
|
|
|
40 |
exit 0
|