M gitsrht/blueprints/api.py => gitsrht/blueprints/api.py +7 -3
@@ 48,7 48,7 @@ def tree_to_dict(t):
{
"name": e.name,
"id": str(e.id),
- "type": e.type,
+ "type": (e.type_str if hasattr(e, "type_str") else e.type),
"mode": e.filemode,
} for e in t
]
@@ 144,7 144,9 @@ def repo_tree_GET(username, reponame, ref, path):
if not tree or part not in tree:
abort(404)
entry = tree[part]
- if entry.type == "blob":
+ etype = (entry.type_str
+ if hasattr(entry, "type_str") else entry.type)
+ if etype == "blob":
abort(404)
tree = git_repo.get(entry.id)
if not tree:
@@ 209,7 211,9 @@ def repo_blob_GET(username, reponame, ref, path):
if part not in tree:
abort(404)
entry = tree[part]
- if entry.type == "blob":
+ etype = (entry.type_str
+ if hasattr(entry, "type_str") else entry.type)
+ if etype == "blob":
tree = annotate_tree(git_repo, tree, commit)
commit = next(e.commit for e in tree if e.name == entry.name)
blob = git_repo.get(entry.id)
M gitsrht/blueprints/repo.py => gitsrht/blueprints/repo.py +6 -2
@@ 175,7 175,9 @@ def tree(owner, repo, ref, path):
if not tree or part not in tree:
abort(404)
entry = tree[part]
- if entry.type == "blob":
+ etype = (entry.type_str
+ if hasattr(entry, "type_str") else entry.type)
+ if etype == "blob":
tree = annotate_tree(git_repo, tree, commit)
commit = next(
(e.commit for e in tree if e.name == entry.name), None)
@@ 217,7 219,9 @@ def raw_blob(owner, repo, ref, path):
if part not in tree:
abort(404)
entry = tree[part]
- if entry.type == "blob":
+ etype = (entry.type_str
+ if hasattr(entry, "type_str") else entry.type)
+ if etype == "blob":
tree = annotate_tree(git_repo, tree, commit)
commit = next(e.commit for e in tree if e.name == entry.name)
blob = git_repo.get(entry.id)
M gitsrht/editorconfig.py => gitsrht/editorconfig.py +6 -2
@@ 20,7 20,9 @@ class EditorConfig:
if not directory in tree:
return None
entry = tree[directory]
- if entry.type != 'tree':
+ etype = (entry.type_str
+ if hasattr(entry, "type_str") else entry.type)
+ if etype != 'tree':
return None
tree = self.repo.get(entry.id)
trees += [tree]
@@ 29,7 31,9 @@ class EditorConfig:
if ".editorconfig" not in tree:
continue
entry = tree[".editorconfig"]
- if entry.type != "blob":
+ etype = (entry.type_str
+ if hasattr(entry, "type_str") else entry.type)
+ if etype != "blob":
continue
blob = self.repo.get(entry.id)
try:
M gitsrht/git.py => gitsrht/git.py +2 -1
@@ 71,7 71,8 @@ class AnnotatedTreeEntry:
if entry:
self.id = entry.id.hex
self.name = entry.name
- self.type = entry.type
+ self.type = (entry.type_str
+ if hasattr(entry, "type_str") else entry.type)
self.filemode = entry.filemode
def fetch_blob(self):