From d40fe4e8f008d10a445c49a5fca3e184469163c8 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 1 Oct 2018 09:56:32 -0400 Subject: [PATCH] Flesh out log view a bit Fixes and adds style for tags, annotations, etc --- gitsrht/blueprints/repo.py | 14 ++++++++++---- gitsrht/templates/log.html | 4 ++-- gitsrht/templates/summary.html | 2 +- gitsrht/templates/utils.html | 29 +++++++++++++++++++++-------- scss/main.scss | 24 ++++++++++++++++++++++++ 5 files changed, 58 insertions(+), 15 deletions(-) diff --git a/gitsrht/blueprints/repo.py b/gitsrht/blueprints/repo.py index 0949bc0..0ae2185 100644 --- a/gitsrht/blueprints/repo.py +++ b/gitsrht/blueprints/repo.py @@ -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: diff --git a/gitsrht/templates/log.html b/gitsrht/templates/log.html index 16db9bb..07d8b7a 100644 --- a/gitsrht/templates/log.html +++ b/gitsrht/templates/log.html @@ -6,7 +6,7 @@
{% 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 %}
Next {{icon("caret-right")}}
diff --git a/gitsrht/templates/summary.html b/gitsrht/templates/summary.html index eda83b0..89dda4b 100644 --- a/gitsrht/templates/summary.html +++ b/gitsrht/templates/summary.html @@ -13,7 +13,7 @@
{% for c in commits %} - {{ utils.commit_event(c, commit_time, trim_commit) }} + {{ utils.commit_event(repo, c, commit_time, trim_commit) }} {% endfor %}
diff --git a/gitsrht/templates/utils.html b/gitsrht/templates/utils.html index 012d2ee..629d0e2 100644 --- a/gitsrht/templates/utils.html +++ b/gitsrht/templates/utils.html @@ -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={}) %}
- {{c.id.hex[:8]}} — + {{c.id.hex[:8]}}{{c.author.name}} - - {{ commit_time(c) | date }} - + {{ commit_time(c) | date }} {% if c.id.hex in refs %} {% for ref in refs[c.id.hex] %} - - {{ref.name}} - + {{ref.name}} {% endfor %} {% endif %}
diff --git a/scss/main.scss b/scss/main.scss index a8dc8e3..4a2a7cd 100644 --- a/scss/main.scss +++ b/scss/main.scss @@ -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; + } +} -- 2.38.4