aboutsummaryrefslogtreecommitdiff
path: root/http_handle_repo_tree.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-02-14 08:48:07 +0800
committerRunxi Yu <me@runxiyu.org>2025-02-14 08:48:07 +0800
commite347064abe3ce4c90fbad23d36e5d61a149e2389 (patch)
treeb587b82f918800b6ea457ece60d778b39a92dbe1 /http_handle_repo_tree.go
parentREADME.md: Add details in features supported by git repos (diff)
downloadforge-e347064abe3ce4c90fbad23d36e5d61a149e2389.tar.gz
forge-e347064abe3ce4c90fbad23d36e5d61a149e2389.tar.zst
forge-e347064abe3ce4c90fbad23d36e5d61a149e2389.zip
http_*: Refactor to reduce duplication
Diffstat (limited to 'http_handle_repo_tree.go')
-rw-r--r--http_handle_repo_tree.go14
1 files changed, 2 insertions, 12 deletions
diff --git a/http_handle_repo_tree.go b/http_handle_repo_tree.go
index 69bc40f..f5fbaad 100644
--- a/http_handle_repo_tree.go
+++ b/http_handle_repo_tree.go
@@ -2,7 +2,6 @@ package main
import (
"bytes"
- "errors"
"html/template"
"net/http"
"path"
@@ -17,16 +16,7 @@ import (
func handle_repo_tree(w http.ResponseWriter, r *http.Request, params map[string]any) {
raw_path_spec := params["rest"].(string)
group_name, repo_name, path_spec := params["group_name"].(string), params["repo_name"].(string), strings.TrimSuffix(raw_path_spec, "/")
- ref_type, ref_name, err := get_param_ref_and_type(r)
- if err != nil {
- if errors.Is(err, err_no_ref_spec) {
- ref_type = "head"
- } else {
- http.Error(w, "Error querying ref type: "+err.Error(), http.StatusInternalServerError)
- return
- }
- }
- params["ref_type"], params["ref"], params["path_spec"] = ref_type, ref_name, path_spec
+ params["path_spec"] = path_spec
repo, description, err := open_git_repo(r.Context(), group_name, repo_name)
if err != nil {
http.Error(w, "Error opening repo: "+err.Error(), http.StatusInternalServerError)
@@ -34,7 +24,7 @@ func handle_repo_tree(w http.ResponseWriter, r *http.Request, params map[string]
}
params["repo_description"] = description
- ref_hash, err := get_ref_hash_from_type_and_name(repo, ref_type, ref_name)
+ ref_hash, err := get_ref_hash_from_type_and_name(repo, params["ref_type"].(string), params["ref_name"].(string))
if err != nil {
http.Error(w, "Error getting ref hash: "+err.Error(), http.StatusInternalServerError)
return