diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-10-01 09:56:32 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-10-01 09:56:32 -0400 |
commit | d40fe4e8f008d10a445c49a5fca3e184469163c8 (patch) | |
tree | 69c069c02119802918d18cbfb840ff6217e26735 | |
parent | b697b7e51c52579d45b8576514f9e3a4f19ccdad (diff) |
Flesh out log view a bit
Fixes and adds style for tags, annotations, etc
-rw-r--r-- | gitsrht/blueprints/repo.py | 14 | ||||
-rw-r--r-- | gitsrht/templates/log.html | 4 | ||||
-rw-r--r-- | gitsrht/templates/summary.html | 2 | ||||
-rw-r--r-- | gitsrht/templates/utils.html | 29 | ||||
-rw-r--r-- | 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 @@ <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> 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 @@ <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> 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={}) %} <div class="event"> <div> - <a href="#">{{c.id.hex[:8]}}</a> — + <a + href="#" + title="{{c.id.hex}}" + >{{c.id.hex[:8]}}</a> — <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> 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; + } +} |