~edwargix/git.sr.ht

d40fe4e8f008d10a445c49a5fca3e184469163c8 — Drew DeVault 6 years ago b697b7e
Flesh out log view a bit

Fixes and adds style for tags, annotations, etc
M gitsrht/blueprints/repo.py => gitsrht/blueprints/repo.py +10 -4
@@ 241,10 241,15 @@ class _AnnotatedRef:
            self.type = "branch"
            self.name = ref.name[len("refs/heads/"):]
            self.branch = repo.get(ref.target)
            self.commit = self.branch
        elif ref.name.startswith("refs/tags/"):
            self.type = "tag"
            self.name = ref.name[len("refs/tags/"):]
            self.tag = repo.get(ref.target)
            self.tag = repo.get(self.target)
            if isinstance(self.tag, pygit2.Commit):
                self.commit = self.tag
            else:
                self.commit = repo.get(self.tag.target)
        else:
            self.type = None



@@ 265,9 270,10 @@ def log(owner, repo, ref, path):
        _ref = _AnnotatedRef(git_repo, git_repo.references[_ref])
        if not _ref.type:
            continue
        if _ref.target.hex not in refs:
            refs[_ref.target.hex] = []
        refs[_ref.target.hex].append(_ref)
        print(_ref.commit.id.hex, _ref.name)
        if _ref.commit.id.hex not in refs:
            refs[_ref.commit.id.hex] = []
        refs[_ref.commit.id.hex].append(_ref)

    from_id = request.args.get("from")
    if from_id:

M gitsrht/templates/log.html => gitsrht/templates/log.html +2 -2
@@ 6,7 6,7 @@
    <div class="col-md-12">
      <div class="event-list">
        {% for c in commits[:-1] %}
        {{ utils.commit_event(c, commit_time, None, True, refs) }}
        {{ utils.commit_event(repo, c, commit_time, None, True, refs) }}
        {% endfor %}
      </div>
      <a


@@ 16,7 16,7 @@
          repo=repo.name,
          ref=ref,
          path=path,
        )}}?from={{commits[-1].id}}&prev={{commits[0].id}}"
        )}}?from={{commits[-1].id}}"
      >Next {{icon("caret-right")}}</a>
    </div>
</div>

M gitsrht/templates/summary.html => gitsrht/templates/summary.html +1 -1
@@ 13,7 13,7 @@
    <div class="col-md-6">
      <div class="event-list" style="margin-bottom: 0.5rem">
        {% for c in commits %}
        {{ utils.commit_event(c, commit_time, trim_commit) }}
        {{ utils.commit_event(repo, c, commit_time, trim_commit) }}
        {% endfor %}
      </div>
    </div>

M gitsrht/templates/utils.html => gitsrht/templates/utils.html +21 -8
@@ 17,19 17,32 @@
endif %}{% endfor %}
{% endmacro %}

{% macro commit_event(c, commit_time, trim_commit, full_body=False, refs={}) %}
{% macro commit_event(repo, c, commit_time, trim_commit, full_body=False, refs={}) %}
<div class="event">
  <div>
    <a href="#">{{c.id.hex[:8]}}</a> &mdash;
    <a
      href="#"
      title="{{c.id.hex}}"
    >{{c.id.hex[:8]}}</a> &mdash;
    <a href="#">{{c.author.name}}</a>
    <span class="text-muted pull-right">
      {{ commit_time(c) | date }}
    </span>
    <a
      id="log-{{c.id}}"
      href="#log-{{c.id}}"
      class="text-muted pull-right"
    >{{ commit_time(c) | date }}</a>
    {% if c.id.hex in refs %}
    {% for ref in refs[c.id.hex] %}
    <span class="ref {{ref.type}}">
      {{ref.name}}
    </span>
    <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>
    {% endfor %}
    {% endif %}
  </div>

M scss/main.scss => scss/main.scss +24 -0
@@ 106,3 106,27 @@
    }
  }
}

.ref {
  border-width: 1px;
  border-style: solid;
  padding: 0.2rem;

  &.branch {
    border-color: darken($info, 20);
    background: $info;
    color: $white;
  }

  &.tag {
    border-color: darken($primary, 20);
    background: $primary;
    color: $white;
  }

  &.tag.annotated {
    border-color: darken($success, 20);
    background: $success;
    color: $white;
  }
}