Found one of the useful SVN pre-commit hook in SVN pre-commit hook for avoiding changes to tags subdirectories by mcdon.
I want to add the validation check on the user before committing. Can I do something like below?
@echo off
REM user1, user2, user3 are example
set VALID_USERS=user1,user2,user3
set SVNROOT="C:\Program Files\CollabNet Subversion Server\svnlook.exe"
set REPOS=%1%
set TXN=%2%
%SVNROOT% author %REPOS% -t %TXN% | findstr /r "^%VALID_USERS%$" >nul
if %errorlevel% EQU 0 (
echo This is an invalid user 1>&2
exit 1
) else (
echo This is valid user 1>&2
exit 0
)
The above pre-commit script failed as all users can commit their files. Also, the 'echo' command not working as I don't see any echo statement above. Can anyone help?
I don't understand why you should want a pre-commit hook for that, so I give you a sketch what we are using when working on tags.
We use the Subversion path-based authorization, and have rules like that:
so only admins are allowed to create and modify tags.
If necessary, we add for each tag a rule to avoid modification:
This works for us because tags are created seldomly, and we don't have much of them. We don't need any hooks to forbid something ...
Found the following solution working: