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 }}/{{ repository }}">{{ owner }}/{{ repository }}</a></h1>
    <nav aria-label="Repository">
      <a href="/{{ owner }}/{{ repository }}">Summary</a>
      <a href="/{{ owner }}/{{ repository }}/refs">Refs</a>
      <a href="/{{ owner }}/{{ repository }}/issues">Issues</a>
      <a href="/{{ owner }}/{{ repository }}/pulls">Pull requests</a>
      <a href="/{{ owner }}/{{ repository }}/watch">Watch</a>
    </nav>
  </header>

  <article>
    <h2>#{{ pull_request.number }} {{ pull_request.title }}</h2>
    <p>{{ pull_request.state }} · opened by {{ pull_request.author }} at <time>{{ pull_request.created_at }}</time> · updated <time>{{ pull_request.updated_at }}</time></p>
    <p>Base: <code>{{ pull_request.base_ref }}</code> at <code>{{ pull_request.base_object_id }}</code></p>
    <p>Head: <code>{{ pull_request.head_ref }}</code> at <code>{{ pull_request.head_object_id }}</code></p>
    <p>Fetch: <code>git fetch origin refs/pull/{{ pull_request.number }}/head</code></p>
    <div class="markdown">{{ body_html|safe }}</div>
  </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>{{ revision.head_object_id }}</code> against <code>{{ revision.base_object_id }}</code> at <time>{{ revision.created_at }}</time>.
{% 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 id="review-{{ review.id }}">
      <h3>{{ review.author }}: {{ review.kind }} at <time>{{ review.created_at }}</time></h3>
      <p>Revision {{ review.revision }}
{% if review.kind == "line-comment" %}
        · <code>{{ review.commit_object_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 %}
  </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 }} at <time>{{ event.created_at }}</time></li>
{% endfor %}
    </ol>
  </section>

  <section aria-labelledby="comparison-heading">
    <h2 id="comparison-heading">Comparison for revision {{ selected_revision }}</h2>
    <p>Merge base: <code>{{ comparison.merge_base }}</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>{{ commit.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>
        </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_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 %}