diff options
author | Frederick Yin <fkfd@macaw.me> | 2020-06-25 20:12:29 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@macaw.me> | 2020-06-25 20:19:06 +0800 |
commit | 6a98cf09349272d1540a821ed048271bae94975a (patch) | |
tree | 217a1a79a6a6ab41e78d511fa2632876aef8895f /git-gmi/gateway.py | |
parent | 0d5ff48ee49971d7b4c21fc42c7cdb5cc829b8bd (diff) |
View commit
Diffstat (limited to 'git-gmi/gateway.py')
-rw-r--r-- | git-gmi/gateway.py | 24 |
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")) |