##// END OF EJS Templates
pull-requests: fixed multiple repetitions of referenced tickets in pull requests summary sidebar.
milka -
r4650:5d2569e3 default
parent child Browse files
Show More
@@ -25,6 +25,7 b' Consists of functions to typically be us'
25 25 available to Controllers. This module is available to both as 'h'.
26 26 """
27 27 import base64
28 import collections
28 29
29 30 import os
30 31 import random
@@ -1733,7 +1734,7 b' def process_patterns(text_string, repo_n'
1733 1734
1734 1735
1735 1736 def urlify_commit_message(commit_text, repository=None, active_pattern_entries=None,
1736 issues_container=None, error_container=None):
1737 issues_container_callback=None, error_container=None):
1737 1738 """
1738 1739 Parses given text message and makes proper links.
1739 1740 issues are linked to given issue-server, and rest is a commit link
@@ -1756,8 +1757,9 b' def urlify_commit_message(commit_text, r'
1756 1757 new_text, issues, errors = process_patterns(
1757 1758 new_text, repository or '', active_entries=active_pattern_entries)
1758 1759
1759 if issues_container is not None:
1760 issues_container.extend(issues)
1760 if issues_container_callback is not None:
1761 for issue in issues:
1762 issues_container_callback(issue)
1761 1763
1762 1764 if error_container is not None:
1763 1765 error_container.extend(errors)
@@ -1802,7 +1804,7 b' def renderer_from_filename(filename, exc'
1802 1804
1803 1805
1804 1806 def render(source, renderer='rst', mentions=False, relative_urls=None,
1805 repo_name=None, active_pattern_entries=None, issues_container=None):
1807 repo_name=None, active_pattern_entries=None, issues_container_callback=None):
1806 1808
1807 1809 def maybe_convert_relative_links(html_source):
1808 1810 if relative_urls:
@@ -1819,8 +1821,9 b" def render(source, renderer='rst', menti"
1819 1821 source, issues, errors = process_patterns(
1820 1822 source, repo_name, link_format='rst',
1821 1823 active_entries=active_pattern_entries)
1822 if issues_container is not None:
1823 issues_container.extend(issues)
1824 if issues_container_callback is not None:
1825 for issue in issues:
1826 issues_container_callback(issue)
1824 1827
1825 1828 return literal(
1826 1829 '<div class="rst-block">%s</div>' %
@@ -1833,8 +1836,10 b" def render(source, renderer='rst', menti"
1833 1836 source, issues, errors = process_patterns(
1834 1837 source, repo_name, link_format='markdown',
1835 1838 active_entries=active_pattern_entries)
1836 if issues_container is not None:
1837 issues_container.extend(issues)
1839 if issues_container_callback is not None:
1840 for issue in issues:
1841 issues_container_callback(issue)
1842
1838 1843
1839 1844 return literal(
1840 1845 '<div class="markdown-block">%s</div>' %
@@ -2115,3 +2120,29 b' def is_active(menu_entry, selected):'
2115 2120
2116 2121 if selected in menu_entry:
2117 2122 return "active"
2123
2124
2125 class IssuesRegistry(object):
2126 """
2127 issue_registry = IssuesRegistry()
2128 some_func(issues_callback=issues_registry(...))
2129 """
2130
2131 def __init__(self):
2132 self.issues = []
2133 self.unique_issues = collections.defaultdict(lambda: [])
2134
2135 def __call__(self, commit_dict=None):
2136 def callback(issue):
2137 if commit_dict and issue:
2138 issue['commit'] = commit_dict
2139 self.issues.append(issue)
2140 self.unique_issues[issue['id']].append(issue)
2141 return callback
2142
2143 def get_issues(self):
2144 return self.issues
2145
2146 @property
2147 def issues_unique_count(self):
2148 return len(set(i['id'] for i in self.issues))
@@ -24,7 +24,7 b''
24 24 ## to speed up lookups cache some functions before the loop
25 25 <%
26 26 active_patterns = h.get_active_pattern_entries(c.repo_name)
27 urlify_commit_message = h.partial(h.urlify_commit_message, active_pattern_entries=active_patterns, issues_container=getattr(c, 'referenced_commit_issues', None))
27 urlify_commit_message = h.partial(h.urlify_commit_message, active_pattern_entries=active_patterns)
28 28 %>
29 29
30 30 %for commit in c.commit_ranges:
@@ -57,7 +57,7 b''
57 57 </td>
58 58 <td class="mid td-description">
59 59 <div class="log-container truncate-wrap">
60 <div class="message truncate" id="c-${commit.raw_id}" data-message-raw="${commit.message}">${urlify_commit_message(commit.message, c.repo_name)}</div>
60 <div class="message truncate" id="c-${commit.raw_id}" data-message-raw="${commit.message}">${urlify_commit_message(commit.message, c.repo_name, issues_container_callback=getattr(c, 'referenced_commit_issues', lambda p:p)(commit.serialize()))}</div>
61 61 </div>
62 62 </td>
63 63 </tr>
@@ -27,8 +27,8 b''
27 27 <%def name="main()">
28 28 ## Container to gather extracted Tickets
29 29 <%
30 c.referenced_commit_issues = []
31 c.referenced_desc_issues = []
30 c.referenced_commit_issues = h.IssuesRegistry()
31 c.referenced_desc_issues = h.IssuesRegistry()
32 32 %>
33 33
34 34 <script type="text/javascript">
@@ -86,7 +86,7 b''
86 86 </div>
87 87
88 88 <div id="pr-desc" class="input" title="${_('Rendered using {} renderer').format(c.renderer)}">
89 ${h.render(c.pull_request.description, renderer=c.renderer, repo_name=c.repo_name, issues_container=c.referenced_desc_issues)}
89 ${h.render(c.pull_request.description, renderer=c.renderer, repo_name=c.repo_name, issues_container_callback=c.referenced_desc_issues())}
90 90 </div>
91 91
92 92 <div id="pr-desc-edit" class="input textarea" style="display: none;">
@@ -435,7 +435,7 b''
435 435 </td>
436 436 <td class="mid td-description">
437 437 <div class="log-container truncate-wrap">
438 <div class="message truncate" id="c-${commit.raw_id}" data-message-raw="${commit.message}">${h.urlify_commit_message(commit.message, c.repo_name, issues_container=c.referenced_commit_issues)}</div>
438 <div class="message truncate" id="c-${commit.raw_id}" data-message-raw="${commit.message}">${h.urlify_commit_message(commit.message, c.repo_name, issues_container_callback=c.referenced_commit_issues(commit.serialize()))}</div>
439 439 </div>
440 440 </td>
441 441 </tr>
@@ -809,7 +809,7 b''
809 809 <div class="sidebar-element clear-both">
810 810 <div class="tooltip right-sidebar-collapsed-state" style="display: none" onclick="toggleSidebar(); return false" title="${_('Referenced Tickets')}">
811 811 <i class="icon-info-circled"></i>
812 ${(len(c.referenced_desc_issues) + len(c.referenced_commit_issues))}
812 ${(c.referenced_desc_issues.issues_unique_count + c.referenced_commit_issues.issues_unique_count)}
813 813 </div>
814 814
815 815 <div class="right-sidebar-expanded-state pr-details-title">
@@ -822,15 +822,17 b''
822 822 <table>
823 823
824 824 <tr><td><code>${_('In pull request description')}:</code></td></tr>
825 % if c.referenced_desc_issues:
826 % for ticket_dict in sorted(c.referenced_desc_issues):
825 % if c.referenced_desc_issues.issues:
826
827 % for ticket_id, ticket_dict in c.referenced_desc_issues.unique_issues.items():
827 828 <tr>
828 829 <td>
829 <a href="${ticket_dict.get('url')}">
830 ${ticket_dict.get('id')}
830 <a href="${ticket_dict[0].get('url')}">
831 ${ticket_id}
831 832 </a>
832 833 </td>
833 834 </tr>
835
834 836 % endfor
835 837 % else:
836 838 <tr>
@@ -841,13 +843,14 b''
841 843 % endif
842 844
843 845 <tr><td style="padding-top: 10px"><code>${_('In commit messages')}:</code></td></tr>
844 % if c.referenced_commit_issues:
845 % for ticket_dict in sorted(c.referenced_commit_issues):
846 % if c.referenced_commit_issues.issues:
847 % for ticket_id, ticket_dict in c.referenced_commit_issues.unique_issues.items():
846 848 <tr>
847 849 <td>
848 <a href="${ticket_dict.get('url')}">
849 ${ticket_dict.get('id')}
850 <a href="${ticket_dict[0].get('url')}">
851 ${ticket_id}
850 852 </a>
853 - ${_ungettext('in %s commit', 'in %s commits', len(ticket_dict)) % (len(ticket_dict))}
851 854 </td>
852 855 </tr>
853 856 % endfor
General Comments 0
You need to be logged in to leave comments. Login now