##// END OF EJS Templates
patterns: enabled global !NUM match for new style pull-request references.
dan -
r4041:db4eefe4 default
parent child Browse files
Show More
@@ -734,7 +734,6 b' class TestAdminSettingsIssueTracker(obje'
734 734
735 735 post_url = route_path('admin_settings_issuetracker_delete')
736 736 post_data = {
737 '_method': 'delete',
738 737 'uid': uid,
739 738 'csrf_token': csrf_token
740 739 }
@@ -1627,6 +1627,11 b' def _process_url_func(match_obj, repo_na'
1627 1627 '%(pref)s<a class="tooltip %(cls)s" href="%(url)s" title="%(title)s">'
1628 1628 '%(issue-prefix)s%(id-repr)s'
1629 1629 '</a>')
1630 elif link_format == 'html+hovercard':
1631 tmpl = (
1632 '%(pref)s<a class="tooltip-hovercard %(cls)s" href="%(url)s" data-hovercard-url="%(hovercard_url)s">'
1633 '%(issue-prefix)s%(id-repr)s'
1634 '</a>')
1630 1635 elif link_format == 'rst':
1631 1636 tmpl = '`%(issue-prefix)s%(id-repr)s <%(url)s>`_'
1632 1637 elif link_format == 'markdown':
@@ -1647,6 +1652,7 b' def _process_url_func(match_obj, repo_na'
1647 1652 # named regex variables
1648 1653 named_vars.update(match_obj.groupdict())
1649 1654 _url = string.Template(entry['url']).safe_substitute(**named_vars)
1655 desc = string.Template(entry['desc']).safe_substitute(**named_vars)
1650 1656
1651 1657 def quote_cleaner(input_str):
1652 1658 """Remove quotes as it's HTML"""
@@ -1659,7 +1665,8 b' def _process_url_func(match_obj, repo_na'
1659 1665 'id-repr': issue_id,
1660 1666 'issue-prefix': entry['pref'],
1661 1667 'serv': entry['url'],
1662 'title': entry['desc']
1668 'title': desc,
1669 'hovercard_url': ''
1663 1670 }
1664 1671 if return_raw_data:
1665 1672 return {
@@ -1723,6 +1730,18 b' def process_patterns(text_string, repo_n'
1723 1730 new_text = pattern.sub(url_func, new_text)
1724 1731 log.debug('processed prefix:uid `%s`', uid)
1725 1732
1733 # finally use global replace, eg !123 -> pr-link, those will not catch
1734 # if already similar pattern exists
1735 pr_entry = {
1736 'pref': '!',
1737 'url': '/_admin/pull-requests/${id}',
1738 'desc': 'Pull Request !${id}'
1739 }
1740 pr_url_func = partial(
1741 _process_url_func, repo_name=repo_name, entry=pr_entry, uid=None)
1742 new_text = re.compile(r'(?:(?:^!)|(?: !))(\d+)').sub(pr_url_func, new_text)
1743 log.debug('processed !pr pattern')
1744
1726 1745 return new_text, issues_data
1727 1746
1728 1747
@@ -1734,24 +1753,24 b' def urlify_commit_message(commit_text, r'
1734 1753 :param commit_text:
1735 1754 :param repository:
1736 1755 """
1737 def escaper(string):
1738 return string.replace('<', '&lt;').replace('>', '&gt;')
1756 def escaper(_text):
1757 return _text.replace('<', '&lt;').replace('>', '&gt;')
1739 1758
1740 newtext = escaper(commit_text)
1759 new_text = escaper(commit_text)
1741 1760
1742 1761 # extract http/https links and make them real urls
1743 newtext = urlify_text(newtext, safe=False)
1762 new_text = urlify_text(new_text, safe=False)
1744 1763
1745 1764 # urlify commits - extract commit ids and make link out of them, if we have
1746 1765 # the scope of repository present.
1747 1766 if repository:
1748 newtext = urlify_commits(newtext, repository)
1767 new_text = urlify_commits(new_text, repository)
1749 1768
1750 1769 # process issue tracker patterns
1751 newtext, issues = process_patterns(newtext, repository or '',
1770 new_text, issues = process_patterns(new_text, repository or '',
1752 1771 active_entries=active_pattern_entries)
1753 1772
1754 return literal(newtext)
1773 return literal(new_text)
1755 1774
1756 1775
1757 1776 def render_binary(repo_name, file_obj):
@@ -60,7 +60,7 b''
60 60 <a class="edit_issuetracker_entry" href="">${_('Edit')}</a>
61 61 </span>
62 62 <span class="edit">
63 ${h.hidden('uid', uid)}
63 <input id="uid_${uid}" name="uid" type="hidden" value="${uid}">
64 64 </span>
65 65 </div>
66 66 <div class="grid_delete">
@@ -93,11 +93,10 b''
93 93
94 94 var delete_pattern = function(entry) {
95 95 if (confirm("${_('Confirm to remove this pattern:')} "+$(entry).data('desc'))) {
96 var request = $.ajax({
96 $.ajax({
97 97 type: "POST",
98 98 url: "${delete_url}",
99 99 data: {
100 '_method': 'delete',
101 100 'csrf_token': CSRF_TOKEN,
102 101 'uid':$(entry).data('uid')
103 102 },
@@ -182,7 +181,8 b''
182 181 <textarea id="test_pattern_data" >
183 182 This commit fixes ticket #451.
184 183 This is an example text for testing issue tracker patterns, add a pattern here and
185 hit preview to see the link
184 hit preview to see the link.
185 Open a pull request !101 to contribute !
186 186 </textarea>
187 187 </div>
188 188 </div>
@@ -190,7 +190,7 b' hit preview to see the link'
190 190 <div class="test_pattern_preview">
191 191 <div id="test_pattern" class="btn btn-small" >${_('Preview')}</div>
192 192 <p>${_('Test Pattern Preview')}</p>
193 <div id="test_pattern_result"></div>
193 <div id="test_pattern_result" style="white-space: pre-wrap"></div>
194 194 </div>
195 195 </div>
196 196
General Comments 0
You need to be logged in to leave comments. Login now