svn強制commit寫log


https://tortoisesvn.net/docs/nightly/TortoiseSVN_en/tsvn-howto-minlogmsgsize.html

Force users to enter a log message

There are two ways to prevent users from committing with an empty log message. One is specific to TortoiseSVN, the other works for all Subversion clients, but requires access to the server directly.

Hook-script on the server

If you have direct access to the repository server, you can install a pre-commit hook script which rejects all commits with an empty or too short log message.

In the repository folder on the server, there's a sub-folder hooks which contains some example hook scripts you can use. The file pre-commit.tmpl contains a sample script which will reject commits if no log message is supplied, or the message is too short. The file also contains comments on how to install/use this script. Just follow the instructions in that file.

This method is the recommended way if your users also use other Subversion clients than TortoiseSVN. The drawback is that the commit is rejected by the server and therefore users will get an error message. The client can't know before the commit that it will be rejected. If you want to make TortoiseSVN have the OK button disabled until the log message is long enough then please use the method described below.

Project properties

TortoiseSVN uses properties to control some of its features. One of those properties is the tsvn:logminsize property.

If you set that property on a folder, then TortoiseSVN will disable the OK button in all commit dialogs until the user has entered a log message with at least the length specified in the property.

For detailed information on those project properties, please refer to the section called “Project Settings”.

 

具體操作

# On a Windows system, you should name the hook program
# 'pre-commit.bat' or 'pre-commit.exe',
# but the basic idea is the same.

需要注意的是, pre-commit.tmpl僅存在於具體的svn的repository中,並不存在於visual svn server的安裝目錄下。

直接使用everything,搜索pre-commit。然后按照文件內的說明,重命名為bat文件。結果發現默認的不能用

找到如下的腳本,直接將內容復制,然后覆蓋原來的內容

 https://stackoverflow.com/questions/1928023/how-can-i-prevent-subversion-commits-without-comments

You can use a hook (put it into <repository>/hooks and name it pre-commit.bat (Windows)):

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

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
svnlook log %REPOS% -t %TXN% | findstr . > nul
if %errorlevel% gtr 0 (goto err) else exit 0

:err
echo. 1>&2
echo Your commit has been blocked because you didn't give any log message 1>&2
echo Please write a log message describing the purpose of your changes and 1>&2
echo then try committing again. -- Thank you 1>&2
exit 1

src: http://www.anujgakhar.com/2008/02/14/how-to-force-comments-on-svn-commit/

 

遇到問題'svnlook' is not recognized as an internal or external command,

https://serverfault.com/questions/165663/svnlook-is-not-recognized-as-an-internal-or-external-command-visualsvn-server

1.把這個目錄配置到環境變量

C:\Program Files (x86)\VisualSVN Server\bin

2.然后重啟VisualSvnServer這個windows service

 

如果svn的repository太多的話,可以寫一個腳本,來自動復制pre-commit.bat

http://kockerbeck.blogspot.com/2010/08/require-comment-message-on-all-svn.html

@ECHO OFF
:: ------ SVN Deploy Hooks ------
:: ----- by Mark Kockerbeck  ----

:: ------ Configuration ---------
SET HookDirectory=C:\CommonHooks
SET RepositoryDirectory=C:\Repositories
:: ------ /Configuration --------

pushd %HookDirectory%
for /r %%i in (*) do (
 for /D %%j in (%RepositoryDirectory%\*) do (
  echo Copying %%i to %%j\hooks\
  copy %%i %%j\hooks\
 )
)
popd

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM