通过 TortoiseSVN 提交时,如何强制我们的开发人员输入注释?

发布于 2024-08-15 18:57:35 字数 74 浏览 10 评论 0原文

我经常看到大量的提交,但没有引用票据的注释......所以我最终返回并手动检查差异。不一定是坏事,但如果有笔记就更好了。有什么想法吗?

I often see a slew of commits, but no notes referencing the tickets... And so I end up going back and reviewing the diff manually. Not necessarily bad, but it would be nice to have notes. Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

你的心境我的脸 2024-08-22 18:57:35

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

Not TortoiseSVN, but Subversion itself - a setting on the server. You can set up a pre-commit hook that enforces a commit comment. There are also pre-commit hooks that will verify the presence of a reference to an issue tracking system like Jira if you want to go one step further.

蓝礼 2024-08-22 18:57:35

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

这是帖子 关于如何去做。

You can define a pre-commit hook script which rejects all commits with an empty or too short log message.

Here is a post on how to do it.

小女人ら 2024-08-22 18:57:35

您需要使用预提交挂钩,它是一种服务器设置,我为 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

You need to use a pre-commit hook which is a server setting, I have written one for VisualSVN which is basically a batch file -- similar scripts are available for non-windows based SVN Servers.

@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
画离情绘悲伤 2024-08-22 18:57:35

当然可以,但是您将如何强制执行非胡言乱语、有意义且上下文相关的提交消息?

当你发现蹩脚/空洞的提交时,最好直接打你不负责任的同事。或者相当于“拳击”的口头表达。只要确保他们感觉不好,这是应得的。

Sure, but how are you going to enforce non-gibberish, meaningful and contextualized commit messages?

Better to just punch your irresponsible coworkers when you notice a lame/empty commit. Or the verbal equivalent of punch. Just make sure they feel bad, it's deserved.

江心雾 2024-08-22 18:57:35

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

fixes frobulator when the moon is full (bug 1234)

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

I have used a pre-commit hook script to ensure that a commit comment always refers to an issue number in the issue tracking system. For example, a comment such as

fixes frobulator when the moon is full (bug 1234)

would be accepted because it contains a bug number. Even with this arrangement, you still have to trust the developer to insert a meaningful comment and bug number.

岛徒 2024-08-22 18:57:35

我们的预提交钩子脚本(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 )

Our pre-commit hookscript (windows batch):

@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 )
笑忘罢 2024-08-22 18:57:35

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

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

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

You can force a commit comment easily enough, but what you'll end up with is a million commits that say "debugging" or "testing".

If your developers don't see the value in adding commit messages forcing them to type something is not going to change that.

What's worse is when Eclipse users have SVN/CVS integrated such that it remembers their last commit message - and they end up committing a completely unrelated file with the message from their last task/project.

空宴 2024-08-22 18:57:35

TortoiseSVN 是一个客户端,您可能需要 在颠覆服务器上强制评论
或者你可以告诉他们评论他们的提交。

TortoiseSVN is a client, you might want to force comments on the subversion server.
Or you can tell them to comment their commits.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文