diff --git a/pagure/templates/_repo_renderdiff.html b/pagure/templates/_repo_renderdiff.html new file mode 100644 index 0000000..5b9e13c --- /dev/null +++ b/pagure/templates/_repo_renderdiff.html @@ -0,0 +1,203 @@ +{% macro repo_renderdiff(diff, diff_commits, pull_request, repo, username, namespace) -%} + +{% 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('old_id') %} + {% set patch_old_id = patch.old_id %} + {% elif patch |hasattr('delta') %} + {% set patch_old_id = patch.delta.old_file.id %} + {% else %} + {% set patch_old_id = patch.old_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 -%} + + +
+
+
+
+ + {% set linesadded = patch.line_stats[1] %} + {% set linesremoved = patch.line_stats[2] %} + + {% macro lineschanged(added, removed) -%} + {%if added%} + +{{linesadded}} + {%endif%} + {%if removed%} + -{{linesremoved}} + {%endif%} + {%endmacro%} + + {% macro viewfilelink(filepath, identifier=False)%} + {% if pull_request and not pull_request.remote %} + {% if not identifier %} + {% set identifier = pull_request.branch_from %} + {% endif %} + {{ + filepath | unicode }} + {% elif not pull_request %} + {{ + filepath | unicode }} + {% elif pull_request and pull_request.remote %} + {{ filepath | unicode }} +
+ this is a remote pull-request, so we cannot provide you + with a direct link to the file but you can always + + checkout the pull-request locally + to review it entirely. +
+ {% endif %} + {% endmacro %} + + {% if patch | hasattr('new_file_path') %} + {%- if patch.new_file_path == patch.old_file_path -%} + {%- if patch.status == 'D' -%} + {% set patchtype = "removed"%} +
+ {{ viewfilelink(patch.new_file_path) }} {{ lineschanged(False, True) }} +
+
file removed
+ {%-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-%} + {%- else -%} + {% set patchtype = "moved"%} + {{lineschanged(True, True)}} +
+ {{patch.old_file_path}}
+ {{viewfilelink(patch.new_file_path)}} +
+
file moved
+ {%- 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 in [33188, 33261] -%} + {% set patchtype = "removed"%} +
+ {{ viewfilelink(patch.delta.new_file.path) }} + {{ lineschanged(False, True) }} +
+
file removed
+ + {%-elif patch.delta.new_file.mode in [33188, 33261] + and patch.delta.old_file.mode == 0 -%} + {% set patchtype = "added"%} +
+ {{ viewfilelink(patch.delta.new_file.path) }} + {{ lineschanged(True, False) }} +
+
file added
+ + {%-elif patch.delta.new_file.mode in [33188, 33261] + and patch.delta.old_file.mode in [33188, 33261] -%} + {% set patchtype = "changed"%} +
+ {{ viewfilelink(patch.delta.new_file.path)}} + {{ lineschanged(True, True) }} +
+
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 -%} +
+
+ {% if patchtype == "moved" and linesadded == 0 and linesremoved == 0%} +
+
file was moved with no change to the file
+
+ {% elif patchtype == "added" and linesadded == 0 %} +
+
empty file added
+
+ {% else %} + {% if patchtype == "added" and linesadded > 1000 %} +
+
+ The added file is too large to be shown here, see it at: + {{ viewfilelink(patch_new_file_path) }} +
+
+ {% elif patchtype == "removed" %} +
+
+ The removed file is too large to be shown here, see it at: + {{ viewfilelink(patch_new_file_path, patch_old_id) }} +
+
+ {% else %} + {% autoescape false %} + {{ patch | patch_to_diff | html_diff(linenos=None) | format_loc( + filename=patch_new_file_path, + commit=patch_new_id, + prequest=pull_request, + index=loop.index, + tree_id=diff_commits[0].tree.id)}} + {% endautoescape %} + {% endif %} + {% endif %} + +
+
+ {% endfor %} + {% endif %} + +{%- endmacro %} + diff --git a/pagure/templates/pull_request.html b/pagure/templates/pull_request.html deleted file mode 100644 index f6ad6e7..0000000 --- a/pagure/templates/pull_request.html +++ /dev/null @@ -1,1872 +0,0 @@ -{% extends "repo_master.html" %} -{% from "_formhelper.html" import show_comment, show_pr_initial_comment, render_bootstrap_field %} - -{% block title %} - {%- if pull_request -%} - PR#{{ requestid }}: {{ pull_request.title | noJS(ignore="img") | safe }} - {%- elif form and (g.repo_committer or remote_git) -%} - Create new Pull Request for {{ branch_to }} - {%- elif origin == 'compare_commits' -%} - Diff from {{ commit1 }} to {{ commit2 }} - {%- else -%} - Diff from {{ branch_from }} to {{ branch_to }} - {%- endif - %} - {{ repo.url_path }} -{% endblock %} - -{% set tag = "home" %} - -{% block header %} - - - -{% endblock %} - -{% block repo %} -{% if pull_request %} -
-

