118 | | === How-To Combine SVN trac-post-commit-hook With Test Workflow === |
119 | | |
120 | | If you installed a {{{post-commit-hook}}} in your subversion repository that calls {{{trac-post-commit-hook}}} as provided by trac, then you might want to change the behaviour: Now a developer should set the tickets to {{{testing}}}, not {{{closed}}} and assign them to the reporter. |
121 | | |
122 | | If you change the following method in file {{{trac-post-commit-hook}}}, then the subversion comments to close a ticket, sucht as {{{"closes #64"}}} won't close the ticket any more, but they will put the ticket to status {{{testing}}} and switch the owner to the reporter: |
123 | | |
124 | | {{{ |
125 | | def _cmdClose(self, ticket): |
126 | | ticket['status'] = 'testing' |
127 | | ticket['owner'] = ticket['reporter'] |
128 | | #ticket['status'] = 'closed' |
129 | | #ticket['resolution'] = 'fixed' |
130 | | }}} |
131 | | |
132 | | Commented out are the original two lines. |
133 | | |
134 | | Of course you could also add new keywords, such as {{{test}}} or {{{testing}}} and a new function {{{_cmdClose}}}. Then a developer can choose whether he wants to put the ticket to testing state or to close it. |
135 | | |
136 | | In that case, extend the {{{_supported_cmds}}}, e.g. to: |
137 | | |
138 | | {{{ |
139 | | _supported_cmds = {'close': '_cmdClose', |
140 | | 'closed': '_cmdClose', |
141 | | 'closes': '_cmdClose', |
142 | | 'fix': '_cmdClose', |
143 | | 'fixed': '_cmdClose', |
144 | | 'fixes': '_cmdClose', |
145 | | 'test': '_cmdTest', |
146 | | 'testing': '_cmdTest', |
147 | | 'addresses': '_cmdRefs', |
148 | | 're': '_cmdRefs', |
149 | | 'references': '_cmdRefs', |
150 | | 'refs': '_cmdRefs', |
151 | | 'see': '_cmdRefs'} |
152 | | }}} |
153 | | |
154 | | ... and add a new method {{{_cmdTest}}} just below {{{_cmdClose}}} (and don't modify {{{_cmdClose}}}): |
155 | | {{{ |
156 | | def _cmdTest(self, ticket): |
157 | | ticket['status'] = 'testing' |
158 | | ticket['owner'] = ticket['reporter'] |
159 | | }}} |
160 | | |
161 | | In this case, don't forget to add the new keywords {{{test}}} and {{{testing}}} to file {{{trac-pre-commit-hook}}}, in case you also installed the subversion {{{pre-commit-hook}}}: |
162 | | {{{ |
163 | | for tmp in re.findall('(?:close|closed|closes|fix|fixed|fixes|test|testing|addresses|references|refs|re|see)' |
164 | | }}} |
| 118 | === How to combine the `tracopt.ticket.commit_updater` with the testing workflow === |
| 119 | |
| 120 | The [[source:trunk/tracopt/ticket/commit_updater.py|tracopt.ticket.commit_updater]] is the optional component that [[TracRepositoryAdmin#trac-post-commit-hook|replaces the old trac-post-commit-hook]], in Trac 0.12. |
| 121 | |
| 122 | By default it reacts on some keywords found in changeset message logs like ''close'', ''fix'' etc. and performs the corresponding workflow action. |
| 123 | |
| 124 | If you have a more complex workflow, like the testing stage described above and you want the ''closes'' keyword to move the ticket to the ''testing'' status instead of the ''closed'' status, you need to adapt the code a bit. |
| 125 | |
| 126 | Have a look at the [[0.11/TracWorkflow#How-ToCombineSVNtrac-post-commit-hookWithTestWorkflow|Trac 0.11 recipe]] for the `trac-post-commit-hook`, this will give you some ideas about how to modify the component. |
| 127 | |