Show More
@@ -1666,22 +1666,26 b" pr_pattern_re = regex.compile(r'(?:(?:^!" | |||||
1666 | allowed_link_formats = [ |
|
1666 | allowed_link_formats = [ | |
1667 | 'html', 'rst', 'markdown', 'html+hovercard', 'rst+hovercard', 'markdown+hovercard'] |
|
1667 | 'html', 'rst', 'markdown', 'html+hovercard', 'rst+hovercard', 'markdown+hovercard'] | |
1668 |
|
1668 | |||
|
1669 | compile_cache = { | |||
|
1670 | ||||
|
1671 | } | |||
|
1672 | ||||
1669 |
|
1673 | |||
1670 | def process_patterns(text_string, repo_name, link_format='html', active_entries=None): |
|
1674 | def process_patterns(text_string, repo_name, link_format='html', active_entries=None): | |
1671 |
|
1675 | |||
1672 | if link_format not in allowed_link_formats: |
|
1676 | if link_format not in allowed_link_formats: | |
1673 | raise ValueError('Link format can be only one of:{} got {}'.format( |
|
1677 | raise ValueError('Link format can be only one of:{} got {}'.format( | |
1674 | allowed_link_formats, link_format)) |
|
1678 | allowed_link_formats, link_format)) | |
|
1679 | issues_data = [] | |||
|
1680 | errors = [] | |||
|
1681 | new_text = text_string | |||
1675 |
|
1682 | |||
1676 | if active_entries is None: |
|
1683 | if active_entries is None: | |
1677 | log.debug('Fetch active issue tracker patterns for repo: %s', repo_name) |
|
1684 | log.debug('Fetch active issue tracker patterns for repo: %s', repo_name) | |
1678 | active_entries = get_active_pattern_entries(repo_name) |
|
1685 | active_entries = get_active_pattern_entries(repo_name) | |
1679 |
|
1686 | |||
1680 | issues_data = [] |
|
|||
1681 | errors = [] |
|
|||
1682 | new_text = text_string |
|
|||
1683 |
|
||||
1684 | log.debug('Got %s pattern entries to process', len(active_entries)) |
|
1687 | log.debug('Got %s pattern entries to process', len(active_entries)) | |
|
1688 | ||||
1685 | for uid, entry in active_entries.items(): |
|
1689 | for uid, entry in active_entries.items(): | |
1686 |
|
1690 | |||
1687 | if not (entry['pat'] and entry['url']): |
|
1691 | if not (entry['pat'] and entry['url']): | |
@@ -1693,6 +1697,8 b' def process_patterns(text_string, repo_n' | |||||
1693 |
|
1697 | |||
1694 | if entry.get('pat_compiled'): |
|
1698 | if entry.get('pat_compiled'): | |
1695 | pattern = entry['pat_compiled'] |
|
1699 | pattern = entry['pat_compiled'] | |
|
1700 | elif entry['pat'] in compile_cache: | |||
|
1701 | pattern = compile_cache[entry['pat']] | |||
1696 | else: |
|
1702 | else: | |
1697 | try: |
|
1703 | try: | |
1698 | pattern = regex.compile(r'%s' % entry['pat']) |
|
1704 | pattern = regex.compile(r'%s' % entry['pat']) | |
@@ -1701,6 +1707,7 b' def process_patterns(text_string, repo_n' | |||||
1701 | log.exception('issue tracker pattern: `%s` failed to compile', regex_err) |
|
1707 | log.exception('issue tracker pattern: `%s` failed to compile', regex_err) | |
1702 | errors.append(regex_err) |
|
1708 | errors.append(regex_err) | |
1703 | continue |
|
1709 | continue | |
|
1710 | compile_cache[entry['pat']] = pattern | |||
1704 |
|
1711 | |||
1705 | data_func = partial( |
|
1712 | data_func = partial( | |
1706 | _process_url_func, repo_name=repo_name, entry=entry, uid=uid, |
|
1713 | _process_url_func, repo_name=repo_name, entry=entry, uid=uid, |
General Comments 0
You need to be logged in to leave comments.
Login now