-
- {% if pull_request.status == 'Open' %} - - #{{requestid}} - {% elif pull_request.status == 'Merged' %} - - #{{requestid}} - {% elif pull_request.status == 'Closed' %} - - #{{requestid}} - {% endif %} - - {{ pull_request.title | noJS(ignore="img") | safe}} - - {% if g.authenticated and (g.fas_user.username == pull_request.user.username - or g.repo_committer) and pull_request.status == 'Open'%} - - {% endif %} -
-
- - {% if pull_request.status == 'Open' %} - - Opened {{ pull_request.date_created |humanize }} - - by {{ pull_request.user.user }}. - - Modified {{ pull_request.last_updated |humanize }} - - {% elif pull_request.status == 'Merged' %} - - Merged {{ pull_request.closed_at |humanize }} - - by - {{ pull_request.user.user }}. - - Opened {{ pull_request.date_created |humanize }} - - by {{ pull_request.user.user }}. - {% elif pull_request.status == 'Closed' %} - - Cancelled {{ pull_request.closed_at |humanize }} - - by - {{ pull_request.user.user }}. - - Opened {{ pull_request.date_created |humanize }} - - by {{ pull_request.user.user }}. - {% endif %} - -
-
- - {% if pull_request.remote_git or pull_request.project_from.is_fork %} - - {% if pull_request.remote_git %} - - {{pull_request.remote_git}} - {% elif pull_request.project_from.is_fork %} - - {% if pull_request.project_from.namespace %} - {{pull_request.project_from.namespace}}/ - {% endif %} - {% if pull_request.project_from.is_fork -%} - {{ pull_request.project_from.user.user }}/ - {%- endif -%} - {{pull_request.project_from.name}} - {% endif %} - - {% endif %} - - - {{ pull_request.branch_from }} - -  into  - - - {{ pull_request.branch }} - - -
- - -

-
- {% if g.authenticated and (g.fas_user.username == pull_request.user.username - or g.repo_committer) and pull_request.status == 'Open'%} - {% if pull_request.status == 'Open' and g.authenticated and - (g.repo_committer or g.fas_user.username == pull_request.user.username) %} - {% if mergeform and pull_request.remote %} -
- - {{ mergeform.csrf_token }} -
- {% endif %} - -
- {% endif %} - - {% if pull_request.status == 'Open' and g.authenticated and - (g.repo_committer or g.fas_user.username == pull_request.user.username) %} - {{ mergeform.csrf_token }} - - {% endif %} - {% if pull_request.status == 'Open' and g.authenticated and - (g.repo_committer or g.fas_user.username == pull_request.user.username) %} -
- {% endif %} - {% endif %} - {% if pull_request.status == 'Open' %} - - {% endif %} - {% if pull_request.status == 'Closed' and g.authenticated and - (g.repo_committer or g.fas_user.username == pull_request.user.username) %} -
- {{ mergeform.csrf_token }} - -
- {% endif %} -
-
-{% elif form and (g.repo_committer or remote_git) %} -

Create pull request

-{% else %} -

Diff - (tree)

