From f27fd16d6fdac1f31f20ee53e48f494d30a72705 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 3 Jan 2020 16:09:44 -0500 Subject: [PATCH] Fix pygit2 1.0 errors with refs --- gitsrht/blueprints/repo.py | 3 +++ gitsrht/templates/refs.html | 10 ++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/gitsrht/blueprints/repo.py b/gitsrht/blueprints/repo.py index 1c212b0..ec3ae48 100644 --- a/gitsrht/blueprints/repo.py +++ b/gitsrht/blueprints/repo.py @@ -480,5 +480,8 @@ def ref(owner, repo, ref): abort(404) except ValueError: abort(404) + if isinstance(tag, pygit2.Commit): + return redirect(url_for(".commit", + owner=owner, repo=repo, ref=tag.id.hex)) return render_template("ref.html", view="refs", owner=owner, repo=repo, git_repo=git_repo, tag=tag) diff --git a/gitsrht/templates/refs.html b/gitsrht/templates/refs.html index dc14e1b..bd79063 100644 --- a/gitsrht/templates/refs.html +++ b/gitsrht/templates/refs.html @@ -36,8 +36,10 @@

{% if isinstance(tag, pygit2.Commit) %} - {{ref[len("refs/tags/"):]}} + {% set ref = commit.id.hex %} + {{ref[len("refs/tags/"):]}} {% else %} + {% set ref = tag.name %} .tar.gz {{icon("caret-right")}} browse {{icon("caret-right")}} log {{icon("caret-right")}}

-- 2.38.4