Modify

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#13524 closed enhancement (wontfix)

Exclude InterTrac ticket references

Reported by: Marcel Gestewitz Owned by: lucid
Priority: normal Component: PageTicketsMacro
Severity: normal Keywords:
Cc: clemens Trac Release:

Description

The useful PageTickets macro should avoid to list also ticket numbers which are not intended to be a reference to a ticket.

On the one hand this can be InterTrac links to tickets of other TRAC repositories. Furthermore this may also be escaped references like #13523.

For me it works to adapt the regular expression to the following statement:

tickets_re = re.compile('(?:(?:^|(?:[\s,;.-]))(?:#|(?:ticket:|issue:|bug:)))(\d+)')

With this statement ticket references needs to be

  • at the very beginning of the text
  • preceded by a white space, dot, comma, semicolon, hyphen

In other cases keywords for ticket references are ignored.

Relation

This change may also be of interest for the MentionedTickets plugin.

Attachments (0)

Change History (5)

comment:1 Changed 6 years ago by clemens

Cc: clemens added

Hello

We use a lot of InterTrac links and in my opinion it makes sense to exclude them from the PageTickets macro, because the underlying TicketQuery cannot resolve those external InterTrac links anyway.

Ditto for the MentionedTicketsPlugin.

Clemens

comment:2 Changed 6 years ago by anonymous

Are all the (?: ) needed?

tickets_re = re.compile("""
    (?:
        ^            # At the beginning of the text
        |            # OR
        [\s,;.-]     # After whitespace or punctuation
    )
    (?:
        \#           # #
        |            # OR
        ticket:      # ticket:
        |            # OR
        issue:       # issue:
        |            # OR
        bug:         # bug:
    )
    (\d+)            # Group 1: The ticket number
""", re.VERBOSE)

comment:3 in reply to:  2 Changed 6 years ago by Marcel Gestewitz

Replying to anonymous:

Are all the (?: ) needed?

tickets_re = re.compile("""
    (?:
        ^            # At the beginning of the text
        |            # OR
        [\s,;.-]     # After whitespace or punctuation
    )
    (?:
        \#           # #
        |            # OR
        ticket:      # ticket:
        |            # OR
        issue:       # issue:
        |            # OR
        bug:         # bug:
    )
    (\d+)            # Group 1: The ticket number
""", re.VERBOSE)

Yes this is correct and an useful reduction of the regular expression.

I added the condition for beginning of text later, thus my statement was more complex than necessary.

I did not changed the latter part. In my opinion it is also not required to split \# and the other ticket keywords. See ticket #12499. I did not know why this is the case.

Your regular expression works perfect for me.

comment:4 Changed 6 years ago by lucid

Resolution: wontfix
Status: newclosed

Thanks for the suggestions. Unfortunately there's a problem: This excludes links of the form comment:2:ticket:13524. Subjectively I rate this breakage higher than the exclusion of intertrac links, so for now I close this as WONTFIX. Please reopen if there's a reasobaly simple solution to this obstacle.

comment:5 Changed 6 years ago by lucid

In 17329:

PageTicketsMacro: Include issue: references (see #13524)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain lucid.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.