- - {% if origin == 'compare_commits' %} -
{{ commit1 }} .. {{ commit2 }}
- {% endif %} -{% endif%} - - -
-
- -{% if form and (g.repo_committer or remote_git) %} -
- {% if remote_git %} -
- - - {% else %} - - {% endif %} -
- Pull from - {% - if remote_git -%}{{ remote_git }}{%- - else -%} - {{ repo.fullname }} {%- - endif -%} - - - - - - into - - - {#{ parent.fullname }#} - -   - -
- {% if contributing %} -
- {{ contributing | markdown | noJS | safe}} -
- {% endif %} - {{ render_bootstrap_field(form.title) }} -
- - - Preview - - {{ form.initial_comment(class_="form-control")|safe }} -
- - {% if form.initial_comment.errors %} - - - {% for error in form.initial_comment.errors %} - {{ error }}  - {% endfor %} - - - {% endif %} -
- -
-

- - {{ form.csrf_token }} - - Cancel - -

-
-
-{% endif %} - - - -
- -
-
- {% for commit in diff_commits %} - - {% if pull_request and pull_request.status and pull_request.project_from.is_fork %} - {% set commit_link = url_for( - 'ui_ns.view_commit', - repo=pull_request.project_from.name, - username=pull_request.project_from.user.user, - namespace=repo.namespace, - commitid=commit.oid.hex)%} - {% set tree_link = url_for( - 'ui_ns.view_tree', username=pull_request.project_from.user.user, namespace=repo.namespace, - repo=repo.name, identifier=commit.hex) %} - {% elif pull_request and pull_request.remote %} - {% set commit_link = None %} - {% else %} - {% set commit_link = url_for('ui_ns.view_commit', - repo=repo.name, - username=username, - namespace=repo.namespace, - commitid=commit.oid.hex) %} - {% set tree_link = url_for( - 'ui_ns.view_tree', username=username, namespace=repo.namespace, - repo=repo.name, identifier=commit.hex) %} - {% endif %} -
-
-
- {% if commit_link %} - - {% endif %} - {{ commit.message.strip().split('\n')[0] }} - {% if commit_link %} - - {% endif %} -
- {{commit.author|author2user_commits( - link=url_for('ui_ns.view_commits', - repo=repo.name, - branchname=branchname, - username=username, - namespace=repo.namespace, - author=commit.author.email), - cssclass="notblue")|safe}} - • - {{ commit.commit_time|humanize }}   -
-
- -
-
- {% else %} -

No commits found

- {% endfor %} -
-
- -
- {% if g.authenticated and pull_request %} -
- {% endif %} - - {% if diff %} - {% set count = 0 %} - {% for patch in diff %} - {% set count = count+1 %} - {% 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('old_id') %} - {% set patch_old_id = patch.old_id %} - {% elif patch |hasattr('delta') %} - {% set patch_old_id = patch.delta.old_file.id %} - {% else %} - {% set patch_old_id = patch.old_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 -%} - - -
-
-
-
- - {% set linesadded = patch.line_stats[1] %} - {% set linesremoved = patch.line_stats[2] %} - - {% macro lineschanged(added, removed) -%} - {%if added%} - +{{linesadded}} - {%endif%} - {%if removed%} - -{{linesremoved}} - {%endif%} - {%endmacro%} - - {% macro viewfilelink(filepath, identifier=False)%} - {% if pull_request and not pull_request.remote %} - {% if not identifier %} - {% set identifier = pull_request.branch_from %} - {% endif %} - {{ - filepath | unicode }} - {% elif not pull_request %} - {% if identifier == False %} - {% set identifier = branch_from %} - {% endif %} - {{ - filepath | unicode }} - {% elif pull_request and pull_request.remote %} - {{ filepath | unicode }} -
- this is a remote pull-request, so we cannot provide you - with a direct link to the file but you can always - - checkout the pull-request locally - to review it entirely. -
- {% endif %} - {% endmacro %} - - {% if patch | hasattr('new_file_path') %} - {%- if patch.new_file_path == patch.old_file_path -%} - {%- if patch.status == 'D' -%} - {% set patchtype = "removed"%} -
- {{ viewfilelink(patch.new_file_path) }} {{ lineschanged(False, True) }} -
-
file removed
- {%-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-%} - {%- else -%} - {% set patchtype = "moved"%} - {{lineschanged(True, True)}} -
- {{patch.old_file_path}}
- {{viewfilelink(patch.new_file_path)}} -
-
file moved
- {%- 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 in [33188, 33261] -%} - {% set patchtype = "removed"%} -
- {{ viewfilelink(patch.delta.new_file.path) }} - {{ lineschanged(False, True) }} -
-
file removed
- - {%-elif patch.delta.new_file.mode in [33188, 33261] - and patch.delta.old_file.mode == 0 -%} - {% set patchtype = "added"%} -
- {{ viewfilelink(patch.delta.new_file.path) }} - {{ lineschanged(True, False) }} -
-
file added
- - {%-elif patch.delta.new_file.mode in [33188, 33261] - and patch.delta.old_file.mode in [33188, 33261] -%} - {% set patchtype = "changed"%} -
- {{ viewfilelink(patch.delta.new_file.path)}} - {{ lineschanged(True, True) }} -
-
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 -%} -
-
- {% if patchtype == "moved" and linesadded == 0 and linesremoved == 0%} -
-
file was moved with no change to the file
-
- {% elif patchtype == "added" and linesadded == 0 %} -
-
empty file added
-
- {% else %} - {% if patchtype == "added" and linesadded > 1000 %} -
-
- The added file is too large to be shown here, see it at: - {{ viewfilelink(patch_new_file_path) }} -
-
- {% elif patchtype == "removed" %} -
-
- The removed file is too large to be shown here, see it at: - {{ viewfilelink(patch_new_file_path, patch_old_id) }} -
-
- {% else %} - {% autoescape false %} - {{ patch | patch_to_diff | html_diff(linenos=None) | format_loc( - filename=patch_new_file_path, - commit=patch_new_id, - prequest=pull_request, - index=loop.index, - tree_id=diff_commits[0].tree.id)}} - {% endautoescape %} - {% endif %} - {% endif %} - -
-
- {% endfor %} - {% endif %} - - {% if g.authenticated and pull_request %} - {{ mergeform.csrf_token }} -
- {% endif %} -
- {% if pull_request %} -
-
-
- {{ show_pr_initial_comment(pull_request, repo, form, username) }} -
- {% if pull_request.comments %} -
- - {% for comment in pull_request.comments %} - {% if comment.commit_id %} -
-
-
- {{ comment.user.user }} commented on line - {{ - comment.line }} of {{ comment.filename }}. -
- {{ - comment.date_created | humanize }}
-
- (Hide) -
- {{ comment.comment }} -
-
-
- {% elif comment.notification %} -
-
- {{ comment.user.default_email | avatar(24) | safe }} -
- {{ comment.comment | markdown | noJS | safe }} -
- {{ - comment.date_created | humanize }} -
-
- {% else %} - {{ show_comment(comment, comment.id, repo, username, - requestid, form) }} - {% endif %} - {% endfor %} - {{ mergeform.csrf_token }} -
- {% endif %} -
- - {% if g.authenticated and mergeform and pull_request %} -
- {% if g.authenticated %} - -
-
-
- Add new comment -
-
- - {% if repo.quick_replies %} - {% include "quick_reply.html" %} - {% endif %} -
-
-
-
- {{ mergeform.csrf_token }} -
- -
-
-
- -
- - {% endif %} -
- {% if pull_request %} -
-

