【发布时间】:2012-04-27 15:50:22
【问题描述】:
我想阻止我的 SVN 存储库的用户签入对某些文件的更改。我通过使用以下预提交钩子脚本完成了这项工作。然而,受限文件的数量正在增长,提交更改变得非常缓慢。我想知道是否有更有效的编码方式,我玩过更改列表,但无法完成。
提前致谢
预提交挂钩脚本(基于 Windows 的 SVN 存储库):
setlocal
:: Inputs from Subversion
set REPOS=%1%
set TXN=%2%
:: Checks if one of the reference files
Rem Check if the commit contains reference files
svnlook changed %REPOS% -t %TXN% | findstr /r /i "^.*referenceparts/part1.txt" > nul
if %errorlevel%==0 (goto RefPart)
svnlook changed %REPOS% -t %TXN% | findstr /r /i "^.*referenceparts/part2.txt" > nul
if %errorlevel%==0 (goto RefPart)
......
.....
etc etc
exit 0
:: Blocks the commit if part are reference
: RefPart
echo. 1>&2
echo ---------------------------------------------------------------------- 1>&2
echo Your commit has been cancelled because you are trying to change a 1>&2
echo part for a reference turbine! Please make a copy of this part and 1>&2
echo save it under a different name. 1>&2
echo ---------------------------------------------------------------------- 1>&2
echo. 1>&2
exit 1
【问题讨论】:
-
你可能应该找到一种不同的方法来锁定文件,但也许只做一个
svnlook changed %REPOS% -t %TXN%可能会有所帮助(我不知道那是瓶颈还是 findstr)。
标签: svn pre-commit-hook