Integración con sistemas de control de errores / seguimiento de incidencias

Es muy común en el Desarrollo de Software que los cambios se refieran a un ID de error o incidencia específico. A los usuarios de los sistemas de control de errores (seguimiento de incidencias) les gustaría asociar los cambios que hacen en Subversion con un ID específico en su programa de seguimiento de incidencias. La mayoría de programas de seguimiento de incidencias proporcionan un script gancho pre-commit que parsea el mensaje de log para encontrar el ID del error con el que se asocia la confirmación. Esto es de alguna forma propenso a errores, porque se basa en el que usuario escriba el mensaje de registro de forma correcta para que el script gancho pre-commit pueda parsearlo correctamente.

TortoiseSVN puede ayudar al usuario de dos formas:

  1. Cuando el usuario introduce un mensaje de registro, puede añadirse una línea bien definida incluyendo el número de incidencia asociada a la confirmación. Esto reduce el riesgo de que el usuario introduzca el número de incidencia que las herramientas de control de errores no puedan parsear correctamente.

    O TortoiseSVN puede remarcar la parte del mensaje de registro introducido que el programa de seguimiento de incidencias reconoce. De esta forma el usuario sabrá que el mensaje de registro introducido puede parsearse correctamente.

  2. Cuando el usuario navega por los mensajes de registro, TortoiseSVN crea un enlace desde cada ID de error en el mensaje de registro, que lanza el navegador con la incidencia mencionada.

Adding Issue Numbers to Log Messages

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: (“Configuración del proyecto”)

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%

You can also use relative URLs instead of absolute ones. This is useful when your issue tracker is on the same domain/server as your source repository. In case the domain name ever changes, you don't have to adjust the bugtraq:url property. There are two ways to specify a relative URL:

Si empieza con la cadena ^/ se asume que es relativa a la raíz del repositorio. Por ejemplo, ^/../?do=details&id=%BUGID% se resolverá como http://tortoisesvn.net/?do=details&id=%BUGID% si su repositorio está en http://tortoisesvn.net/svn/trunk/.

Una URL que comience con la cadena / se asume que es relativo al nombre del servidor. Por ejemplo, /?do=details&id=%BUGID% se resolverá como http://tortoisesvn.net/?do=details&id=%BUGID% si su repositorio está localizado en cualquier parte de http://tortoisesvn.net.

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.

Issue Number in Text Box

En el caso simple, TortoiseSVN muestra al usuario un campo de entrada separado donde se puede introducir un ID del error. En ese caso se añade una línea adicional al final o al principio del mensaje de registro que el usuario introduce.

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. As an example you might use Issue : %BUGID%, but this depends on your Tool.

bugtraq:append

Esta propiedad define si el ID del error se añade (true) al final del mensaje de registro o se inserta (false) al inicio del mensaje de registro. Los valores válidos son true/false. Si no se define, se asume true, para que los proyectos ya existentes no se rompan.

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.

Issue Numbers Using Regular Expressions

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 either a single regular expressions, or two regular expressions separated by a newline.

Si se dan dos expresiones, la primera expresión se utiliza como un pre-filtro para encontrar expresiones que contengan identificadores de incidencias. La segunda expresión se utiliza para extraer los identificadores individuales desde los resultados de la primera expresión regular. Esto le permite utilizar una lista de identificadores de incidencias y expresiones en lenguaje natural si lo desea, por ejemplo puede arreglar varias incidencias e incluir una cadena como esta: “Este cambio resuelve las incidencias #23, #24 y #25

Si desea capturar identificadores de incidencias utilizados como se muestran anteriormente dentro de un mensaje de registro, puede utilizar las siguientes cadenas de expresiones regulares, que son las que se utilizan en el proyecto TortoiseSVN (traducidas al inglés): [Ii]ncidencias?:?(\s*(,|y)?\s*#\d+)+ y (\d+)

La primera expresión extrae “incidencias #23, #24 y #25” de entre el resto del mensaje de registro. La segunda expresión regular extrae los números decimales individuales desde la salida de la primera expresión regular, por lo que devolverá “23”, “24” y “25” para utilizarlos como identificadores de incidencias.

Profundizando en la primera expresión regular un poco, debe empezar con la palabra “incidencia”, posiblemente empezando por mayúscula. Opcionalmente puede ir seguida de una “s” (más de una incidencia) y opcionalmente dos puntos. A esto le sigue uno o más grupos, cada uno empezando por cero o más espacios en blanco, una coma opcional o “y” y más espacios opcionales. Finalmente, hay un “#” obligatorio y un número decimal obligatorio.

Si sólo se establece una expresión, entonces los identificadores individuales de incidencias deben concordar con los grupos de la expresión regular. Por ejemplo: [Ii]ncidencia(?:s)? #?(\d+) Este método se necesita por algunos gestores de incidencias, por ejemplo trac, pero la expresión regular es más dificil de construir. Le recomendamos que sólo utilice este método si la documentación de su gestor de incidencias se lo indica.

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/.

Si se establecen las dos propiedades bugtraq:message y bugtraq:logregex, logregex tiene preferencia.

Sugerencia

¡Incluso si no tiene un programa de seguimiento de incidencias con un gancho pre-commit parseando sus mensajes de log, puede seguir utilizando ésto para convertir las incidencias mencionadas en su mensajes de registro en vínculos!

And even if you don't need the links, the issue numbers show up as a separate column in the log dialog, making it easier to find the changes which relate to a particular issue.

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

Estableciendo las propiedades en las carpetas

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.

Getting Information from the Issue Tracker

The previous section deals with adding issue information to the log messages. But what if you need to get information from the issue tracker? The commit dialog has a Windows COM interface which allows integration an external program that can talk to your tracker. Typically you might want to query the tracker to get a list of open issues assigned to you, so that you can pick the issues that are being addressed in this commit.

Any such interface is of course highly specific to your system, so we cannot provide this part, and describing how to create such a program is beyond the scope of this manual. The interface definition and sample programs can be obtained from the contrib folder in the in the TortoiseSVN repository.

For illustration purposes, let's suppose that your system administrator has provided you with an issue tracker plugin which you have installed, and that you have set up some of your working copies to use the plugin in TortoiseSVN's settings dialog. When you open the commit dialog from a working copy to which the plugin has been assigned, you will see a new button at the top of the dialog.

Figura 5.49. Example issue tracker query dialog

Example issue tracker query dialog


In this example you can select one or more open issues. The plugin can then generate specially formatted text which it adds to your log message.