Subversion Repositories DevTools

Rev

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

REM Maintained in package SubversionServerSupport
REM
REM Limit the property chnages that a user can make to:
REM     svn:log (commit comment)
REM     Made by themselves only
REM     On the same day    
REM                     [Now allow change to log made on any day]
REM
REM Args %1 - Repo Path
REM      %2 - Rev to be changed
REM      %3 - Authenticated user name
REM      %4 - Name of property to be changed
REM      %5 - Change Type. A,D or M

REM     These users can do anything
if %3==xdpurdie goto OK
if %3==buildadm goto OK

REM
REM     The rest of this code allows a user to modify his own svn:log (comment) created
REM     today. The date test is brute force.

REM     Allow log comments to be modified
if NOT %4==svn:log goto BAD
if NOT %5==M goto BAD

set SVNLOOK="%VISUALSVN_SERVER%bin\svnlook.exe"

REM     User can only modify his own comments
set muser=error
for /f "delims=" %%a in ('%SVNLOOK%  author -r %2 %1 ') do @set muser=%%a
if NOT %muser%==%3 goto BADUSER

REM     User is allowed to modify comment [Age not longer considered]
goto OK

REM     User can only modify comments made on the same day
set datestamp=error
set today=error

for /f "delims=" %%a in ('%SVNLOOK%  date -r %2 %1 ') do @set datestamp=%%a
set datestamp=%datestamp:~0,10%

for /F "tokens=1-4 delims=/ " %%a in ("%date%") do (
 set YEAR=%%d
 set MONTH=%%c
 set DAY=%%b )
set today=%YEAR%-%MONTH%-%DAY%
if NOT %today%==%datestamp% goto BADDAY

REM     User is allowed to modify comment
goto OK

:BADDAY
echo User %3 is only allowed to modify svn:log created on the same day >&2
echo Info. Change User: %muser%. Change Date: %datestamp%. Today: %today%. %date% >&2
exit 1

:BADUSER
echo User %3 is not allowed to modify svn:log created by another user (%muser%) on %1 >&2
exit 1

:BAD
echo User %3 is not allowed to modify repository properties %4(%5) on %1 >&2
exit 1

:OK
exit 0