SVNServer常用HOOK
svn server 可通过hook的方式 来自定义SVN 行为控制,这里列几个常用的。
1.限制单个提交文件大小不超过100MB
Pre-commit hook @echo off setlocal enabledelayedexpansion set REPOS=%1 set TXN=%2 rem MAX_SIZE value is byte set MAX_SIZE=104857600 for /f "delims=" %%a in ('svnlook changed -t %TXN% %REPOS%') do ( set var=%%a for /f %%i in ('svnlook filesize -t %TXN% %REPOS% !var:~4!') do ( if %%i gtr %MAX_SIZE% ( set /a size=%%i/1024 echo file size upto limit 100MB. File: !var:~4! Size: !size!KB 1>&2 exit 1 ) ) ) exit 0
2.可修改提交记录
Pre-revision property change hook SET REPOS="%1" SET REV="%2" SET USER="%3" SET PROPNAME="%4" SET ACTION="%5" IF %ACTION% == "M" (IF %PROPNAME% == "svn:log" (EXIT 0)) ECHO "Changing revision properties %PROPNAME% is prohibited" >&2 EXIT 1
这些脚本都是 批处理(.sh .bat)的脚本 不同的操作系统下hook代码是不一样的。