-
-
Save joestump/27ddfef50dcb54a7f013 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TICKET_PREFIX = '(?:#|(?:ticket|issue|item|defect|bug)[: ]?)' | |
TICKET_RE = re.compile(TICKET_PREFIX + '([0-9]+)', re.I | re.UNICODE) | |
class CommitParser(object): | |
_ticket_reference = TICKET_PREFIX + '[0-9]+' | |
_ticket_command = (r'(?P<action>[A-Za-z]*) ?(task|issue|defect|bug|item|ticket|:)?.?' | |
'(?P<ticket>%s(?:(?:[, &]*|[ ,]+?and[ ]?)%s)*)' % | |
(_ticket_reference, _ticket_reference)) | |
_command_re = re.compile(_ticket_command, re.I | re.UNICODE) | |
_ticket_re = re.compile(TICKET_PREFIX + '([0-9]+)', re.I | re.UNICODE) | |
_item_cmds = {'close': 'close_ticket', | |
'closed': 'close_ticket', | |
'closes': 'close_ticket', | |
'finish': 'close_ticket', | |
'finished': 'close_ticket', | |
'finishes': 'close_ticket', | |
'fix': 'close_ticket', | |
'fixed': 'close_ticket', | |
'fixes': 'close_ticket', | |
'breaks': 'reopen_ticket', | |
'unfixes': 'reopen_ticket', | |
'reopen': 'reopen_ticket', | |
'reopens': 'reopen_ticket', | |
're-open': 'reopen_ticket', | |
're-opens': 'reopen_ticket', | |
'addresses': 'reference_ticket', | |
're': 'reference_ticket', | |
'ref': 'reference_ticket', | |
'references': 'reference_ticket', | |
'refs': 'reference_ticket', | |
'start': 'reference_ticket', | |
'starts': 'reference_ticket', | |
'see': 'reference_ticket'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
_command_re
to find all instances of_item_cmds
referencing something that looks like a ticket.TICKET_RE
to find all instances of a ticket.I should mention this is some of the oldest code in Sprint.ly so it's probably a bit crufty in some places. That being said, it's also pretty well tested and generally picks up what it should and leaves what it shouldn't.