{% extends "base.html" %}

{% block title %}{{ sha[..8] }} - {{ repo }}{% endblock %}
{% block og_title %}{{ sha[..8] }} - {{ repo }}{% endblock %}
{% block og_description %}{{ message }}{% endblock %}

{% block breadcrumbs %}
<ul>
  <li><a href="{{ crate::base_url() }}/">{{ crate::hostname() }}</a></li>
  <li><a href="{{ crate::base_url() }}/{{ repo }}">{{ repo }}</a></li>
  <li><a href="{{ crate::base_url() }}/{{ repo }}/commits">commits</a></li>
  <li>{{ sha[..8] }}</li>
</ul>
{% endblock %}

{% block content %}
<h1>{{ sha[..8] }}</h1>

<details>
  <summary><svg class="summary-icon"><use href="#icon-archive"/></svg>Archive</summary>
  <ul>
    <li><a href="{{ crate::base_url() }}/{{ repo }}/archive/tar.gz/{{ sha }}" download="{{ repo }}-{{ sha[..8] }}.tar.gz"><span class="archive-link">{{ repo }}-{{ sha[..8] }}.tar.gz</span><span>tar.gz</span></a></li>
    <li><a href="{{ crate::base_url() }}/{{ repo }}/archive/tar.xz/{{ sha }}" download="{{ repo }}-{{ sha[..8] }}.tar.xz"><span class="archive-link">{{ repo }}-{{ sha[..8] }}.tar.xz</span><span>tar.xz</span></a></li>
    <li><a href="{{ crate::base_url() }}/{{ repo }}/archive/zip/{{ sha }}" download="{{ repo }}-{{ sha[..8] }}.zip"><span class="archive-link">{{ repo }}-{{ sha[..8] }}.zip</span><span>zip</span></a></li>
  </ul>
</details>

<div class="repo-nav">
  <a href="{{ crate::base_url() }}/{{ repo }}/commits/{{ sha }}/tree" class="repo-nav-item">
    <svg class="summary-icon"><use href="#icon-tree"/></svg>
    <span>Tree</span>
    <span class="repo-nav-item-meta">[{{ sha[..8] }}]</span>
    <span class="repo-nav-item-arrow">[&gt;]</span>
  </a>
</div>

{% if !refs.is_empty() %}
<dl class="tag-info">
  <dt>refs</dt>
  <dd>{% for r in refs %}<div class="commit-ref-row"><a href="{{ crate::base_url() }}/{{ repo }}/{% if r.kind == "branch" %}branches{% else %}tags{% endif %}/{{ r.name }}" class="commit-ref commit-ref-{{ r.kind }}">{{ r.name }}</a></div>{% endfor %}</dd>
</dl>
{% endif %}

<dl class="tag-info">
  <dt>commit</dt><dd><a class="commit-sha" href="{{ crate::base_url() }}/{{ repo }}/commits/{{ sha }}">{{ sha }}</a></dd>
  <dt>parent{% if parents.len() != 1 %}s{% endif %}</dt>
  <dd>{% for (parent_sha, _) in parents %}<div class="commit-parent"><a class="commit-sha" href="{{ crate::base_url() }}/{{ repo }}/commits/{{ parent_sha }}">{{ parent_sha }}</a></div>{% endfor %}</dd>
  <dt>author</dt><dd>{{ author }}</dd>
  <dt>date</dt><dd>{{ date }}</dd>
</dl>

<dl class="tag-info">
  <dt>committer</dt><dd>{{ committer }}</dd>
  <dt>date</dt><dd>{{ committer_date }}</dd>
</dl>

{% if files_changed > 0 || lines_added > 0 || lines_removed > 0 %}
<dl class="tag-info">
  <dt>changes</dt><dd>{{ files_changed }}</dd>
  <dt>insertions</dt><dd>{{ lines_added }}</dd>
  <dt>deletions</dt><dd>{{ lines_removed }}</dd>
</dl>
{% endif %}

{% if !message.is_empty() %}
<pre class="message">{{ message }}</pre>
{% endif %}

{% if files_changed > 0 || lines_added > 0 || lines_removed > 0 %}
<div class="diff-files">
{% for fc in file_changes %}
  <details class="diff-file">
    <summary><span class="diff-stat-type diff-stat-{{ fc.change_type }}">{{ fc.change_type }}</span><span class="diff-stat-path">{{ fc.path }}</span></summary>
    {% if !fc.hunks.is_empty() %}
    <div class="diff-hunks">{% for hunk in fc.hunks %}<pre class="diff-hunk">{% for line in hunk %}<span class="diff-line"><span class="diff-line-marker diff-line-{{ line.css_class }}">{{ line.marker }}</span><span>{{ line.content }}</span></span>{% endfor %}</pre>{% endfor %}</div>
    {% endif %}
  </details>
{% endfor %}
</div>
{% endif %}
{% endblock %}
