#7884 closed defect (duplicate)
Commits match against partial ticket number (i.e. commit refs #1045 ends up on ticket #10)
Reported by: | Marcus Lindblom | Owned by: | Richard Liao |
---|---|---|---|
Priority: | normal | Component: | TracTicketChangelogPlugin |
Severity: | major | Keywords: | |
Cc: | Trac Release: | 0.12 |
Description
Our commit comments use the fixes/refs/see system, which looks like
The problem is that a commit that referenses ticket 100 ends up on ticket 1 and 10 as well.
I've tried using something like: .*?#%s[^0-9].*
but the problem seems to be with the %s itself.
Or else it's a different bug altogether.
Attachments (0)
Change History (8)
comment:1 Changed 14 years ago by
Status: | new → assigned |
---|
comment:2 Changed 14 years ago by
Summary: | Unable to figure out good pattern for comments _ending_ in ticket # → Commits match against partial ticket number (i.e. commit refs #1045 ends up on ticket #10) |
---|
Thanks for the quick response. Sorry for being so slow in return.
I've updated the summary to be more relevant w.r.t. my problem.
The previous pattern was slightly incorrect. I've tried with a slightly different one and got the same results. Perhaps there is a better way altogether.
Pattern: log_pattern = .*#%s[^0-9]*.*
Commit:
changeset: 1904:a42d4562ecb0 tag: tip user: Marcus Lindblom <marcus.lindblom@orzone.se> date: Wed Nov 03 14:19:45 2010 +0100 summary: OrzCPanel: Ask user if system is in correct position + better shutdown msg (fixes #1064)
Ticket #10 changelog:
Changeset Author Time ChangeLog [a42d4562ecb0231950446ef48cbb2f5314fef344] Marcus Lindblom 2010-11-03 OrzCPanel: Ask user if system is in correct position + better shutdown msg (fixes #1064) [8f89fd76a27c52782a100105e67e167ecd2019f2] Daniel Svensson 2010-11-03 OrzCPanel: Added missing signal/slot connection for calibrated status in GUI. Fixes #1065 [5953bb2cbbb84d2c9ee16a408098f80b684515a1] Daniel Svensson 2010-11-03 OrzCPanel: Maxon motors store calibrate status in volatile ram. (Fixes #1013) * Added necessary transitions to state machine to enable new functionality. * Added new function calibrateCheck in motors which checks that the calibrated flag is set. On maxonmotor the relevant bit on the controller is read. * Fixed Re-calibrate functionality. If all motors are calibrated and the user wishes to recalibrate, this now works. * Setup motor_config_dev.xml with same configuration as k6 system. [bc03b4514883cc0cf50392a6847b2fed461e7a32] Marcus Lindblom 2010-11-02 OrzCPanel: Swap via emulated motors when changing config file. See #1007 [e2f3ddf9891ed57663382b967aa614563e37929c] Marcus Lindblom 2010-11-02 Dummy commit to test trac hook. see #10 [747256f9047c4621dab67364975275231c3ab449] Marcus Lindblom 2010-11-02 Dummy commit to test trac hook. see #10
What exactly do you put in %s? is it ([0-9]+)
or something different?
Also, how can I be sure that old changes are removed from the ticket? I currently use 'trac-admin . mercurial sync default' to re-sync changesets after I've changed the pattern. (I'm assuming the ticket<->changeset relations are stored in the database and not matched 'live' each time I view a ticket...)
Just so I don't take up your time with bad data.
comment:3 Changed 10 years ago by
Type: | task → defect |
---|
comment:4 follow-up: 5 Changed 10 years ago by
We had the same problem her and the following pattern works well:
[ticketlog] log_pattern = (\n|.)*#%s($|\D(\n|.)*)
comment:5 Changed 9 years ago by
Replying to anonymous:
We had the same problem her and the following pattern works well:
[ticketlog] log_pattern = (\n|.)*#%s($|\D(\n|.)*)
I've tried your reqexp, however it leads to hangs of the web server running trac when parsing a long commit message, probably because of Catastrophic Backtracking.
This expression works for me:
(?:\n|[^#])*#%s(?:\D|$)
I'd like to propose the use of re.search instead of re.match though, to simplify the regexp even further and make eliminating of "false" matches from the database result faster:
Index: web_ui.py =================================================================== --- web_ui.py (revision 14529) +++ web_ui.py (working copy) @@ -36,7 +36,7 @@ max_message_length = IntOption('ticketlog', 'log_message_maxlength', doc="""Maximum length of log message to display.""") - log_pattern = Option('ticketlog', 'log_pattern', '\s*#%s[:\s]+.*', + log_pattern = Option('ticketlog', 'log_pattern', '#%s(?:\D|$)', "Regex to determine which changesets reference the ticket.") def __init__(self): @@ -86,7 +86,7 @@ WHERE message LIKE %s """, ('%#' + ticket_id + '%',)): - if not p.match(message): + if not p.search(message): continue repos = RepositoryManager(self.env).get_repository(repos_name)
comment:6 Changed 9 years ago by
This issue will eventually be resolved by using the regex from CommitTicketUpdater, as suggested in #11821.
comment:7 Changed 9 years ago by
Resolution: | → duplicate |
---|---|
Status: | assigned → closed |
Closing as a duplicate of #11821, since I hope to implement those changes within the next few months.
I tried your pattern, but did not get matched:
This changelog seems should not on ticket 10 as above test.
Could you show the exact comment and pattern?