##// 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 post_url = route_path('admin_settings_issuetracker_delete')
735 post_url = route_path('admin_settings_issuetracker_delete')
736 post_data = {
736 post_data = {
737 '_method': 'delete',
738 'uid': uid,
737 'uid': uid,
739 'csrf_token': csrf_token
738 'csrf_token': csrf_token
740 }
739 }
@@ -1627,6 +1627,11 b' def _process_url_func(match_obj, repo_na'
1627 '%(pref)s<a class="tooltip %(cls)s" href="%(url)s" title="%(title)s">'
1627 '%(pref)s<a class="tooltip %(cls)s" href="%(url)s" title="%(title)s">'
1628 '%(issue-prefix)s%(id-repr)s'
1628 '%(issue-prefix)s%(id-repr)s'
1629 '</a>')
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 elif link_format == 'rst':
1635 elif link_format == 'rst':
1631 tmpl = '`%(issue-prefix)s%(id-repr)s <%(url)s>`_'
1636 tmpl = '`%(issue-prefix)s%(id-repr)s <%(url)s>`_'
1632 elif link_format == 'markdown':
1637 elif link_format == 'markdown':
@@ -1647,6 +1652,7 b' def _process_url_func(match_obj, repo_na'
1647 # named regex variables
1652 # named regex variables
1648 named_vars.update(match_obj.groupdict())
1653 named_vars.update(match_obj.groupdict())
1649 _url = string.Template(entry['url']).safe_substitute(**named_vars)
1654 _url = string.Template(entry['url']).safe_substitute(**named_vars)
1655 desc = string.Template(entry['desc']).safe_substitute(**named_vars)
1650
1656
1651 def quote_cleaner(input_str):
1657 def quote_cleaner(input_str):
1652 """Remove quotes as it's HTML"""
1658 """Remove quotes as it's HTML"""
@@ -1659,7 +1665,8 b' def _process_url_func(match_obj, repo_na'
1659 'id-repr': issue_id,
1665 'id-repr': issue_id,
1660 'issue-prefix': entry['pref'],
1666 'issue-prefix': entry['pref'],
1661 'serv': entry['url'],
1667 'serv': entry['url'],
1662 'title': entry['desc']
1668 'title': desc,
1669 'hovercard_url': ''
1663 }
1670 }
1664 if return_raw_data:
1671 if return_raw_data:
1665 return {
1672 return {
@@ -1723,6 +1730,18 b' def process_patterns(text_string, repo_n'
1723 new_text = pattern.sub(url_func, new_text)
1730 new_text = pattern.sub(url_func, new_text)
1724 log.debug('processed prefix:uid `%s`', uid)
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 return new_text, issues_data
1745 return new_text, issues_data
1727
1746
1728
1747
@@ -1734,24 +1753,24 b' def urlify_commit_message(commit_text, r'
1734 :param commit_text:
1753 :param commit_text:
1735 :param repository:
1754 :param repository:
1736 """
1755 """
1737 def escaper(string):
1756 def escaper(_text):
1738 return string.replace('<', '&lt;').replace('>', '&gt;')
1757 return _text.replace('<', '&lt;').replace('>', '&gt;')
1739
1758
1740 newtext = escaper(commit_text)
1759 new_text = escaper(commit_text)
1741
1760
1742 # extract http/https links and make them real urls
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 # urlify commits - extract commit ids and make link out of them, if we have
1764 # urlify commits - extract commit ids and make link out of them, if we have
1746 # the scope of repository present.
1765 # the scope of repository present.
1747 if repository:
1766 if repository:
1748 newtext = urlify_commits(newtext, repository)
1767 new_text = urlify_commits(new_text, repository)
1749
1768
1750 # process issue tracker patterns
1769 # process issue tracker patterns
1751 newtext, issues = process_patterns(newtext, repository or '',
1770 new_text, issues = process_patterns(new_text, repository or '',
1752 active_entries=active_pattern_entries)
1771 active_entries=active_pattern_entries)
1753
1772
1754 return literal(newtext)
1773 return literal(new_text)
1755
1774
1756
1775
1757 def render_binary(repo_name, file_obj):
1776 def render_binary(repo_name, file_obj):
@@ -60,7 +60,7 b''
60 <a class="edit_issuetracker_entry" href="">${_('Edit')}</a>
60 <a class="edit_issuetracker_entry" href="">${_('Edit')}</a>
61 </span>
61 </span>
62 <span class="edit">
62 <span class="edit">
63 ${h.hidden('uid', uid)}
63 <input id="uid_${uid}" name="uid" type="hidden" value="${uid}">
64 </span>
64 </span>
65 </div>
65 </div>
66 <div class="grid_delete">
66 <div class="grid_delete">
@@ -93,11 +93,10 b''
93
93
94 var delete_pattern = function(entry) {
94 var delete_pattern = function(entry) {
95 if (confirm("${_('Confirm to remove this pattern:')} "+$(entry).data('desc'))) {
95 if (confirm("${_('Confirm to remove this pattern:')} "+$(entry).data('desc'))) {
96 var request = $.ajax({
96 $.ajax({
97 type: "POST",
97 type: "POST",
98 url: "${delete_url}",
98 url: "${delete_url}",
99 data: {
99 data: {
100 '_method': 'delete',
101 'csrf_token': CSRF_TOKEN,
100 'csrf_token': CSRF_TOKEN,
102 'uid':$(entry).data('uid')
101 'uid':$(entry).data('uid')
103 },
102 },
@@ -182,7 +181,8 b''
182 <textarea id="test_pattern_data" >
181 <textarea id="test_pattern_data" >
183 This commit fixes ticket #451.
182 This commit fixes ticket #451.
184 This is an example text for testing issue tracker patterns, add a pattern here and
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 </textarea>
186 </textarea>
187 </div>
187 </div>
188 </div>
188 </div>
@@ -190,7 +190,7 b' hit preview to see the link'
190 <div class="test_pattern_preview">
190 <div class="test_pattern_preview">
191 <div id="test_pattern" class="btn btn-small" >${_('Preview')}</div>
191 <div id="test_pattern" class="btn btn-small" >${_('Preview')}</div>
192 <p>${_('Test Pattern Preview')}</p>
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 </div>
194 </div>
195 </div>
195 </div>
196
196
General Comments 0
You need to be logged in to leave comments. Login now