diff --git a/pagure/templates/pull_request.html b/pagure/templates/pull_request.html index c2f5387..16799e0 100644 --- a/pagure/templates/pull_request.html +++ b/pagure/templates/pull_request.html @@ -235,22 +235,34 @@ {% if diff %} {% for patch in diff %} + {% if patch |hasattr('new_id') %} + {% set patch_new_id = patch.new_id %} + {% elif patch |hasattr('delta') %} + {% set patch_new_id = patch.delta.new_file.id %} + {% else %} + {% set patch_new_id = patch.new_oid %} + {% endif %} + + {% if patch | hasattr('new_file_path') %} + {% set patch_new_file_path = patch.new_file_path -%} + {% if patch.new_file_path != patch.old_file_path %} + {% set patch_old_file_path = patch.old_file_path %} + {%- endif -%} + {%- elif patch | hasattr('delta') -%} + {% set patch_new_file_path = patch.delta.new_file.path -%} + {%- if patch.delta.new_file.path != patch.delta.old_file.path -%} + {% set patch_old_file_path = patch.delta.old_file.path %} + {%- endif -%} + {%- endif -%} +
- {%- if patch | hasattr('new_file_path') -%} - {%- if patch.new_file_path == patch.old_file_path -%} - {{ patch.new_file_path }} - {%- else -%} - {{ patch.new_file_path }} (Renamed from "{{ patch.old_file_path }}") - {%- endif -%} - {%- elif patch | hasattr('delta') -%} - {%- if patch.delta.new_file.path == patch.delta.old_file.path -%} - {{ patch.delta.new_file.path }} - {%- else -%} - {{ patch.delta.new_file.path }} (Renamed from "{{ patch.delta.old_file.path }}") - {%- endif -%} + {%- if patch_new_file_path == patch_old_file_path -%} + {{ patch_new_file_path }} (Renamed from "{{ patch_old_file_path }}") + {%- else -%} + {{ patch_new_file_path }} {%- endif -%} {% if pull_request %} @@ -261,7 +273,7 @@ if pull_request.project_from.is_fork else None, repo=pull_request.project_from.name, identifier=pull_request.branch_from, - filename=patch.new_file_path) }}" + filename=patch_new_file_path) }}" {% else %} View - {% elif patch |hasattr('delta') %} - title="View file as of {{ patch.delta.new_file.id|short }}">View - {% else %} - title="View file as of {{ patch.new_oid|short }}">View + filename=patch_new_file_path) }}" {% endif %} + title="View file as of {{ patch_new_id|short }}">View
-
##{{patch}}## +
{% autoescape false %} {{ patch | patch_to_diff | html_diff | format_loc( - filename=patch.new_file_path, - commit=patch.new_id or patch.new_oid, + filename=patch_new_file_path, + commit=patch_new_id, prequest=pull_request, index=loop.index)}} {% endautoescape %} diff --git a/pagure/ui/filters.py b/pagure/ui/filters.py index e5a424e..056756c 100644 --- a/pagure/ui/filters.py +++ b/pagure/ui/filters.py @@ -66,8 +66,8 @@ def format_loc(loc, commit=None, filename=None, prequest=None, index=None): comments = {} if prequest and not isinstance(prequest, flask.wrappers.Request): for com in prequest.comments: - if commit and com.commit_id == commit \ - and com.filename == filename: + if commit and unicode(com.commit_id) == unicode(commit) \ + and unicode(com.filename) == unicode(filename): if com.line in comments: comments[com.line].append(com) else: