summaryrefslogtreecommitdiff
path: root/git-gmi/gateway.py
diff options
context:
space:
mode:
Diffstat (limited to 'git-gmi/gateway.py')
-rw-r--r--git-gmi/gateway.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/git-gmi/gateway.py b/git-gmi/gateway.py
index 671d5cd..29f0268 100644
--- a/git-gmi/gateway.py
+++ b/git-gmi/gateway.py
@@ -37,18 +37,15 @@ def handle_cgi_request(path: str, query: str):
if view == "summary":
try:
print(repo.view_summary())
- return
except:
print(STATUS_TEMPORARY_FAILURE)
- return
elif view == "tree":
if len(path_trace) == 2:
# gemini://git.gemini.site/git/cgi/<repo>/tree/
print(f"31 {MAIN_BRANCH}/")
- return
- if len(path_trace) > 2:
+ elif len(path_trace) > 2:
# gemini://git.gemini.site/git/cgi/<repo>/tree/<branch>/
branch = path_trace[2]
@@ -68,18 +65,31 @@ def handle_cgi_request(path: str, query: str):
elif view == "log":
try:
print(repo.view_log())
- return
except:
print(STATUS_TEMPORARY_FAILURE)
+
+ elif view == "commit":
+ try:
+ commit_str = path_trace[2]
+ except IndexError:
+ print("50 No commit id given")
return
+ try:
+ if query == "raw":
+ print(repo.view_raw_commit(commit_str))
+ else:
+ print(repo.view_commit(commit_str))
+ except FileNotFoundError:
+ print("50 No such commit")
+ except:
+ print(STATUS_TEMPORARY_FAILURE)
+
elif view == "refs":
try:
print(repo.view_refs())
- return
except:
print(STATUS_TEMPORARY_FAILURE)
- return
handle_cgi_request(environ.get("PATH_INFO"), environ.get("QUERY_STRING"))