6

我经常看到大量提交,但没有注释引用票证......所以我最终回去手动查看差异。不一定是坏事,但有笔记会很好。有任何想法吗?

4

8 回答 8

6

不是 TortoiseSVN,而是 Subversion 本身——服务器上的一个设置。您可以设置一个强制提交注释的预提交挂钩。如果您想更进一步,还有预提交挂钩可以验证是否存在对 Jira 等问题跟踪系统的引用。

于 2009-12-18T19:49:30.327 回答
5

您可以定义一个预提交挂钩脚本,该脚本拒绝所有带有空或太短日志消息的提交。

这是一篇关于如何做到这一点的帖子。

于 2009-05-04T23:55:30.247 回答
3

您需要使用作为服务器设置的预提交挂钩,我已经为 VisualSVN 编写了一个,它基本上是一个批处理文件——类似的脚本可用于非基于 Windows 的 SVN 服务器。

@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
call "C:\program files\visualsvn server\bin\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
于 2009-12-18T19:56:35.930 回答
2

当然可以,但是你将如何强制执行非乱码、有意义和上下文相关的提交消息?

当你发现一个蹩脚/空洞的提交时,最好只打你不负责任的同事。或相当于打孔的语言。只要确保他们感觉不好,这是应得的。

于 2009-05-04T23:55:25.427 回答
1

我使用了预提交挂钩脚本来确保提交注释始终引用问题跟踪系统中的问题编号。例如,评论如

修复满月时的 frobulator (bug 1234)

将被接受,因为它包含一个错误编号。即使采用这种安排,您仍然必须相信开发人员会插入有意义的注释和错误编号。

于 2009-05-04T23:58:47.837 回答
1

我们的预提交钩子脚本(Windows 批处理):

@echo off & setlocal ENABLEEXTENSIONS

set SVNLOOK="E:\Subversion\Program\Subversion 1.5.0\bin\svnlook.exe"

set REPOS=%1%
set TXN=%2%
set LOGFILE=%REPOS%\hooks\log-%TXN%.txt
set GREP=E:\UnxUtils\usr\local\wbin\grep.exe

%SVNLOOK% log -t "%TXN%" "%REPOS%" >%LOGFILE%

set "first="
for /f "delims=" %%a in ('more ^< "%LOGFILE%"') do (
  if not defined first set first=%%a
)

del %LOGFILE%

if not defined first ( echo "Please supply a commit comment" >&2 & exit 1 )





REM Check for invalid windows characters in the path
echo Checking >%LOGFILE%
%SVNLOOK% changed -t "%TXN%" "%REPOS%" | find "\" >>%LOGFILE%
%SVNLOOK% changed -t "%TXN%" "%REPOS%" | find ":" >>%LOGFILE%
%SVNLOOK% changed -t "%TXN%" "%REPOS%" | find "*" >>%LOGFILE%
%SVNLOOK% changed -t "%TXN%" "%REPOS%" | find "?" >>%LOGFILE%
%SVNLOOK% changed -t "%TXN%" "%REPOS%" | find """" >>%LOGFILE%
%SVNLOOK% changed -t "%TXN%" "%REPOS%" | find "^>" >>%LOGFILE%
%SVNLOOK% changed -t "%TXN%" "%REPOS%" | find "^<" >>%LOGFILE%
%SVNLOOK% changed -t "%TXN%" "%REPOS%" | find "^|" >>%LOGFILE%

set "first="
for /f "delims=" %%a in ('more +1 ^< "%LOGFILE%"') do (
  if not defined first set first=%%a
)

del %LOGFILE%

if defined first ( echo "Please do not use filename characters which are invalid in  windows. - Found %first%" >&2 & exit 1 )






REM Tagblock - prevent changes to tag directories
echo Checking >%LOGFILE%
%SVNLOOK% changed -t "%TXN%" "%REPOS%" | %GREP% "^U.*\/tags\/.*" | %GREP% -v -f "%REPOS%\conf\tag-block-exceptions.txt" >>%LOGFILE%

set "first="
for /f "delims=" %%a in ('more +1 ^< "%LOGFILE%"') do (
  if not defined first set first=%%a
)

del %LOGFILE%


if defined first ( 
    echo "%first% -- Error: Modifications to tag directories are blocked. To allow these modifications add the path to %REPOS%\conf\tag-block-exceptions.txt" >&2 
    exit 1 )
于 2009-05-05T08:19:20.923 回答
1

你可以很容易地强制提交评论,但你最终会得到一百万个说“调试”或“测试”的提交。

如果您的开发人员没有看到添加提交消息的价值,强制他们输入内容并不会改变这一点。

更糟糕的是,当 Eclipse 用户集成了 SVN/CVS 时,它会记住他们最后的提交消息——他们最终会提交一个与上一个任务/项目中的消息完全不相关的文件。

于 2009-12-18T19:59:33.427 回答
0

TortoiseSVN 是一个客户端,你可能想在 subversion 服务器上强制注释。或者你可以告诉他们评论他们的提交。

于 2009-12-18T19:52:06.297 回答