From bf50286332609a996b874a728ec5c6b48ec06f2d Mon Sep 17 00:00:00 2001 From: Ryan Lerch Date: Jan 13 2016 11:00:02 +0000 Subject: [PATCH 1/6] started changes to the diff page --- diff --git a/pagure/templates/commit.html b/pagure/templates/commit.html index 37dbb05..24d6191 100644 --- a/pagure/templates/commit.html +++ b/pagure/templates/commit.html @@ -7,64 +7,75 @@ {% set splitted_message = commit.message.split('\n') %}
-

- {{ splitted_message[0] }} - (commit: {{ commitid|short }} - - tree) +

+ Commit {{ commitid|short }} + {{ splitted_message[0] }} +
+ raw + patch + tree + {% if commit.parents|length == 1 %} + parent + {% elif commit.parents|length > 1 %} +
+ + +
+ {% endif%} +
+

+
+ {% if commit.author| author2user == commit.committer| author2user %} + Authored and Committed by {{ commit.author | author2user |safe }} + {{commit.commit_time | humanize}} + {% else %} + Authored by {{ commit.author | author2user |safe }} + {{commit.commit_time | humanize}}, + Committed by {{ commit.committer | author2user |safe }} + {{commit.commit_time | humanize}}, + {% endif%} +
+
+ {% if splitted_message|length > 1 %} - +
         {% for message in splitted_message %}
-            {% if loop.index > 1 %}
-                {{ message }}
-            {% endif %}
+{{ message }}
         {% endfor %}
-    
+    
{% endif %} - - - - - - - - - - - - - - - -
Author - {{ commit.author | author2user |safe }} - - {{ commit.commit_time | format_ts}} -
Committer - {{ commit.committer | author2user |safe }} - - {{ commit.commit_time | format_ts }} -
Parent - {% for parent in commit.parents %} - - {{ parent.oid.hex }} -
- {% endfor %} -
Changes
{% for patch in diff %} -
-
- {% if patch | hasattr('new_file_path') %} -

{{ patch.new_file_path }}

- {% elif patch | hasattr('delta') %} -

{{ patch.delta.new_file.path }}

- {% 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 %} - {% if patch.line_stats[2] > 0 %}-{{ patch.line_stats[2] }}{% endif %} - - {% endif %} - {% endif %} - {% endif %} -
  • -
  • - View -
  • -
-
+
+
+ {% if patch | hasattr('new_file_path') %} + + {{ patch.new_file_path }} + + {% elif patch | hasattr('delta') %} + + {{ patch.delta.new_file.path }} + + {% 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 %} + {% if patch.line_stats[2] > 0 %}-{{ patch.line_stats[2] }}{% endif %} + + {% endif %} + {% endif %} + {% endif %} +
{% if patch.is_binary %}

Binary diffs cannot be rendered.

@@ -135,7 +145,7 @@ {{ patch|patch_to_diff|html_diff}} {% endautoescape %} {% endif %} -
+ {% endfor %} From 6d207568b6632fd3cbe92bf5c5ca4bcabdc556ad Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 13 2016 12:09:36 +0000 Subject: [PATCH 2/6] Small indentation fixes --- diff --git a/pagure/templates/repo_master.html b/pagure/templates/repo_master.html index a77427b..ae53296 100644 --- a/pagure/templates/repo_master.html +++ b/pagure/templates/repo_master.html @@ -12,12 +12,15 @@ {% if repo.is_fork %}{% endif %}{{ repo.fullname }} - {% if authenticated and not repo_admin and not repo.is_fork%} + {{ authenticated }} -- {{ repo_admin }} -- {{ repo.is_fork }} + {% if authenticated and not repo_admin and not repo.is_fork %}
- + {{ forkbuttonform.csrf_token }}
From 5b6ee2f21cdc932e4ea38c2e5500bdc7ac3f629a Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 13 2016 12:09:44 +0000 Subject: [PATCH 3/6] Specify if the user is an admin of the repo when viewing a commit --- diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index 85a93cf..22e7195 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -584,6 +584,7 @@ def view_commit(repo, commitid, username=None): select='logs', repo=repo, username=username, + repo_admin=is_repo_admin(repo), commitid=commitid, commit=commit, diff=diff, From 907be1e771a273d997a9c6f0e75954ea69c34a76 Mon Sep 17 00:00:00 2001 From: Ryan Lerch Date: Jan 13 2016 23:44:25 +0000 Subject: [PATCH 4/6] removed text used for debugging --- diff --git a/pagure/templates/repo_master.html b/pagure/templates/repo_master.html index ae53296..2c99e4b 100644 --- a/pagure/templates/repo_master.html +++ b/pagure/templates/repo_master.html @@ -12,7 +12,6 @@ {% if repo.is_fork %}{% endif %}{{ repo.fullname }} - {{ authenticated }} -- {{ repo_admin }} -- {{ repo.is_fork }} {% if authenticated and not repo_admin and not repo.is_fork %}
{% if commit.author| author2user == commit.committer| author2user %} - Authored and Committed by {{ commit.author | author2user |safe }} + {{diff|count}} file{{'s' if diff|count > 1}} Authored and Committed by {{ commit.author | author2user |safe }} {{commit.commit_time | humanize}} {% else %} - Authored by {{ commit.author | author2user |safe }} + {{diff|count}} file{{'s' if diff|count > 1}} Authored by {{ commit.author | author2user |safe }} {{commit.commit_time | humanize}}, Committed by {{ commit.committer | author2user |safe }} {{commit.commit_time | humanize}}, @@ -48,6 +48,42 @@
+ + +
{% if splitted_message|length > 1 %}
         {% for message in splitted_message %}
@@ -55,56 +91,12 @@
         {% endfor %}
     
{% endif %} +
- - - - - -
Changes -
    - {% for patch in diff %} -
  • - {% if patch | hasattr('new_file_path') %} - - {{ patch.new_file_path }} - - {% elif patch | hasattr('delta') %} - - {{ patch.delta.new_file.path }} - - {% 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 %} - {% if patch.line_stats[2] > 0 %}-{{ patch.line_stats[2] }}{% endif %} - - {% endif %} - {% endif %} - {% endif %} - - {{ patch.new_file_path }} -
  • - {% endfor %} -
-
- +{% set filecount = 0 %} {% for patch in diff %} -
+ {% set filecount = filecount + 1 %} +
{% if patch | hasattr('new_file_path') %} + $(function(){ + $('#diff_list_link').click(function(){ + $('#diff_list').toggle(); + }); + }); + +{% endblock %} From 4449a5fb29cafea774a002167a8609f7cdd5e70c Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 14 2016 13:48:13 +0000 Subject: [PATCH 6/6] Adjust unit-tests for the new view_commit page --- diff --git a/tests/test_progit_flask_ui_repo.py b/tests/test_progit_flask_ui_repo.py index c245dae..f050616 100644 --- a/tests/test_progit_flask_ui_repo.py +++ b/tests/test_progit_flask_ui_repo.py @@ -1038,9 +1038,11 @@ class PagureFlaskRepotests(tests.Modeltests): # View first commit output = self.app.get('/test/%s' % commit.oid.hex) self.assertEqual(output.status_code, 200) - self.assertTrue('
' in output.data) - self.assertTrue('Author' in output.data) - self.assertTrue('Committer' in output.data) + self.assertTrue( + '