#11349 closed enhancement (fixed)
Allow commit message action to follow ticket number.
Reported by: | anonymous | Owned by: | Ryan J Ollos |
---|---|---|---|
Priority: | normal | Milestone: | 1.0.2 |
Component: | ticket system | Version: | 1.0.1 |
Severity: | normal | Keywords: | CommitTicketUpdater |
Cc: | ethan.jucovy@… | Branch: | |
Release Notes: |
CommitTicketUpdater: Use |
||
API Changes: | |||
Internal Changes: |
Description
Currently commit_updater.py allows the status of a ticket to be set through commit messages, I am currently using it and doing "closes #1234" and "fixes #1234" works perfectly. I would also like it to be possible to do this in reverse such as "#1234 fixed" and "1234 and 1235 closed" I was curious how difficult this would be to implement I know it would take some regex modification to http://trac.edgewall.org/browser/trunk/tracopt/ticket/commit_updater.py, probably lines 135-139.
Attachments (0)
Change History (7)
comment:1 by , 11 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:2 by , 11 years ago
Cc: | added |
---|
comment:4 by , 11 years ago
Milestone: | undecided → 1.0.2 |
---|
A cleaner version of the proposed change can be found in log:rjollos.git:t11349. The use case for the change is fairly limited in scope, but at the same time the change seems harmless. I was thinking I'd also take the opportunity to add a few unit tests for CommitTicketUpdater
(forthcoming).
comment:6 by , 11 years ago
Keywords: | CommitTicketUpdater added |
---|---|
Release Notes: | modified (diff) |
Committed to 1.0-stable in [12325:12326], and merged to trunk in [12327].
In Trac 1.0.2dev-r12326 and later, the simpler CommitTicketUpdater subclass can be used:
from tracopt.ticket.commit_updater import CommitTicketUpdater class CustomCommitTicketUpdater(CommitTicketUpdater): ticket_command = (r'(?P<ticket>%s(?:(?:[, &]*|[ ]?and[ ]?)%s)*)\s*' r'(?P<action>[A-Za-z]*)\s*.?' % (CommitTicketUpdater.ticket_reference, CommitTicketUpdater.ticket_reference))
It was mentioned earlier that you should disable tracopt.ticket.commit_updater.CommitTicketUpdater
. However, it seems to work fine to leave them both enabled, and then both syntaxes can be used.
comment:7 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
This hasn't been tested much so the regex might need to be tweaked a bit more.
You can drop it in your environment plugin's directory, naming it something like
custom_commit_updater.py
. Make sure to disabletracopt.ticket.commit_updater.CommitTicketUpdater
and enable this plugin (it will be enabled by default if you put it in yourplugins
directory).As for any possible changes to Trac, a modification to
_parse_message
would simplifyCustomCommitTicketUpdater
. Really, all that is needed for your case is this change:tracopt/ticket/commit_updater.py
cmd, tktsin cmd_groups:However, I modified
_parse_message
for your case in a way that would work for the existing syntax (e.g.Refs #1
) as well as your custom syntax (e.g.#1 Refs
), so that we could consider this as a possible patch for Trac:tracopt/ticket/commit_updater.py
all(message)If we applied that patch to Trac, you plugin would simply be: