##// END OF EJS Templates
pull-requests: expose commit versions in the pull-request commit list. Fixes #5642
milka -
r4615:ca0827b2 default
parent child Browse files
Show More
@@ -357,6 +357,9 b' class RepoPullRequestsView(RepoAppView, '
357 357 pull_request_id=pull_request_id))
358 358
359 359 versions = pull_request_display_obj.versions()
360
361 c.commit_versions = PullRequestModel().pr_commits_versions(versions)
362
360 363 # used to store per-commit range diffs
361 364 c.changes = collections.OrderedDict()
362 365
@@ -3821,8 +3821,12 b' class ChangesetComment(Base, BaseModel):'
3821 3821 return q.all()
3822 3822
3823 3823 @classmethod
3824 def get_index_from_version(cls, pr_version, versions):
3825 num_versions = [x.pull_request_version_id for x in versions]
3824 def get_index_from_version(cls, pr_version, versions=None, num_versions=None):
3825
3826 if versions is not None:
3827 num_versions = [x.pull_request_version_id for x in versions]
3828
3829 num_versions = num_versions or []
3826 3830 try:
3827 3831 return num_versions.index(pr_version) + 1
3828 3832 except (IndexError, ValueError):
@@ -610,6 +610,20 b' class PullRequestModel(BaseModel):'
610 610 return _org_pull_request_obj, pull_request_obj, \
611 611 pull_request_display_obj, at_version
612 612
613 def pr_commits_versions(self, versions):
614 """
615 Maps the pull-request commits into all known PR versions. This way we can obtain
616 each pr version the commit was introduced in.
617 """
618 commit_versions = collections.defaultdict(list)
619 num_versions = [x.pull_request_version_id for x in versions]
620 for ver in versions:
621 for commit_id in ver.revisions:
622 ver_idx = ChangesetComment.get_index_from_version(
623 ver.pull_request_version_id, num_versions=num_versions)
624 commit_versions[commit_id].append(ver_idx)
625 return commit_versions
626
613 627 def create(self, created_by, source_repo, source_ref, target_repo,
614 628 target_ref, revisions, reviewers, observers, title, description=None,
615 629 common_ancestor_id=None,
@@ -12,6 +12,9 b''
12 12 <input type="hidden" name="__start__" value="revisions:sequence">
13 13 <table class="rctable compare_view_commits">
14 14 <tr>
15 % if hasattr(c, 'commit_versions'):
16 <th>ver</th>
17 % endif
15 18 <th>${_('Time')}</th>
16 19 <th>${_('Author')}</th>
17 20 <th>${_('Commit')}</th>
@@ -30,6 +33,11 b''
30 33 class="compare_select"
31 34 style="${'display: none' if c.collapse_all_commits else ''}"
32 35 >
36 % if hasattr(c, 'commit_versions'):
37 <td class="tooltip" title="${_('Pull request version this commit was introduced')}">
38 <code>${('v{}'.format(c.commit_versions[commit.raw_id][0]) if c.commit_versions[commit.raw_id] else 'latest')}</code>
39 </td>
40 % endif
33 41 <td class="td-time">
34 42 ${h.age_component(commit.date)}
35 43 </td>
General Comments 0
You need to be logged in to leave comments. Login now