~edwargix/git.sr.ht

0c2a72230bdbaf7e0d8b527ebe49ae6505c9815d — Drew DeVault 6 years ago 347c613
Add annotated ref page
M gitsrht/blueprints/repo.py => gitsrht/blueprints/repo.py +14 -0
@@ 372,3 372,17 @@ def refs(owner, repo):
            owner=owner, repo=repo, tags=tags, branches=branches,
            git_repo=git_repo, isinstance=isinstance, pygit2=pygit2,
            page=page + 1, total_pages=total_pages)

@repo.route("/<owner>/<repo>/refs/<ref>")
def ref(owner, repo, ref):
    owner, repo = get_repo(owner, repo)
    if not repo:
        abort(404)
    if not has_access(repo, UserAccess.read):
        abort(401)
    git_repo = CachedRepository(repo.path)
    tag = git_repo.revparse_single(ref)
    if not isinstance(tag, pygit2.Tag):
        abort(404)
    return render_template("ref.html", view="refs",
            owner=owner, repo=repo, git_repo=git_repo, tag=tag)

M gitsrht/templates/commit.html => gitsrht/templates/commit.html +16 -14
@@ 16,20 16,22 @@
      </div>
    </div>
    <div class="col-md-2">
      <a
        href="{{url_for("repo.patch",
          owner=repo.owner.canonical_name,
          repo=repo.name,
          ref=commit.id.hex)}}"
        class="btn btn-primary btn-block"
      >patch {{icon("caret-right")}}</a>
      <a
        href="{{url_for("repo.tree",
          owner=repo.owner.canonical_name,
          repo=repo.name,
          ref=commit.id.hex)}}"
        class="btn btn-default btn-block"
      >browse {{icon("caret-right")}}</a>
      <div style="margin-bottom: 1rem">
        <a
          href="{{url_for("repo.patch",
            owner=repo.owner.canonical_name,
            repo=repo.name,
            ref=commit.id.hex)}}"
          class="btn btn-primary btn-block"
        >patch {{icon("caret-right")}}</a>
        <a
          href="{{url_for("repo.tree",
            owner=repo.owner.canonical_name,
            repo=repo.name,
            ref=commit.id.hex)}}"
          class="btn btn-default btn-block"
        >browse {{icon("caret-right")}}</a>
      </div>
    </div>
  </div>
  <div class="row">

A gitsrht/templates/ref.html => gitsrht/templates/ref.html +40 -0
@@ 0,0 1,40 @@
{% extends "repo.html" %}
{% import "utils.html" as utils %}
{% block title %}
<title>{{repo.owner.canonical_name}}/{{repo.name}} {{tag.name}} - {{cfg("sr.ht", "site-name")}} git</title>
{% endblock %}
{% block content %}
<div class="container">
  <div class="row">
    <div class="col-md-8">
      <div class="event-list">
        <div class="event">
          <h3 style="margin-bottom: 0.5rem">
            {{tag.name}}
            <small class="pull-right text-muted">
              {{commit_time(tag) | date}}
            </small>
          </h3>
          {% if tag.message %}
          <pre style="padding-bottom: 0;">{{tag.message}}</pre>
          {% endif %}
        </div>
      </div>
    </div>
    <div class="col-md-4">
      <a
        class="btn btn-primary btn-block"
        href="{{url_for("repo.archive",
          owner=repo.owner.canonical_name,
          repo=repo.name, ref=tag.name)}}"
      >.tar.gz {{icon("caret-right")}}</a>
      <a
        class="btn btn-default btn-block"
        href="{{url_for("repo.tree",
          owner=repo.owner.canonical_name,
          repo=repo.name, ref=tag.name)}}"
      >browse {{icon("caret-right")}}</a>
    </div>
  </div>
</div>
{% endblock %}

M gitsrht/templates/refs.html => gitsrht/templates/refs.html +4 -1
@@ 21,7 21,10 @@
            {% if isinstance(tag, pygit2.Commit) %}
              {{ref[len("refs/tags/"):]}}
            {% else %}
            <a href="#">
            <a href="{{url_for("repo.ref",
                owner=repo.owner.canonical_name,
                repo=repo.name,
                ref=tag.name)}}">
              {{tag.name}}
            </a>
            {% endif %}

M gitsrht/templates/utils.html => gitsrht/templates/utils.html +16 -12
@@ 56,18 56,22 @@ endif %}{% endfor %}
  {% endif %}

  {% if c.id.hex in refs %}
  {% for ref in refs[c.id.hex] %}
  <a
    class="ref {{ref.type}}
      {{"annotated" if ref.type == "tag" and ref.tag.message else ""}}"
    {% if ref.type == "branch" %}
    href="{{url_for("repo.tree",
      owner=repo.owner.canonical_name, repo=repo.name, ref=ref.name)}}"
    {% else %}
    {# TODO: Annotated tag page #}
    href="#"
    {% endif %}
  >{{ref.name}}</a>
  <span style="margin-left: 0.5rem">
    {% for ref in refs[c.id.hex] %}
    <a
      class="ref {{ref.type}}
        {{"annotated" if ref.type == "tag" and ref.tag.message else ""}}"
      {% if ref.type == "branch" %}
      href="{{url_for("repo.tree",
        owner=repo.owner.canonical_name, repo=repo.name, ref=ref.name)}}"
      {% elif ref.type == "tag" %}
      href="{{url_for("repo.ref",
          owner=repo.owner.canonical_name,
          repo=repo.name,
          ref=ref.name)}}"
      {% endif %}
    >{{ref.name}}</a>
  </span>
  {% endfor %}
  {% endif %}
</div>