| 1 | Integration of Subversion (GUI) clients with Bug Tracking Tools: |
|---|
| 2 | ================================================================================ |
|---|
| 3 | |
|---|
| 4 | I. Preface |
|---|
| 5 | ---------- |
|---|
| 6 | This document is primarily intended for writers of various GUI clients for |
|---|
| 7 | Subversion. Clients such as TortoiseSVN, Subclipse, RapidSVN, PySVN and many |
|---|
| 8 | others. |
|---|
| 9 | |
|---|
| 10 | The goal of this document is to outline a common technique for defining and then |
|---|
| 11 | integrating these GUI clients with third party bug tracking software. |
|---|
| 12 | |
|---|
| 13 | II. Introduction |
|---|
| 14 | ---------------- |
|---|
| 15 | It is very common in Software Development for changes to be related to a |
|---|
| 16 | specific bug or issue ID. Users of bug tracking systems would like to associate |
|---|
| 17 | the changes they make in Subversion with a specific ID in their bug tracking |
|---|
| 18 | system. There are already a number of people that have integrated these systems |
|---|
| 19 | with Subversion. They typically rely on the end user entering a log message on |
|---|
| 20 | their commits in some kind of a specific format that can be parsed with a |
|---|
| 21 | commit-hook or in some cases just on-the-fly in a web-based presentation of the |
|---|
| 22 | commit info. This option is OK, but it is not very user-friendly and it places |
|---|
| 23 | all of the integration within the bug tracking tool. When using a Subversion |
|---|
| 24 | client, you can see the log message info, but there is no way to jump to the bug |
|---|
| 25 | system. |
|---|
| 26 | |
|---|
| 27 | Subversion (GUI) clients can help both the users and the bug tracking tools in |
|---|
| 28 | that task: |
|---|
| 29 | |
|---|
| 30 | - When the user enters a log message, a well defined line including the issue |
|---|
| 31 | number associated with the commit can be added by the client automatically. This |
|---|
| 32 | reduces the risk that the users enters the issue number in a way the bug |
|---|
| 33 | tracking tools can't parse correctly and therefore won't know that the commit |
|---|
| 34 | was associated with a specific issue. The users won't have to remember the |
|---|
| 35 | format they have to use for each log message and each individual project - the |
|---|
| 36 | client will take care of that. |
|---|
| 37 | |
|---|
| 38 | - When the user browses the log messages, there should be an easy way to fire up |
|---|
| 39 | the webbrowser to see the issue associated with that log message/commit. |
|---|
| 40 | |
|---|
| 41 | III. Requirements |
|---|
| 42 | ----------------- |
|---|
| 43 | To make the integration with bug tracking tools possible, a Subversion client |
|---|
| 44 | needs some information about the bug tracking tool used in a project. That |
|---|
| 45 | information should be available inside the working copy so that clients don't |
|---|
| 46 | have to access the repository over a possibly very slow connection to get that |
|---|
| 47 | information. |
|---|
| 48 | |
|---|
| 49 | The information a client needs is: |
|---|
| 50 | |
|---|
| 51 | - the URL pointing to the bug tracking tool |
|---|
| 52 | - the format of the issue number it has to add to the log messages so the |
|---|
| 53 | bug tracking tool can recognize it. Or |
|---|
| 54 | - a regular expression to parse the log message with to extract the issue number |
|---|
| 55 | |
|---|
| 56 | There are other things a Subversion (GUI) client could use to make the |
|---|
| 57 | integration with bug tracking tools easier for the user, but these are |
|---|
| 58 | essential for the integration to work. |
|---|
| 59 | |
|---|
| 60 | IV. Implementation |
|---|
| 61 | ------------------ |
|---|
| 62 | The required information for the clients is stored in *folder* properties. The |
|---|
| 63 | reason we chose this path is explained in the FAQ at the end of this document. |
|---|
| 64 | |
|---|
| 65 | There are two different ways a client can integrate with an issue tracker. One |
|---|
| 66 | is very basic but provides the user with a separate GUI to enter bug ID's, |
|---|
| 67 | and the other one is based on regular expressions where the user has to enter |
|---|
| 68 | the bug ID's directly into the log message. |
|---|
| 69 | |
|---|
| 70 | The following properties are defined which are used by both ways: |
|---|
| 71 | |
|---|
| 72 | name : bugtraq:url |
|---|
| 73 | value : (string) |
|---|
| 74 | This value is the URL pointing to the bug tracking tool. The URL string should |
|---|
| 75 | contain the substring "%BUGID%" which the client replaces with the issue number. |
|---|
| 76 | That way the resulting URL will point directly to the correct issue. |
|---|
| 77 | NOTE: The URL must be properly URI encoded by the user. |
|---|
| 78 | This URL can be used by clients to create a link to the bug tracking tool when |
|---|
| 79 | showing the logmessage of a revision. |
|---|
| 80 | |
|---|
| 81 | name : bugtraq:warnifnoissue |
|---|
| 82 | value : "true"/"yes" or "false"/"no" |
|---|
| 83 | If set to "true", then the clients will warn the user if the issue text box is |
|---|
| 84 | left empty. But it must not block the commit, only give the user a chance to |
|---|
| 85 | enter an issue number in case (s)he forgot it. |
|---|
| 86 | |
|---|
| 87 | Properties used with the basic integration: |
|---|
| 88 | |
|---|
| 89 | name : bugtraq:label |
|---|
| 90 | value : (string) |
|---|
| 91 | This can be used by a client as a GUI label describing the text box where the |
|---|
| 92 | user has to enter the issue number. If this is not set, then a default value |
|---|
| 93 | should be used, e.g. "Bug-ID / Issue-Number :". Keep in mind though that most |
|---|
| 94 | GUI clients don't resize their windows according to the size of GUI elements. So |
|---|
| 95 | keep the size of the label string below 20-25 chars. |
|---|
| 96 | |
|---|
| 97 | name : bugtraq:message |
|---|
| 98 | value : (string) |
|---|
| 99 | If this property is set, then the client should show a text box in the commit |
|---|
| 100 | window where the user can enter an issue number. |
|---|
| 101 | The value string of this property is used by the client to create an additional |
|---|
| 102 | line added to the log message. The string must contain the substring "%BUGID%" |
|---|
| 103 | which is replaced with the issue number the user entered before applied to the |
|---|
| 104 | log message. The client will add the resulting string as a new line to the end |
|---|
| 105 | of the log message the user entered: |
|---|
| 106 | logmessage + "\n" + resultstring |
|---|
| 107 | In case bugtraq:append is set to "false", then the log message is defined as |
|---|
| 108 | resultstring + "\n" + logmessage |
|---|
| 109 | The client should make sure that the string doesn't have multiple lines. |
|---|
| 110 | If more than one issue number is entered by the user (separated by commas), the |
|---|
| 111 | client must make sure that there's no whitespace chars before and after the |
|---|
| 112 | comma. And also the whole issue number string must be trimmed. |
|---|
| 113 | Note: if the bugtraq:logregex property is set, then this property should be |
|---|
| 114 | ignored for parsing the log message but only be used to show the issue ID edit box. |
|---|
| 115 | |
|---|
| 116 | name : bugtraq:number |
|---|
| 117 | value : "true" or "false" |
|---|
| 118 | If this property is set to "false", then the client allows any character entered |
|---|
| 119 | in the issue text box. Any other value or if the property is missing then only |
|---|
| 120 | numbers are allowed as the issue number. One exception is the ',' char, which is |
|---|
| 121 | used to separate multiple issues. |
|---|
| 122 | The client must never complain if the text box is left empty, i.e. if no issue |
|---|
| 123 | number is given. Not all commits are assigned to an issue! |
|---|
| 124 | Note: if the property bugtraq:logregex is set and this property is set to false, |
|---|
| 125 | then the client should use the regex against the created string which is added |
|---|
| 126 | to the log message to check if the bug ID is valid. |
|---|
| 127 | |
|---|
| 128 | name : bugtraq:append |
|---|
| 129 | value : "true" or "false" |
|---|
| 130 | If set to "false", then the bugtraq:message part is inserted at the top of |
|---|
| 131 | the log message, if "yes" or not set, then it's appended to the log message at |
|---|
| 132 | the bottom. |
|---|
| 133 | |
|---|
| 134 | Properties used with the regex integration: |
|---|
| 135 | |
|---|
| 136 | name : bugtraq:logregex |
|---|
| 137 | value : (string) |
|---|
| 138 | This property contains one or two regular expressions, separated by a newline. |
|---|
| 139 | If only one expression is set, then the bare bug ID's must be matched in the |
|---|
| 140 | groups of the regex string. Example: |
|---|
| 141 | [Ii]ssue #?(\d+) |
|---|
| 142 | |
|---|
| 143 | If two expressions are set, then the first expression is used to find a |
|---|
| 144 | string which relates to a bug ID but may contain more than just the bug ID |
|---|
| 145 | (e.g. "Issue #123" or "resolves issue 123"). |
|---|
| 146 | The second expression is then used to extract the bare bug ID from the string |
|---|
| 147 | extracted with the first expression. |
|---|
| 148 | An example: |
|---|
| 149 | if you want to catch every pattern "issue #XXX" and "issue #890, #789" inside |
|---|
| 150 | a log message you could use the following regex strings: |
|---|
| 151 | [Ii]ssue #?(\d+)(,? ?#?(\d+))+ |
|---|
| 152 | (\d+) |
|---|
| 153 | |
|---|
| 154 | The property bugtraq:logregex will override bugtraq:number and bugtraq:message. |
|---|
| 155 | If both bugtraq:logregex and bugtraq:message are set, then bugtraq:message is |
|---|
| 156 | only used if the user enters an issue ID in the edit box of the commit window. |
|---|
| 157 | Both are used in the log window to find the URL's to point to the issuetracker. |
|---|
| 158 | |
|---|
| 159 | Please note: |
|---|
| 160 | - All property names and values must be properly UTF8 encoded. The client should |
|---|
| 161 | take care of that when setting the properties. |
|---|
| 162 | - If the properties are not set for a folder, the client should search upwards |
|---|
| 163 | in the working copy for them until the working copy root is reached. |
|---|
| 164 | |
|---|
| 165 | |
|---|
| 166 | A. FAQ |
|---|
| 167 | ====== |
|---|
| 168 | Q: Why is the integration with bug tracking tools not defined by the Subversion |
|---|
| 169 | project? |
|---|
| 170 | A: The Subversion developers want to keep Subversion "clean", i.e. they |
|---|
| 171 | concentrate on Subversions basic tasks. |
|---|
| 172 | |
|---|
| 173 | Q: Why don't you use a config file located on the server or revision properties |
|---|
| 174 | instead of folder properties? |
|---|
| 175 | A: A config file located on the server and revision properties would mean that |
|---|
| 176 | a client would need to connect to the server each time the bugtracking |
|---|
| 177 | information is needed. On slow connections, this can take several seconds and |
|---|
| 178 | would make the GUI respond slower. |
|---|
| 179 | |
|---|
| 180 | Q: Isn't there a way to store the data in the repository, but having it also |
|---|
| 181 | stored in the working copy? |
|---|
| 182 | A: Subversion doesn't provide such a feature (yet). And there's no way to be |
|---|
| 183 | sure that there ever will be such a feature. So we have to make use of that |
|---|
| 184 | what's already available. |
|---|
| 185 | Also, if the properties are set for each folder, then you can assign a |
|---|
| 186 | different bug tracking tool for a subfolder if you want to. Or you can |
|---|
| 187 | provide a different URL for each folder. |
|---|
| 188 | |
|---|
| 189 | Q: But if I have many folders, I have to add those properties to each one of |
|---|
| 190 | them! Isn't there a better way? |
|---|
| 191 | A: Sorry, but no. But if you can be sure that each user checks out only from |
|---|
| 192 | e.g. /trunk/ and not some subfolder, then it's enough if you set the |
|---|
| 193 | properties there. The clients will search for those properties the path up |
|---|
| 194 | to the working copy root for those properties. |
|---|