{% extends "base.html" %}

{% block title %}{{ branch }} - {{ repo }}{% endblock %}
{% block og_title %}{{ branch }} - {{ repo }}{% endblock %}
{% block og_description %}branch {{ branch }} in {{ repo }}{% 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 }}/branches">branches</a></li>
  <li>{{ branch }}</li>
</ul>
{% endblock %}

{% block content %}
<h1>{{ branch }}</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/refs/heads/{{ branch }}" download="{{ repo }}-{{ branch }}.tar.gz"><span class="archive-link">{{ repo }}-{{ branch }}.tar.gz</span><span>tar.gz</span></a></li>
    <li><a href="{{ crate::base_url() }}/{{ repo }}/archive/tar.xz/refs/heads/{{ branch }}" download="{{ repo }}-{{ branch }}.tar.xz"><span class="archive-link">{{ repo }}-{{ branch }}.tar.xz</span><span>tar.xz</span></a></li>
    <li><a href="{{ crate::base_url() }}/{{ repo }}/archive/zip/refs/heads/{{ branch }}" download="{{ repo }}-{{ branch }}.zip"><span class="archive-link">{{ repo }}-{{ branch }}.zip</span><span>zip</span></a></li>
  </ul>
</details>

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

{% if commits.is_empty() %}
<p>No commits.</p>
{% else %}
<div class="commit-log">
  {% for commit in commits %}
  <a href="{{ crate::base_url() }}/{{ repo }}/commits/{{ commit.sha }}" class="commit-row">
    <span class="commit-sha">{{ commit.sha[..8] }}</span>
    <span class="commit-message">{{ commit.message }}</span>
    <span class="commit-meta"><span>{{ commit.author }}</span><span>{{ commit.date }}</span></span>
  </a>
  {% endfor %}
</div>
<nav class="pagination">
  {% if has_prev %}<a href="?page={{ page - 1 }}"><span class="pagination-sym">&lt;</span> <span>newer</span></a>{% else %}<span></span>{% endif %}
  {% if has_next %}<a href="?page={{ page + 1 }}"><span>older</span> <span class="pagination-sym">&gt;</span></a>{% else %}<span></span>{% endif %}
</nav>
{% endif %}
{% endblock %}
