Browse Source

doc_server: pygit2 1.0.0 support

Julen Landa Alustiza 4 years ago
parent
commit
d7427a009f
1 changed files with 7 additions and 1 deletions
  1. 7 1
      pagure/docs_server.py

+ 7 - 1
pagure/docs_server.py

@@ -120,7 +120,13 @@ def __get_tree_and_content(repo_obj, commit, path):
         # Not tested and no idea how to test it, but better safe than sorry
         flask.abort(404, description="File not found")
 
-    if isinstance(blob_or_tree, pygit2.TreeEntry):  # Returned a file
+    is_file = False
+    try:
+        is_file = isinstance(blob_or_tree, pygit2.TreeEntry)
+    except AttributeError:
+        is_file = isinstance(blob_or_tree, pygit2.Blob)
+
+    if is_file:
         filename = blob_or_tree.name
         name, ext = os.path.splitext(filename)
         blob_obj = repo_obj[blob_or_tree.oid]