Show More
@@ -1543,6 +1543,9 b' def process_patterns(text_string, repo_n' | |||||
1543 | log.debug('issue tracker entry: uid: `%s` PAT:%s URL:%s PREFIX:%s', |
|
1543 | log.debug('issue tracker entry: uid: `%s` PAT:%s URL:%s PREFIX:%s', | |
1544 | uid, entry['pat'], entry['url'], entry['pref']) |
|
1544 | uid, entry['pat'], entry['url'], entry['pref']) | |
1545 |
|
1545 | |||
|
1546 | if entry.get('pat_compiled'): | |||
|
1547 | pattern = entry['pat_compiled'] | |||
|
1548 | else: | |||
1546 | try: |
|
1549 | try: | |
1547 | pattern = re.compile(r'%s' % entry['pat']) |
|
1550 | pattern = re.compile(r'%s' % entry['pat']) | |
1548 | except re.error: |
|
1551 | except re.error: |
@@ -21,6 +21,7 b'' | |||||
21 | import os |
|
21 | import os | |
22 | import hashlib |
|
22 | import hashlib | |
23 | import logging |
|
23 | import logging | |
|
24 | import re | |||
24 | from collections import namedtuple |
|
25 | from collections import namedtuple | |
25 | from functools import wraps |
|
26 | from functools import wraps | |
26 | import bleach |
|
27 | import bleach | |
@@ -372,9 +373,15 b' class IssueTrackerSettingsModel(object):' | |||||
372 | for uid in issuetracker_entries: |
|
373 | for uid in issuetracker_entries: | |
373 | url_data = qs.get(self._get_keyname('url', uid, 'rhodecode_')) |
|
374 | url_data = qs.get(self._get_keyname('url', uid, 'rhodecode_')) | |
374 |
|
375 | |||
|
376 | pat = qs.get(self._get_keyname('pat', uid, 'rhodecode_')) | |||
|
377 | try: | |||
|
378 | pat_compiled = re.compile(r'%s' % pat) | |||
|
379 | except re.error: | |||
|
380 | pat_compiled = None | |||
|
381 | ||||
375 | issuetracker_entries[uid] = AttributeDict({ |
|
382 | issuetracker_entries[uid] = AttributeDict({ | |
376 |
'pat': |
|
383 | 'pat': pat, | |
377 | self._get_keyname('pat', uid, 'rhodecode_')), |
|
384 | 'pat_compiled': pat_compiled, | |
378 | 'url': url_cleaner( |
|
385 | 'url': url_cleaner( | |
379 | qs.get(self._get_keyname('url', uid, 'rhodecode_')) or ''), |
|
386 | qs.get(self._get_keyname('url', uid, 'rhodecode_')) or ''), | |
380 | 'pref': bleach.clean( |
|
387 | 'pref': bleach.clean( |
@@ -43,6 +43,9 b' class TestIssueTrackerSettingsModel(obje' | |||||
43 | settings_mock.return_value = input_settings |
|
43 | settings_mock.return_value = input_settings | |
44 | result = model.get_global_settings(cache=True) |
|
44 | result = model.get_global_settings(cache=True) | |
45 | get_settings.assert_called_once_with(cache=True) |
|
45 | get_settings.assert_called_once_with(cache=True) | |
|
46 | for k, v in result.items(): | |||
|
47 | v.pop('pat_compiled', None) | |||
|
48 | ||||
46 | assert expected_result == result |
|
49 | assert expected_result == result | |
47 |
|
50 | |||
48 | def test_get_repo_settings_raise_exception_when_repo_is_not_set(self): |
|
51 | def test_get_repo_settings_raise_exception_when_repo_is_not_set(self): | |
@@ -68,6 +71,8 b' class TestIssueTrackerSettingsModel(obje' | |||||
68 | settings_mock.return_value = input_settings |
|
71 | settings_mock.return_value = input_settings | |
69 | result = model.get_repo_settings(cache=True) |
|
72 | result = model.get_repo_settings(cache=True) | |
70 | get_settings.assert_called_once_with(cache=True) |
|
73 | get_settings.assert_called_once_with(cache=True) | |
|
74 | for k, v in result.items(): | |||
|
75 | v.pop('pat_compiled', None) | |||
71 | assert expected_result == result |
|
76 | assert expected_result == result | |
72 |
|
77 | |||
73 | @pytest.mark.parametrize("inherit_settings, method", [ |
|
78 | @pytest.mark.parametrize("inherit_settings, method", [ |
General Comments 0
You need to be logged in to leave comments.
Login now