# HG changeset patch # User Daniel Dourvaris # Date 2019-11-06 12:56:26 # Node ID db4eefe41b16bccba9dea481dcd1a3c784a84d25 # Parent 334480434a3f548d14e3ba890fa7de04f14489b2 patterns: enabled global !NUM match for new style pull-request references. diff --git a/rhodecode/apps/admin/tests/test_admin_settings.py b/rhodecode/apps/admin/tests/test_admin_settings.py --- a/rhodecode/apps/admin/tests/test_admin_settings.py +++ b/rhodecode/apps/admin/tests/test_admin_settings.py @@ -734,7 +734,6 @@ class TestAdminSettingsIssueTracker(obje post_url = route_path('admin_settings_issuetracker_delete') post_data = { - '_method': 'delete', 'uid': uid, 'csrf_token': csrf_token } diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -1627,6 +1627,11 @@ def _process_url_func(match_obj, repo_na '%(pref)s' '%(issue-prefix)s%(id-repr)s' '') + elif link_format == 'html+hovercard': + tmpl = ( + '%(pref)s' + '%(issue-prefix)s%(id-repr)s' + '') elif link_format == 'rst': tmpl = '`%(issue-prefix)s%(id-repr)s <%(url)s>`_' elif link_format == 'markdown': @@ -1647,6 +1652,7 @@ def _process_url_func(match_obj, repo_na # named regex variables named_vars.update(match_obj.groupdict()) _url = string.Template(entry['url']).safe_substitute(**named_vars) + desc = string.Template(entry['desc']).safe_substitute(**named_vars) def quote_cleaner(input_str): """Remove quotes as it's HTML""" @@ -1659,7 +1665,8 @@ def _process_url_func(match_obj, repo_na 'id-repr': issue_id, 'issue-prefix': entry['pref'], 'serv': entry['url'], - 'title': entry['desc'] + 'title': desc, + 'hovercard_url': '' } if return_raw_data: return { @@ -1723,6 +1730,18 @@ def process_patterns(text_string, repo_n new_text = pattern.sub(url_func, new_text) log.debug('processed prefix:uid `%s`', uid) + # finally use global replace, eg !123 -> pr-link, those will not catch + # if already similar pattern exists + pr_entry = { + 'pref': '!', + 'url': '/_admin/pull-requests/${id}', + 'desc': 'Pull Request !${id}' + } + pr_url_func = partial( + _process_url_func, repo_name=repo_name, entry=pr_entry, uid=None) + new_text = re.compile(r'(?:(?:^!)|(?: !))(\d+)').sub(pr_url_func, new_text) + log.debug('processed !pr pattern') + return new_text, issues_data @@ -1734,24 +1753,24 @@ def urlify_commit_message(commit_text, r :param commit_text: :param repository: """ - def escaper(string): - return string.replace('<', '<').replace('>', '>') + def escaper(_text): + return _text.replace('<', '<').replace('>', '>') - newtext = escaper(commit_text) + new_text = escaper(commit_text) # extract http/https links and make them real urls - newtext = urlify_text(newtext, safe=False) + new_text = urlify_text(new_text, safe=False) # urlify commits - extract commit ids and make link out of them, if we have # the scope of repository present. if repository: - newtext = urlify_commits(newtext, repository) + new_text = urlify_commits(new_text, repository) # process issue tracker patterns - newtext, issues = process_patterns(newtext, repository or '', - active_entries=active_pattern_entries) + new_text, issues = process_patterns(new_text, repository or '', + active_entries=active_pattern_entries) - return literal(newtext) + return literal(new_text) def render_binary(repo_name, file_obj): diff --git a/rhodecode/templates/base/issue_tracker_settings.mako b/rhodecode/templates/base/issue_tracker_settings.mako --- a/rhodecode/templates/base/issue_tracker_settings.mako +++ b/rhodecode/templates/base/issue_tracker_settings.mako @@ -60,7 +60,7 @@ ${_('Edit')} - ${h.hidden('uid', uid)} +
@@ -93,11 +93,10 @@ var delete_pattern = function(entry) { if (confirm("${_('Confirm to remove this pattern:')} "+$(entry).data('desc'))) { - var request = $.ajax({ + $.ajax({ type: "POST", url: "${delete_url}", data: { - '_method': 'delete', 'csrf_token': CSRF_TOKEN, 'uid':$(entry).data('uid') }, @@ -182,7 +181,8 @@
@@ -190,7 +190,7 @@ hit preview to see the link
${_('Preview')}

${_('Test Pattern Preview')}

-
+