From 9c9f3ae351058ae6f975c56cae2b7c7dab99ada4 Mon Sep 17 00:00:00 2001 From: Clement Verna Date: Mar 19 2018 09:36:41 +0000 Subject: [PATCH 1/3] APIs of pygit2 in epel and fedora are now compatible The version pygit2 in epel (0.24.2) is recent enough to drop all conditional check we had in place Signed-off-by: Clement Verna --- diff --git a/pagure/lib/git.py b/pagure/lib/git.py index 7328874..b72ad41 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -201,10 +201,7 @@ def _update_git(obj, repo, repofolder): diff = new_repo.diff() files = [] for patch in diff: - if hasattr(patch, 'new_file_path'): - files.append(patch.new_file_path) - elif hasattr(patch, 'delta'): - files.append(patch.delta.new_file.path) + files.append(patch.delta.new_file.path) # Add the changes to the index if added: @@ -905,9 +902,6 @@ def _update_file_in_git( diff = new_repo.diff() files = [] for patch in diff: - if hasattr(patch, 'new_file_path'): - files.append(patch.new_file_path) - elif hasattr(patch, 'delta'): files.append(patch.delta.new_file.path) # Add the changes to the index diff --git a/pagure/templates/commit.html b/pagure/templates/commit.html index c3c93ab..86be630 100644 --- a/pagure/templates/commit.html +++ b/pagure/templates/commit.html @@ -88,23 +88,10 @@ {% set filecount = 0 %} {% for patch in diff %} {% set filecount = filecount + 1 %} - {% if patch | hasattr('new_file_path') %} - - {{ patch.new_file_path | unicode}} - {% elif patch | hasattr('delta') %} {{ patch.delta.new_file.path | unicode }} - {% endif %}
{% if not patch.is_binary %} - {% if patch | hasattr('additions') %} - {% if (patch.additions + patch.deletions) %} - - {% if patch.additions > 0 %}+{{ patch.additions }}{% endif %} - {% if patch.deletions > 0 %}-{{ patch.deletions }}{% endif %} - - {% endif %} - {% else %} {% if (patch.line_stats[1] + patch.line_stats[2]) %} {% if patch.line_stats[1] > 0 %}+{{ patch.line_stats[1] }}{% endif %} @@ -112,7 +99,6 @@ {% endif %} {% endif %} - {% endif %}
{{ patch.new_file_path | unicode }}
@@ -162,30 +148,13 @@ {% set filecount = filecount + 1 %}
- {% if patch | hasattr('new_file_path') %} - - {{ patch.new_file_path | unicode }} - - {% elif patch | hasattr('delta') %} {{ patch.delta.new_file.path | unicode }} - {% endif %} {% if not patch.is_binary %} - {% if patch | hasattr('additions') %} - {% if (patch.additions + patch.deletions) %} - - {% if patch.additions > 0 %}+{{ patch.additions }} {% endif %} - {% if patch.deletions > 0 %}-{{ patch.deletions }}{% endif %} - - {% endif %} - {% else %} {% if (patch.line_stats[1] + patch.line_stats[2]) %} {% if patch.line_stats[1] > 0 %}+{{ patch.line_stats[1] }} {% endif %} @@ -193,7 +162,6 @@ {% endif %} {% endif %} - {% endif %}
{% if patch.is_binary %} diff --git a/pagure/templates/pull_request.html b/pagure/templates/pull_request.html index ad79d65..42d542a 100644 --- a/pagure/templates/pull_request.html +++ b/pagure/templates/pull_request.html @@ -382,15 +382,8 @@
- {% if patch | hasattr('additions') %} - {# Version of pygit2 -0.21.4 -- F21/EL7 #} - {% set linesadded = patch.additions %} - {% set linesremoved = patch.deletions %} - {% else %} - {# Version of pygit2 -0.23.0 -- F23 #} - {% set linesadded = patch.line_stats[1] %} - {% set linesremoved = patch.line_stats[2] %} - {% endif %} + {% set linesadded = patch.line_stats[1] %} + {% set linesremoved = patch.line_stats[2] %} {% macro lineschanged(added, removed) -%} {%if added%} @@ -882,15 +875,8 @@ {% for patch in diff %} {% set count = count+1 %}
- {% if patch | hasattr('additions') %} - {# Version of pygit2 -0.21.4 -- F21/EL7 #} - {% set linesadded = patch.additions %} - {% set linesremoved = patch.deletions %} - {% else %} - {# Version of pygit2 -0.23.0 -- F23 #} - {% set linesadded = patch.line_stats[1] %} - {% set linesremoved = patch.line_stats[2] %} - {% endif %} + {% set linesadded = patch.line_stats[1] %} + {% set linesremoved = patch.line_stats[2] %} {% if patch | hasattr('new_file_path') %} {%- if patch.new_file_path == patch.old_file_path -%} {%- if patch.status == 'D' -%} From c793e3117fef4e29e6e15e709cb3954ee2eae738 Mon Sep 17 00:00:00 2001 From: Clement Verna Date: Mar 19 2018 09:36:41 +0000 Subject: [PATCH 2/3] Update required pygit2 version Signed-off-by: Clement Verna --- diff --git a/files/pagure.spec b/files/pagure.spec index 5fbd517..1c4f7e5 100644 --- a/files/pagure.spec +++ b/files/pagure.spec @@ -29,7 +29,7 @@ BuildRequires: python-flask-wtf BuildRequires: python-flask-multistatic BuildRequires: python-markdown BuildRequires: python-psutil -BuildRequires: python-pygit2 >= 0.20.1 +BuildRequires: python-pygit2 >= 0.22.1 BuildRequires: python-pygments BuildRequires: python-fedora BuildRequires: python-openid @@ -61,7 +61,7 @@ Requires: python-flask-wtf Requires: python-flask-multistatic Requires: python-markdown Requires: python-psutil -Requires: python-pygit2 >= 0.20.1 +Requires: python-pygit2 >= 0.22.1 Requires: python-pygments Requires: python-fedora Requires: python-openid diff --git a/requirements.txt b/requirements.txt index 7ab025b..2320795 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,7 +18,7 @@ markdown munch Pillow psutil -pygit2 >= 0.20.1 +pygit2 >= 0.22.1 pygments python-openid python-openid-cla From 3178d2accaf59e47755670a8ccfd5d1c6c897da8 Mon Sep 17 00:00:00 2001 From: Clement Verna Date: Mar 19 2018 09:36:41 +0000 Subject: [PATCH 3/3] Fix indentation Signed-off-by: Clement Verna --- diff --git a/pagure/lib/git.py b/pagure/lib/git.py index b72ad41..bf893ec 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -902,7 +902,7 @@ def _update_file_in_git( diff = new_repo.diff() files = [] for patch in diff: - files.append(patch.delta.new_file.path) + files.append(patch.delta.new_file.path) # Add the changes to the index added = False