Integration with Bug Tracking Systems / Issue Trackers

在软件开发中,修改依赖于一个bug或问题编号是很常见的。bug跟踪系统的用户(问题跟踪者)喜欢在问题跟踪中将Subversion的修改与一个指定编号联系起来。因此很多问题跟踪者提供了一个预提交钩子脚本,分析日志,查找提交相关的bug编号。这稍微有些不可靠,因为它依赖于用户写完全的日志,预提交钩子才能正确分析。

TortoiseSVN可以在两个方面帮助用户:

  1. 当用户输入日志信息时,一个定义良好,包含问题编号,与此提交相关的的行,会自动增加。这样减少了用户输入的问题编号不能比bug跟踪系统正确分析的风险。

    或者TortoiseSVN高亮显示日志消息中能被问题跟踪者识别的部分。这样,用户就知道日志消息能被正确解析。

  2. 当用户浏览日志信息,TortoiseSVN在日志信息中创建指向每个bug标示的链接,它可以用浏览器打开。

You can integrate a bug tracking tool of your choice in TortoiseSVN. To do this, you have to define some properties, which start with bugtraq:. They must be set on Folders: (“项目设置”一节)

There are two ways to integrate TortoiseSVN with issue trackers. One is based on simple strings, the other is based on regular expressions. The properties used by both approaches are:

bugtraq:url

Set this property to the URL of your bug tracking tool. It must be properly URI encoded and it has to contain %BUGID%. %BUGID% is replaced with the Issue number you entered. This allows TortoiseSVN to display a link in the log dialog, so when you are looking at the revision log you can jump directly to your bug tracking tool. You do not have to provide this property, but then TortoiseSVN shows only the issue number and not the link to it. e.g the TortoiseSVN project is using http://issues.tortoisesvn.net/?do=details&id=%BUGID%

bugtraq:warnifnoissue

Set this to true, if you want TortoiseSVN to warn you because of an empty issue-number text field. Valid values are true/false. If not defined, false is assumed.

在最简单的方法里,TortoiseSVN为用户显示了一个单独的bug ID输入字段,然后后面预计会追加一个用户输入日志信息的行。

bugtraq:message

This property activates the bug tracking system in Input field mode. If this property is set, then TortoiseSVN will prompt you to enter an issue number when you commit your changes. It's used to add a line at the end of the log message. It must contain %BUGID%, which is replaced with the issue number on commit. This ensures that your commit log contains a reference to the issue number which is always in a consistent format and can be parsed by your bug tracking tool to associate the issue number with a particular commit. e.g the TortoiseSVN project is using Issue : %BUGID%, but this depends on your Tool.

bugtraq:append

这个属性定义了bug-ID。是追加到(true)日志信息的末尾,还是插入到(false)日志信息的开始。有效的值包括true/false如果没有定义,默认是true ,所以现存的项目不会被打破。

bugtraq:label

This text is shown by TortoiseSVN on the commit dialog to label the edit box where you enter the issue number. If it's not set, Bug-ID / Issue-Nr: will be displayed. Keep in mind though that the window will not be resized to fit this label, so keep the size of the label below 20-25 characters.

bugtraq:number

If set to true only numbers are allowed in the issue-number text field. An exception is the comma, so you can comma separate several numbers. Valid values are true/false. If not defined, true is assumed.

In the approach with regular expressions, TortoiseSVN doesn't show a separate input field but marks the part of the log message the user enters which is recognized by the issue tracker. This is done while the user writes the log message. This also means that the bug ID can be anywhere inside a log message! This method is much more flexible, and is the one used by the TortoiseSVN project itself.

bugtraq:logregex

This property activates the bug tracking system in Regex mode. It contains one or two regular expressions, separated by a newline.

If only one expression is set, then the bare bug IDs must be matched in the groups of the regex string. Example: [Ii]ssue(?:s)? #?(\d+)

If two expressions are set, then the first expression is used to find a string which relates to the bug ID but may contain more than just the bug ID (e.g. “Issue #123” or “resolves issue 123”). The second expression is then used to extract the bare bug ID from the string extracted with the first expression. An example:

If you want to catch every pattern “issue #XXX” and “issue #890, #789” inside a log message you could use the following regex strings: [Ii]ssue #?(\d+)(,? ?#(\d+))* and the second expression as (\d+)

If you are unfamiliar with regular expressions, take a look at the introduction at http://en.wikipedia.org/wiki/Regular_expression, and the online documentation and tutorial at http://www.regular-expressions.info/.

如果同时设置了bugtraq:messagebugtraq:logregex属性,日志正则表达式会优先使用。

提示

即使你的问题追踪工具没有pre-commit钩子来解析日志信息,你仍然可以使用这个功能将日志信息中的问题单转化为链接!

Some tsvn: properties require a true/false value. TortoiseSVN also understands yes as a synonym for true and no as a synonym for false.

设置文件夹的属性

These properties must be set on folders for the system to work. When you commit a file or folder the properties are read from that folder. If the properties are not found there, TortoiseSVN will search upwards through the folder tree to find them until it comes to an unversioned folder, or the tree root (eg. C:\) is found. If you can be sure that each user checks out only from e.g trunk/ and not some sub-folder, then it's enough if you set the properties on trunk/. If you can't be sure, you should set the properties recursively on each sub-folder. A property setting deeper in the project hierarchy overrides settings on higher levels (closer to trunk/).

For tsvn: properties only you can use the Recursive checkbox to set the property to all sub-folders in the hierarchy, without also setting it on all files.

This issue tracker integration is not restricted to TortoiseSVN; it can be used with any Subversion client. For more information, read the full Issue Tracker Integration Specification.