~edwargix/git.sr.ht

79f17dc1783175d967c5bebb16654f78ab1d84bf — наб 4 years ago ec44ef4
Don't 500 in blame.html on out-of-redis blobs

Bad assumption on my part that blob.data would be a str
because !blob.is_binary, somehow never came up in testing
2 files changed, 8 insertions(+), 2 deletions(-)

M gitsrht/blueprints/repo.py
M gitsrht/templates/blame.html
M gitsrht/blueprints/repo.py => gitsrht/blueprints/repo.py +7 -1
@@ 305,6 305,12 @@ def blame(owner, repo, ref, path):
            return redirect(url_for("repo.log",
                owner=repo.owner.canonical_name, repo=repo.name, ref=ref,
                path="/".join(path)))
        try:
            data = blob.data.decode()
        except:
            return redirect(url_for("repo.log",
                owner=repo.owner.canonical_name, repo=repo.name, ref=ref,
                path="/".join(path)))

        try:
            blame = git_repo.blame("/".join(path), newest_commit=orig_commit.oid)


@@ 315,7 321,7 @@ def blame(owner, repo, ref, path):
            abort(400)

        return render_template("blame.html", view="blame", owner=owner,
                repo=repo, ref=ref, path=path, entry=entry, blob=blob,
                repo=repo, ref=ref, path=path, entry=entry, blob=blob, data=data,
                blame=blame, commit=orig_commit, highlight_file=_highlight_file,
                editorconfig=EditorConfig(git_repo, orig_commit.tree, path),
                lookup_user=lookup_user())

M gitsrht/templates/blame.html => gitsrht/templates/blame.html +1 -1
@@ 106,7 106,7 @@ pre, body {
        >{{loop.index}}</a>
{% endfor %}</pre>
      {{ highlight_file(repo, ref, entry.name,
        blob.data, blob.id.hex, commit.id.hex) }}
        data, blob.id.hex, commit.id.hex) }}
    </div>
  </div>
</div>