michal/tit

Browse tree · Show commit · Download archive

Blob: templates/pull_request.html

Raw · Blame

{% extends "base.html" %}
{% block title %}#{{ pull_request.number }} {{ pull_request.title }} · {{ owner }}/{{ repository }} · tit{% endblock %}
{% block content %}
  <header class="repository-header">
    <h1><a href="/{{ owner }}">{{ owner }}</a>/<a href="/{{ owner }}/{{ repository }}">{{ repository }}</a></h1>
{% include "repository-nav.html" %}
  </header>

  <article>
    <h2>#{{ pull_request.number }} {{ pull_request.title }}</h2>
    <p>{{ pull_request.state }} · opened by {{ pull_request.author }} at <time datetime="{{ pull_request.created_at }}">{{ pull_request.created_at|human_time }}</time> · updated <time datetime="{{ pull_request.updated_at }}">{{ pull_request.updated_at|human_time }}</time></p>
    <p>Base: <code>{{ pull_request.base_ref }}</code> at <code title="{{ pull_request.base_object_id }}">{{ pull_request.base_object_id|short_id }}</code></p>
    <p>Head: <code>{{ pull_request.head_ref }}</code> at <code title="{{ pull_request.head_object_id }}">{{ pull_request.head_object_id|short_id }}</code></p>
    <p>Fetch: <code>git fetch origin refs/pull/{{ pull_request.number }}/head</code></p>
    <div class="markdown">{{ body_html|safe }}</div>
{% if can_edit %}
    <details>
      <summary>Edit pull request</summary>
      <form method="post" action="/{{ owner }}/{{ repository }}/pulls/{{ pull_request.number }}/edit">
        <input type="hidden" name="csrf" value="{{ csrf }}">
        <div class="field">
          <label for="pull-request-title">Title</label>
          <input id="pull-request-title" name="title" value="{{ pull_request.title }}" maxlength="200" required>
        </div>
        <div class="field">
          <label for="pull-request-body">Description (Markdown)</label>
          <textarea id="pull-request-body" name="body" maxlength="262144" rows="10">{{ pull_request.body }}</textarea>
        </div>
        <button type="submit">Save pull request</button>
      </form>
    </details>
{% endif %}
{% if can_change_state %}
    <form method="post" action="/{{ owner }}/{{ repository }}/pulls/{{ pull_request.number }}/state">
      <input type="hidden" name="csrf" value="{{ csrf }}">
{% if is_open %}
      <button type="submit" name="state" value="closed">Close pull request</button>
{% else %}
      <button type="submit" name="state" value="open">Reopen pull request</button>
{% endif %}
    </form>
{% endif %}
  </article>

  <section aria-labelledby="revisions-heading">
    <h2 id="revisions-heading">Revisions</h2>
    <ol>
{% for revision in revisions %}
      <li value="{{ revision.number }}">
        {{ revision.author }} recorded <code title="{{ revision.head_object_id }}">{{ revision.head_object_id|short_id }}</code> against <code title="{{ revision.base_object_id }}">{{ revision.base_object_id|short_id }}</code> at <time datetime="{{ revision.created_at }}">{{ revision.created_at|human_time }}</time>.
        <a href="/{{ owner }}/{{ repository }}/pulls/{{ pull_request.number }}/revisions/{{ revision.number }}.patch">Download patch</a>
{% if revision.number == selected_revision %}
        <strong>Selected</strong>
{% else %}
        <a href="/{{ owner }}/{{ repository }}/pulls/{{ pull_request.number }}?revision={{ revision.number }}">Compare this revision</a>
{% endif %}
      </li>
{% endfor %}
    </ol>
  </section>

  <section aria-labelledby="reviews-heading">
    <h2 id="reviews-heading">Reviews</h2>
{% if reviews.is_empty() %}
    <p>This pull request has no review activity.</p>
{% else %}
{% for review in reviews %}
    <article class="comment-card" id="review-{{ review.id }}">
      <h3>{{ review.author }}: {{ review.kind|event_name }} at <time datetime="{{ review.created_at }}">{{ review.created_at|human_time }}</time></h3>
      <p>Revision {{ review.revision }}
{% if review.kind == "line-comment" %}
        · <code title="{{ review.commit_object_id }}">{{ review.commit_object_id|short_id }}</code> · <code>{{ review.path }}</code> · {{ review.side }} line {{ review.line }}
{% if review.outdated %}
        · <strong>Outdated</strong>
{% endif %}
{% endif %}
      </p>
{% if review.has_body %}
      <div class="markdown">{{ review.body_html|safe }}</div>
{% endif %}
    </article>
{% endfor %}
{% endif %}
{% if reviews_has_previous || reviews_has_next %}
    <nav aria-label="Review pages">
{% if reviews_has_previous %}
      <a href="?revision={{ selected_revision }}&amp;reviews_page={{ reviews_previous_page }}&amp;timeline_page={{ timeline_page }}">Newer reviews</a>
{% endif %}
{% if reviews_has_next %}
      <a href="?revision={{ selected_revision }}&amp;reviews_page={{ reviews_next_page }}&amp;timeline_page={{ timeline_page }}">Older reviews</a>
{% endif %}
    </nav>
{% endif %}
  </section>

  <section aria-labelledby="timeline-heading">
    <h2 id="timeline-heading">Timeline</h2>
    <ol>
{% for event in timeline %}
      <li value="{{ event.sequence }}">{{ event.actor }} {{ event.kind|event_name }} at <time datetime="{{ event.created_at }}">{{ event.created_at|human_time }}</time></li>
{% endfor %}
    </ol>
{% if timeline_has_previous || timeline_has_next %}
    <nav aria-label="Timeline pages">
{% if timeline_has_previous %}
      <a href="?revision={{ selected_revision }}&amp;reviews_page={{ reviews_page }}&amp;timeline_page={{ timeline_previous_page }}">Newer events</a>
{% endif %}
{% if timeline_has_next %}
      <a href="?revision={{ selected_revision }}&amp;reviews_page={{ reviews_page }}&amp;timeline_page={{ timeline_next_page }}">Older events</a>
{% endif %}
    </nav>
{% endif %}
  </section>

  <section aria-labelledby="comparison-heading">
    <h2 id="comparison-heading">Comparison for revision {{ selected_revision }}</h2>
    <p>Merge base: <code title="{{ comparison.merge_base }}">{{ comparison.merge_base|short_id }}</code></p>
    <p>Mergeability: {{ comparison.mergeability }}</p>

    <h3>Commits</h3>
{% if comparison.commits.is_empty() %}
    <p>This revision has no commits that are not in the base.</p>
{% else %}
    <ol>
{% for commit in comparison.commits %}
      <li><code title="{{ commit.id }}">{{ commit.id|short_id }}</code> <span class="preserve-whitespace">{{ commit.message }}</span></li>
{% endfor %}
    </ol>
{% endif %}

    <h3>Changed paths</h3>
{% if comparison.changed_paths.is_empty() %}
    <p>This revision does not change a path.</p>
{% else %}
    <ul>
{% for path in comparison.changed_paths %}
      <li><code>{{ path }}</code></li>
{% endfor %}
    </ul>
{% endif %}

    <h3>Diff</h3>
{% for file in comparison.files %}
    <article>
      <h4><code>{{ file.path }}</code></h4>
{% if file.binary %}
      <p>This file has binary content.</p>
{% else %}
      <pre>{{ file.hunks }}</pre>
{% if can_review %}
      <form method="post" action="/{{ owner }}/{{ repository }}/pulls/{{ pull_request.number }}/reviews">
        <input type="hidden" name="csrf" value="{{ csrf }}">
        <input type="hidden" name="revision" value="{{ selected_revision }}">
        <input type="hidden" name="kind" value="line-comment">
        <input type="hidden" name="path-hex" value="{{ file.path_hex }}">
        <div class="field">
          <label for="review-side-{{ file.path_hex }}">Side</label>
          <select id="review-side-{{ file.path_hex }}" name="side">
{% if file.has_base %}
            <option value="base">Base</option>
{% endif %}
{% if file.has_head %}
            <option value="head">Head</option>
{% endif %}
          </select>
        </div>
        <div class="field">
          <label for="review-line-{{ file.path_hex }}">Line</label>
          <input id="review-line-{{ file.path_hex }}" name="line" type="number" min="1" required>
          <p class="field-help">Enter a line number from the selected side in the diff above.</p>
        </div>
        <div class="field">
          <label for="review-body-{{ file.path_hex }}">Line comment (Markdown)</label>
          <textarea id="review-body-{{ file.path_hex }}" name="body" maxlength="262144" rows="4" required></textarea>
        </div>
        <button type="submit">Add line comment</button>
      </form>
{% endif %}
{% endif %}
    </article>
{% endfor %}
  </section>

