简体   繁体   中英

Need Subversion pre-commit hook to block check-ins by a specific user

I have Subversion installed on Windows Server 2008. I want to add code to the pre-commit.bat to block commits by domain user jdoe on domain foo. What does that code look like? I am assuming it will use C:\\Program Files (x86)\\VisualSVN Server\\bin\\svnlook.

svnlook author , but do not engage in this nonsense - re-read about path-based authorization and revoke write access for needed user in needed area. Period.

This is my pre-commit.bat. It is ugly, but it works. The first check blocks commits that are missing a comment. The second check blocks commits by user jdoe.

@echo off
::    
:: Stops commits that have empty log messages.
::

@echo off

setlocal

rem Subversion sends through the path to the repository and transaction id
set REPOS=%1
set TXN=%2

rem check for an empty log message
"C:\Program Files (x86)\VisualSVN Server\bin\svnlook" log %REPOS% -t %TXN% | findstr . > nul
if %errorlevel% gtr 0 (goto err) else (goto nextcheck)

rem block commits by user jdoe
:nextcheck
"C:\Program Files (x86)\VisualSVN Server\bin\svnlook" author %REPOS% -t %TXN% > c:\windows\temp\author.txt
set /p authorcommitting=<c:\windows\temp\author.txt
if %authorcommitting%==jdoe (goto err1) else exit 0

:err
echo. 1>&2
echo Your commit has been blocked because you didn't supply a log message  1>&2
echo. 1>&2
echo Please add a log message describing the reason for your changes and 1>&2
echo then commit. 1>&2
echo. 1>&2
exit 1

:err1
echo. 1>&2
echo Commits are blocked for this user 1>&2
echo. 1>&2
exit 1

Please, read the VisualSVN Server Getting Started guide and the section Configuring User Permissions in particular.

VisualSVN Server offers a UI to manage the user permissions. You can use the VisualSVN Server Manager MMC console , PowerShell or RepoCfg to manage the permissions.

Don't forget that SVN server administrators and repository supervisors must understand the access control principles in Subversion. Read the article KB33: Understanding VisualSVN Server authorization for more information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM