From 3520f4e21db91cd9905753418c6f54f7c63511c7 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 12 2016 20:39:47 +0000 Subject: [PATCH 1/3] Fix figuring the patch type on old pygit2 release With this change we can say if a file was added, removed, updated or moved in a diff and we can say so in the UI. --- diff --git a/pagure/templates/pull_request.html b/pagure/templates/pull_request.html index f7d4047..6c6679f 100644 --- a/pagure/templates/pull_request.html +++ b/pagure/templates/pull_request.html @@ -318,15 +318,31 @@ {% if patch | hasattr('new_file_path') %} {%- if patch.new_file_path == patch.old_file_path -%} - {{ viewfilelink(patch.new_file_path)}} {{lineschanged(True, True)}} - {%- else -%} - {{lineschanged(True, True)}} + {{ lineschanged(True, True) }}
{{patch.old_file_path}}
- {{viewfilelink(patch.new_file_path)}} + {{ viewfilelink(patch.new_file_path) }} +
+
file moved
+ {%- elif patch.status == 'D' -%} + {% set patchtype = "removed"%} +
+ {{ viewfilelink(patch.new_file_path) }} {{ lineschanged(False, True) }}
file removed
- {%- endif -%} + {%-elif patch.status == 'A' -%} + {% set patchtype = "added"%} +
+ {{ viewfilelink(patch.new_file_path) }} {{ lineschanged(True, False) }} +
+
file added
+ {%-elif patch.status == 'M' -%} + {% set patchtype = "changed"%} +
+ {{ viewfilelink(patch.new_file_path) }} {{ lineschanged(True, True) }} +
+
file changed
+ {%-endif-%} {%- elif patch | hasattr('delta') -%} {%- if patch.delta.new_file.path == patch.delta.old_file.path -%} {%- if patch.delta.new_file.mode == 0 and patch.delta.old_file.mode == 33188 -%} From 442f8f89371e8730fe275d70442e2a278f3c97ef Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 12 2016 20:39:47 +0000 Subject: [PATCH 2/3] Ensure the file moved wasn't modified --- diff --git a/pagure/templates/pull_request.html b/pagure/templates/pull_request.html index 6c6679f..c41b341 100644 --- a/pagure/templates/pull_request.html +++ b/pagure/templates/pull_request.html @@ -317,10 +317,10 @@ {% endmacro %} {% if patch | hasattr('new_file_path') %} - {%- if patch.new_file_path == patch.old_file_path -%} + {%- if patch.new_file_path == patch.old_file_path and patch.status != 'M' -%} {{ lineschanged(True, True) }}
- {{patch.old_file_path}}
+ {{ patch.old_file_path }}
{{ viewfilelink(patch.new_file_path) }}
file moved
From 00fc1f8d279ec1708e28dce24a0e816c99717f4c Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 12 2016 20:46:35 +0000 Subject: [PATCH 3/3] Quit trying to figure out file moved --- diff --git a/pagure/templates/pull_request.html b/pagure/templates/pull_request.html index c41b341..8766827 100644 --- a/pagure/templates/pull_request.html +++ b/pagure/templates/pull_request.html @@ -317,14 +317,7 @@ {% endmacro %} {% if patch | hasattr('new_file_path') %} - {%- if patch.new_file_path == patch.old_file_path and patch.status != 'M' -%} - {{ lineschanged(True, True) }} -
- {{ patch.old_file_path }}
- {{ viewfilelink(patch.new_file_path) }} -
-
file moved
- {%- elif patch.status == 'D' -%} + {%- if patch.status == 'D' -%} {% set patchtype = "removed"%}
{{ viewfilelink(patch.new_file_path) }} {{ lineschanged(False, True) }} @@ -360,14 +353,6 @@
file changed
{%-endif-%} - {%- else -%} - {% set patchtype = "moved"%} - {{lineschanged(True, True)}} -
- {{patch.delta.old_file.path}}
- {{viewfilelink(patch.delta.new_file.path)}} -
-
file moved
{%- endif -%} {%- endif -%}