summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--git-gmi/git.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/git-gmi/git.py b/git-gmi/git.py
index 9721a6f..034c2b2 100644
--- a/git-gmi/git.py
+++ b/git-gmi/git.py
@@ -111,8 +111,7 @@ class GitGmiRepo:
refs = self.get_refs()
for ref in refs:
response += (
- f"## {ref['shorthand']}\n"
- f"=> tree/{ref['shorthand']}/ view tree\n\n"
+ f"## {ref['shorthand']}\n=> tree/{ref['shorthand']}/ view tree\n\n"
)
return response
@@ -169,7 +168,7 @@ class GitGmiRepo:
{
"type": "dir",
"name": item[0],
- "size": len(item[1]), # number of objects in dir
+ "items": len(item[1]), # number of objects in dir
}
)
@@ -188,13 +187,19 @@ class GitGmiRepo:
def view_tree(self, branch: str, location=[]) -> str:
# actual Gemini response
# consists of a header and a body
- response = f"{STATUS_SUCCESS} {META_GEMINI}\n" + self.generate_header()
tree = self.get_tree(branch)
contents = self.list_tree(tree, location)
+ items = len(contents)
+ response = (
+ f"{STATUS_SUCCESS} {META_GEMINI}\n"
+ + self.generate_header()
+ + f"## {self.name}{'/' if location else ''}{'/'.join(location)}/"
+ f" | {items} {'items' if items > 1 else 'item'}\n\n"
+ )
for item in contents:
if item["type"] == "dir":
response += (
- f"=> {item['name']}/ {item['name']}/ | {item['size']} items\n"
+ f"=> {item['name']}/ {item['name']}/ | {item['items']} items\n"
)
elif item["type"] == "file":
response += f"=> {item['name']} {item['name']} | {convert_filesize(item['size'])}\n"