Pull this pull-request locally v

- -
- {% endif %} - {% endif %} - - -
-
- {% if pull_request %} -
-
-
-
Metadata
- {% if g.authenticated and mergeform and pull_request.status == 'Open' - and (g.repo_committer - or g.fas_user.username == pull_request.user.user) %} -
- - -
- {% endif %} -
- {% if g.authenticated and mergeform and pull_request.status == 'Open' - and g.repo_committer %} -
- - {% endif %} - - - {% if g.authenticated and ( - g.repo_user - or g.fas_user.username == pull_request.user.user) %} - - {% endif%} - - - - {% if g.authenticated and mergeform and pull_request.status == 'Open' - and (g.repo_committer - or g.fas_user.username == pull_request.user.user) %} - - -
- {% endif %} -
- - - {% if pull_request.flags %} - - {% endif %} - - {% if g.authenticated %} -
-
-
- Subscribers - {{subscribers|count}} -
- -
- {% if subscribers %} - -
- {% for subscriber in subscribers %} - {{ - subscriber |avatar(size=30, css_class="pb-1") | safe - }} - {% endfor %} - -
- {% endif %} - -
- {% endif %} - -
- {% endif %} - {% if diff and pull_request%} -
-
-
- Changes Summary - {{ diff|length if diff else 0}} -
-
- {% macro changeschangedfile(filepath, added, removed, diffanchor) -%} - -
-
- +{{added}} - -{{removed}} -
-
- file changed -
-
-
- {{filepath}} -
-
- {%- endmacro %} - {% macro changesrenamedfile(oldfilepath, newfilepath, added, removed, diffanchor) -%} - -
-
+{{added}} -{{removed}}
-
file renamed
-
-
- {{oldfilepath}}
- {{newfilepath}} -
-
- {%- endmacro %} - {% macro changesdeletedfile(filepath, added, removed, diffanchor) -%} - -
-
-{{removed}}
-
file removed
-
-
- {{filepath}} -
-
- {%- endmacro %} - {% macro changesaddedfile(filepath, added, removed, diffanchor) -%} - -
-
+{{added}}
-
file added
-
-
- {{filepath}} -
-
- {%- endmacro %} -
- {% for patch in diff %} - {% 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' -%} - {{ changesdeletedfile(patch.new_file_path, linesadded, linesremoved, loop.index) }} - {%-elif patch.status == 'A' -%} - {{ changesaddedfile(patch.new_file_path, linesadded, linesremoved, loop.index) }} - {%-elif patch.status == 'M' -%} - {{ changeschangedfile(patch.new_file_path, linesadded, linesremoved, loop.index) }} - {%-endif-%} - {%- else -%} - {{changesrenamedfile(patch.old_file_path, patch.new_file_path, linesadded, linesremoved, loop.index)}} - {%- 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 in [33188, 33261] -%} - {{ changesdeletedfile(patch.delta.new_file.path, linesadded, linesremoved, loop.index) }} - {%-elif patch.delta.new_file.mode in [33188, 33261] - and patch.delta.old_file.mode == 0 -%} - {{ changesaddedfile(patch.delta.new_file.path, linesadded, linesremoved, loop.index) }} - {%-elif patch.delta.new_file.mode in [33188, 33261] - and patch.delta.old_file.mode in [33188, 33261] -%} - {{ changeschangedfile(patch.delta.new_file.path, linesadded, linesremoved, loop.index) }} - {%-endif-%} - {%- else -%} - {{changesrenamedfile(patch.delta.old_file.path, patch.delta.new_file.path, linesadded, linesremoved, loop.index)}} - {%- endif -%} - {%- endif -%} - {% endfor %} -
-
- {% endif %} -
-
-
- {% endif %} -
- -
- -{# modal to change the target repo #} -{% if form and (g.repo_committer or remote_git) %} - -{% endif %} - - -
-{% endblock %} - -{% block jscripts %} -{{ super() }} - - - - - - - - - - - - - - - - -{% if repo.quick_replies %} - -{% endif %} - - -{% endblock %} diff --git a/pagure/templates/repo_comparecommits.html b/pagure/templates/repo_comparecommits.html new file mode 100644 index 0000000..d8d835b --- /dev/null +++ b/pagure/templates/repo_comparecommits.html @@ -0,0 +1,150 @@ +{% extends "repo_master.html" %} +{% from "_repo_renderdiff.html" import repo_renderdiff %} + +{% block title -%} + Diff from {{ commit1 }} to {{ commit2 }} - {{ repo.url_path }} +{% endblock %} + +{% set tag = "home" %} + +{% block header %} + + + +{% endblock %} + +{% block repo %} +

Diff + (tree)

+
{{ commit1 }} .. {{ commit2 }}
+ + + +
+
+ + + +
+ +
+
+ {% for commit in diff_commits %} + + {% if pull_request and pull_request.status and pull_request.project_from.is_fork %} + {% set commit_link = url_for( + 'ui_ns.view_commit', + repo=pull_request.project_from.name, + username=pull_request.project_from.user.user, + namespace=repo.namespace, + commitid=commit.oid.hex)%} + {% set tree_link = url_for( + 'ui_ns.view_tree', username=pull_request.project_from.user.user, namespace=repo.namespace, + repo=repo.name, identifier=commit.hex) %} + {% elif pull_request and pull_request.remote %} + {% set commit_link = None %} + {% else %} + {% set commit_link = url_for('ui_ns.view_commit', + repo=repo.name, + username=username, + namespace=repo.namespace, + commitid=commit.oid.hex) %} + {% set tree_link = url_for( + 'ui_ns.view_tree', username=username, namespace=repo.namespace, + repo=repo.name, identifier=commit.hex) %} + {% endif %} +
+
+
+ {% if commit_link %} + + {% endif %} + {{ commit.message.strip().split('\n')[0] }} + {% if commit_link %} + + {% endif %} +
+ {{commit.author|author2user_commits( + link=url_for('ui_ns.view_commits', + repo=repo.name, + branchname=branchname, + username=username, + namespace=repo.namespace, + author=commit.author.email), + cssclass="notblue")|safe}} + • + {{ commit.commit_time|humanize }}   +
+
+ +
+
+ {% else %} +

No commits found

+ {% endfor %} +
+
+ +
+ + {{repo_renderdiff(diff=diff, + diff_commits=diff_commits, + pull_request=None, + repo=repo, + username=username, + namespace=namespace)}} + +
+
+
+
+{% endblock %} + +{% block jscripts %} +{{ super() }} + + +{% endblock %} diff --git a/pagure/templates/repo_new_pull_request.html b/pagure/templates/repo_new_pull_request.html new file mode 100644 index 0000000..d92da05 --- /dev/null +++ b/pagure/templates/repo_new_pull_request.html @@ -0,0 +1,378 @@ +{% extends "repo_master.html" %} +{% from "_formhelper.html" import show_comment, show_pr_initial_comment, render_bootstrap_field %} +{% from "_repo_renderdiff.html" import repo_renderdiff %} + +{% block title %} + {%- if pull_request -%} + PR#{{ requestid }}: {{ pull_request.title | noJS(ignore="img") | safe }} + {%- elif form and (g.repo_committer or remote_git) -%} + Create new Pull Request for {{ branch_to }} + {%- else -%} + Diff from {{ branch_from }} to {{ branch_to }} + {%- endif + %} - {{ repo.url_path }} +{% endblock %} + +{% set tag = "home" %} + +{% block header %} + + + +{% endblock %} + +{% block repo %} + +{% if form and (g.repo_committer or remote_git) %} +

Create pull request

+{% else %} +

Diff + (tree)

+ + {% if origin == 'compare_commits' %} +
{{ commit1 }} .. {{ commit2 }}
+ {% endif %} +{% endif%} + + +
+
+ +{% if form and (g.repo_committer or remote_git) %} +
+ {% if remote_git %} +
+ + + {% else %} + + {% endif %} +
+ Pull from + {% + if remote_git -%}{{ remote_git }}{%- + else -%} + {{ repo.fullname }} {%- + endif -%} + + + + + + into + + + {#{ parent.fullname }#} + +   + +
+ {% if contributing %} +
+ {{ contributing | markdown | noJS | safe}} +
+ {% endif %} + {{ render_bootstrap_field(form.title) }} +
+ + + Preview + + {{ form.initial_comment(class_="form-control")|safe }} +
+ + {% if form.initial_comment.errors %} + + + {% for error in form.initial_comment.errors %} + {{ error }}  + {% endfor %} + + + {% endif %} +
+ +
+

+ + {{ form.csrf_token }} + + Cancel + +

+
+
+{% endif %} + + + +
+ +
+
+ {% for commit in diff_commits %} + {% set commit_link = url_for('ui_ns.view_commit', + repo=repo.name, + username=username, + namespace=repo.namespace, + commitid=commit.oid.hex) %} + {% set tree_link = url_for( + 'ui_ns.view_tree', username=username, namespace=repo.namespace, + repo=repo.name, identifier=commit.hex) %} + +
+
+
+ {% if commit_link %} + + {% endif %} + {{ commit.message.strip().split('\n')[0] }} + {% if commit_link %} + + {% endif %} +
+ {{commit.author|author2user_commits( + link=url_for('ui_ns.view_commits', + repo=repo.name, + branchname=branchname, + username=username, + namespace=repo.namespace, + author=commit.author.email), + cssclass="notblue")|safe}} + • + {{ commit.commit_time|humanize }}   +
+
+ +
+
+ {% else %} +

No commits found

+ {% endfor %} +
+
+ +
+ + {{repo_renderdiff(diff=diff, + diff_commits=diff_commits, + pull_request=pull_request, + repo=repo, + username=username, + namespace=namespace)}} + +
+
+ +
+ +{# modal to change the target repo #} + +
+{% endblock %} + +{% block jscripts %} +{{ super() }} + + + + + + + + + + + +{% endblock %} diff --git a/pagure/templates/repo_pull_request.html b/pagure/templates/repo_pull_request.html new file mode 100644 index 0000000..b3b0e00 --- /dev/null +++ b/pagure/templates/repo_pull_request.html @@ -0,0 +1,1508 @@ +{% extends "repo_master.html" %} +{% from "_formhelper.html" import show_comment, show_pr_initial_comment, render_bootstrap_field %} +{% from "_repo_renderdiff.html" import repo_renderdiff %} + +{% block title %} + {%- if pull_request -%} + PR#{{ requestid }}: {{ pull_request.title | noJS(ignore="img") | safe }} + {%- endif + %} - {{ repo.url_path }} +{% endblock %} + +{% set tag = "home" %} + +{% block header %} + + + +{% endblock %} + +{% block repo %} +
+

+
+ {% if pull_request.status == 'Open' %} + + #{{requestid}} + {% elif pull_request.status == 'Merged' %} + + #{{requestid}} + {% elif pull_request.status == 'Closed' %} + + #{{requestid}} + {% endif %} + + {{ pull_request.title | noJS(ignore="img") | safe}} + + {% if g.authenticated and (g.fas_user.username == pull_request.user.username + or g.repo_committer) and pull_request.status == 'Open'%} + + {% endif %} +
+
+ + {% if pull_request.status == 'Open' %} + + Opened {{ pull_request.date_created |humanize }} + + by {{ pull_request.user.user }}. + + Modified {{ pull_request.last_updated |humanize }} + + {% elif pull_request.status == 'Merged' %} + + Merged {{ pull_request.closed_at |humanize }} + + by + {{ pull_request.user.user }}. + + Opened {{ pull_request.date_created |humanize }} + + by {{ pull_request.user.user }}. + {% elif pull_request.status == 'Closed' %} + + Cancelled {{ pull_request.closed_at |humanize }} + + by + {{ pull_request.user.user }}. + + Opened {{ pull_request.date_created |humanize }} + + by {{ pull_request.user.user }}. + {% endif %} + +
+
+ + {% if pull_request.remote_git or pull_request.project_from.is_fork %} + + {% if pull_request.remote_git %} + + {{pull_request.remote_git}} + {% elif pull_request.project_from.is_fork %} + + {% if pull_request.project_from.namespace %} + {{pull_request.project_from.namespace}}/ + {% endif %} + {% if pull_request.project_from.is_fork -%} + {{ pull_request.project_from.user.user }}/ + {%- endif -%} + {{pull_request.project_from.name}} + {% endif %} + + {% endif %} + + + {{ pull_request.branch_from }} + +  into  + + + {{ pull_request.branch }} + + +
+ + +

+
+ {% if g.authenticated and (g.fas_user.username == pull_request.user.username + or g.repo_committer) and pull_request.status == 'Open'%} + {% if pull_request.status == 'Open' and g.authenticated and + (g.repo_committer or g.fas_user.username == pull_request.user.username) %} + {% if mergeform and pull_request.remote %} +
+ + {{ mergeform.csrf_token }} +
+ {% endif %} + +
+ {% endif %} + + {% if pull_request.status == 'Open' and g.authenticated and + (g.repo_committer or g.fas_user.username == pull_request.user.username) %} + {{ mergeform.csrf_token }} + + {% endif %} + {% if pull_request.status == 'Open' and g.authenticated and + (g.repo_committer or g.fas_user.username == pull_request.user.username) %} +
+ {% endif %} + {% endif %} + {% if pull_request.status == 'Open' %} + + {% endif %} + {% if pull_request.status == 'Closed' and g.authenticated and + (g.repo_committer or g.fas_user.username == pull_request.user.username) %} +
+ {{ mergeform.csrf_token }} + +
+ {% endif %} +
+
+ + +
+
+ + + + +
+ +
+
+ {% for commit in diff_commits %} + + {% if pull_request.status and pull_request.project_from.is_fork %} + {% set commit_link = url_for( + 'ui_ns.view_commit', + repo=pull_request.project_from.name, + username=pull_request.project_from.user.user, + namespace=repo.namespace, + commitid=commit.oid.hex)%} + {% set tree_link = url_for( + 'ui_ns.view_tree', username=pull_request.project_from.user.user, namespace=repo.namespace, + repo=repo.name, identifier=commit.hex) %} + {% elif pull_request.remote %} + {% set commit_link = None %} + {% else %} + {% set commit_link = url_for('ui_ns.view_commit', + repo=repo.name, + username=username, + namespace=repo.namespace, + commitid=commit.oid.hex) %} + {% set tree_link = url_for( + 'ui_ns.view_tree', username=username, namespace=repo.namespace, + repo=repo.name, identifier=commit.hex) %} + {% endif %} +
+
+
+ {% if commit_link %} + + {% endif %} + {{ commit.message.strip().split('\n')[0] }} + {% if commit_link %} + + {% endif %} +
+ {{commit.author|author2user_commits( + link=url_for('ui_ns.view_commits', + repo=repo.name, + branchname=branchname, + username=username, + namespace=repo.namespace, + author=commit.author.email), + cssclass="notblue")|safe}} + • + {{ commit.commit_time|humanize }}   +
+
+ +
+
+ {% else %} +

No commits found

+ {% endfor %} +
+
+ +
+ {% if g.authenticated %} +
+ {% endif %} + + {{repo_renderdiff(diff=diff, + diff_commits=diff_commits, + pull_request=pull_request, + repo=repo, + username=username, + namespace=namespace)}} + + {% if g.authenticated %} + {{ mergeform.csrf_token }} +
+ {% endif %} +
+
+
+
+ {{ show_pr_initial_comment(pull_request, repo, form, username) }} +
+ {% if pull_request.comments %} +
+ + {% for comment in pull_request.comments %} + {% if comment.commit_id %} +
+
+
+ {{ comment.user.user }} commented on line + {{ + comment.line }} of {{ comment.filename }}. +
+ {{ + comment.date_created | humanize }}
+
+ (Hide) +
+ {{ comment.comment }} +
+
+
+ {% elif comment.notification %} +
+
+ {{ comment.user.default_email | avatar(24) | safe }} +
+ {{ comment.comment | markdown | noJS | safe }} +
+ {{ + comment.date_created | humanize }} +
+
+ {% else %} + {{ show_comment(comment, comment.id, repo, username, + requestid, form) }} + {% endif %} + {% endfor %} + {{ mergeform.csrf_token }} +
+ {% endif %} +
+ + {% if g.authenticated and mergeform %} +
+ {% if g.authenticated %} + +
+
+
+ Add new comment +
+
+ + {% if repo.quick_replies %} + {% include "quick_reply.html" %} + {% endif %} +
+
+
+
+ {{ mergeform.csrf_token }} +
+ +
+
+
+ +
+ + {% endif %} +
+
+

Pull this pull-request locally v

+ +
+ {% endif %} + + +
+
+
+
+
+
Metadata
+ {% if g.authenticated and mergeform and pull_request.status == 'Open' + and (g.repo_committer + or g.fas_user.username == pull_request.user.user) %} +
+ + +
+ {% endif %} +
+ {% if g.authenticated and mergeform and pull_request.status == 'Open' + and g.repo_committer %} +
+ + {% endif %} + + + {% if g.authenticated and ( + g.repo_user + or g.fas_user.username == pull_request.user.user) %} + + {% endif%} + + + + {% if g.authenticated and mergeform and pull_request.status == 'Open' + and (g.repo_committer + or g.fas_user.username == pull_request.user.user) %} + + +
+ {% endif %} +
+ + + {% if pull_request.flags %} + + {% endif %} + + {% if g.authenticated %} +
+
+
+ Subscribers + {{subscribers|count}} +
+ +
+ {% if subscribers %} + +
+ {% for subscriber in subscribers %} + {{ + subscriber |avatar(size=30, css_class="pb-1") | safe + }} + {% endfor %} + +
+ {% endif %} + +
+ {% endif %} + +
+ {% if diff %} +
+
+
+ Changes Summary + {{ diff|length if diff else 0}} +
+
+ {% macro changeschangedfile(filepath, added, removed, diffanchor) -%} + +
+
+ +{{added}} + -{{removed}} +
+
+ file changed +
+
+
+ {{filepath}} +
+
+ {%- endmacro %} + {% macro changesrenamedfile(oldfilepath, newfilepath, added, removed, diffanchor) -%} + +
+
+{{added}} -{{removed}}
+
file renamed
+
+
+ {{oldfilepath}}
+ {{newfilepath}} +
+
+ {%- endmacro %} + {% macro changesdeletedfile(filepath, added, removed, diffanchor) -%} + +
+
-{{removed}}
+
file removed
+
+
+ {{filepath}} +
+
+ {%- endmacro %} + {% macro changesaddedfile(filepath, added, removed, diffanchor) -%} + +
+
+{{added}}
+
file added
+
+
+ {{filepath}} +
+
+ {%- endmacro %} +
+ {% for patch in diff %} + {% 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' -%} + {{ changesdeletedfile(patch.new_file_path, linesadded, linesremoved, loop.index) }} + {%-elif patch.status == 'A' -%} + {{ changesaddedfile(patch.new_file_path, linesadded, linesremoved, loop.index) }} + {%-elif patch.status == 'M' -%} + {{ changeschangedfile(patch.new_file_path, linesadded, linesremoved, loop.index) }} + {%-endif-%} + {%- else -%} + {{changesrenamedfile(patch.old_file_path, patch.new_file_path, linesadded, linesremoved, loop.index)}} + {%- 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 in [33188, 33261] -%} + {{ changesdeletedfile(patch.delta.new_file.path, linesadded, linesremoved, loop.index) }} + {%-elif patch.delta.new_file.mode in [33188, 33261] + and patch.delta.old_file.mode == 0 -%} + {{ changesaddedfile(patch.delta.new_file.path, linesadded, linesremoved, loop.index) }} + {%-elif patch.delta.new_file.mode in [33188, 33261] + and patch.delta.old_file.mode in [33188, 33261] -%} + {{ changeschangedfile(patch.delta.new_file.path, linesadded, linesremoved, loop.index) }} + {%-endif-%} + {%- else -%} + {{changesrenamedfile(patch.delta.old_file.path, patch.delta.new_file.path, linesadded, linesremoved, loop.index)}} + {%- endif -%} + {%- endif -%} + {% endfor %} +
+
+ {% endif %} +
+
+
+
+ +
+ +
+{% endblock %} + +{% block jscripts %} +{{ super() }} + + + + + + + + + + + + + + + + +{% if repo.quick_replies %} + +{% endif %} + + +{% endblock %} diff --git a/pagure/ui/fork.py b/pagure/ui/fork.py index bbb5301..2629790 100644 --- a/pagure/ui/fork.py +++ b/pagure/ui/fork.py @@ -279,7 +279,7 @@ def request_pull(repo, requestid, username=None, namespace=None): and pagure.utils.is_repo_committer(request.project_from) ) return flask.render_template( - 'pull_request.html', + 'repo_pull_request.html', select='requests', requestid=requestid, repo=repo, @@ -1362,7 +1362,7 @@ def new_request_pull( flask.g.branches = sorted(orig_repo.listall_branches()) return flask.render_template( - 'pull_request.html', + 'repo_new_pull_request.html', select='requests', repo=repo, username=username, @@ -1455,7 +1455,7 @@ def new_remote_request_pull(repo, username=None, namespace=None): if not confirm: flask.g.branches = sorted(orig_repo.listall_branches()) return flask.render_template( - 'pull_request.html', + 'repo_new_pull_request.html', select='requests', repo=repo, username=username, diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index b2cfc4e..bce65c5 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -459,7 +459,7 @@ def compare_commits(repo, commit1, commit2, username=None, namespace=None): diff_commits.reverse() return flask.render_template( - 'pull_request.html', + 'repo_comparecommits.html', select='logs', origin='compare_commits', repo=repo, diff --git a/tests/test_pagure_flask_ui_remote_pr.py b/tests/test_pagure_flask_ui_remote_pr.py index 52be4db..a96ccb9 100644 --- a/tests/test_pagure_flask_ui_remote_pr.py +++ b/tests/test_pagure_flask_ui_remote_pr.py @@ -219,8 +219,10 @@ class PagureRemotePRtests(tests.Modeltests): self.assertIn('

Create pull request

', output_text) self.assertIn( '
', output_text) - self.assertNotIn( + self.assertIn( '
', output_text) + self.assertNotIn( + '
', output_text) # Not saved yet self.session = pagure.lib.create_session(self.dbpath) @@ -244,8 +246,10 @@ class PagureRemotePRtests(tests.Modeltests): output_text) self.assertIn( '
', output_text) - self.assertNotIn( + self.assertIn( '
', output_text) + self.assertNotIn( + '
', output_text) # Show the filename in the diff view self.assertIn(