{% if can_merge %}
{% if comparison.mergeability == "fast-forward" %}
  <section aria-labelledby="merge-heading">
    <h2 id="merge-heading">Merge this pull request</h2>
    <form method="post" action="/{{ owner }}/{{ repository }}/pulls/{{ pull_request.number }}/merge">
      <input type="hidden" name="csrf" value="{{ csrf }}">
      <input type="hidden" name="method" value="fast-forward">
      <fieldset class="confirmation">
        <legend>Merge this pull request?</legend>
        <label><input type="radio" name="confirm" value="no" checked> No</label>
        <label><input type="radio" name="confirm" value="yes"> Yes</label>
      </fieldset>
      <button type="submit">Fast-forward {{ pull_request.base_ref }}</button>
    </form>
  </section>
{% else if comparison.mergeability == "clean merge" %}
  <section aria-labelledby="merge-heading">
    <h2 id="merge-heading">Merge this pull request</h2>
    <form method="post" action="/{{ owner }}/{{ repository }}/pulls/{{ pull_request.number }}/merge">
      <input type="hidden" name="csrf" value="{{ csrf }}">
      <input type="hidden" name="method" value="merge-commit">
      <fieldset class="confirmation">
        <legend>Merge this pull request?</legend>
        <label><input type="radio" name="confirm" value="no" checked> No</label>
        <label><input type="radio" name="confirm" value="yes"> Yes</label>
      </fieldset>
      <button type="submit">Create a merge commit on {{ pull_request.base_ref }}</button>
    </form>
  </section>
{% endif %}
{% endif %}

{% if can_review %}
  <section aria-labelledby="review-heading">
    <h2 id="review-heading">Review this revision</h2>
    <form method="post" action="/{{ owner }}/{{ repository }}/pulls/{{ pull_request.number }}/reviews">
      <input type="hidden" name="csrf" value="{{ csrf }}">
      <input type="hidden" name="revision" value="{{ selected_revision }}">
      <input type="hidden" name="path-hex" value="">
      <input type="hidden" name="side" value="">
      <input type="hidden" name="line" value="">
      <div class="field">
        <label for="review-body">Review comment (Markdown)</label>
        <textarea id="review-body" name="body" maxlength="262144" rows="8"></textarea>
      </div>
      <button name="kind" value="comment" type="submit">Add comment</button>
      <button name="kind" value="approved" type="submit">Approve</button>
      <button name="kind" value="changes-requested" type="submit">Request changes</button>
    </form>
  </section>
{% endif %}

{% if can_revise %}
  <form method="post" action="/{{ owner }}/{{ repository }}/pulls/{{ pull_request.number }}/revisions">
    <input type="hidden" name="csrf" value="{{ csrf }}">
    <button type="submit">Record current branch heads</button>
  </form>
{% endif %}
{% endblock %}