diff options
Diffstat (limited to 'http_handle_repo_raw.go')
-rw-r--r-- | http_handle_repo_raw.go | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/http_handle_repo_raw.go b/http_handle_repo_raw.go index a0f7430..e398856 100644 --- a/http_handle_repo_raw.go +++ b/http_handle_repo_raw.go @@ -14,62 +14,62 @@ import ( "github.com/go-git/go-git/v5/plumbing/object" ) -func handle_repo_raw(w http.ResponseWriter, r *http.Request, params map[string]any) { - var raw_path_spec, path_spec string +func httpHandleRepoRaw(w http.ResponseWriter, r *http.Request, params map[string]any) { + var rawPathSpec, pathSpec string var repo *git.Repository - var ref_hash plumbing.Hash - var commit_object *object.Commit + var refHash plumbing.Hash + var commitObj *object.Commit var tree *object.Tree var err error - raw_path_spec = params["rest"].(string) - repo, path_spec = params["repo"].(*git.Repository), strings.TrimSuffix(raw_path_spec, "/") - params["path_spec"] = path_spec + rawPathSpec = params["rest"].(string) + repo, pathSpec = params["repo"].(*git.Repository), strings.TrimSuffix(rawPathSpec, "/") + params["path_spec"] = pathSpec - if ref_hash, err = get_ref_hash_from_type_and_name(repo, params["ref_type"].(string), params["ref_name"].(string)); err != nil { + if refHash, err = getRefHash(repo, params["ref_type"].(string), params["ref_name"].(string)); err != nil { http.Error(w, "Error getting ref hash: "+err.Error(), http.StatusInternalServerError) return } - if commit_object, err = repo.CommitObject(ref_hash); err != nil { + if commitObj, err = repo.CommitObject(refHash); err != nil { http.Error(w, "Error getting commit object: "+err.Error(), http.StatusInternalServerError) return } - if tree, err = commit_object.Tree(); err != nil { + if tree, err = commitObj.Tree(); err != nil { http.Error(w, "Error getting file tree: "+err.Error(), http.StatusInternalServerError) return } var target *object.Tree - if path_spec == "" { + if pathSpec == "" { target = tree } else { - if target, err = tree.Tree(path_spec); err != nil { + if target, err = tree.Tree(pathSpec); err != nil { var file *object.File - var file_contents string - if file, err = tree.File(path_spec); err != nil { + var fileContent string + if file, err = tree.File(pathSpec); err != nil { http.Error(w, "Error retrieving path: "+err.Error(), http.StatusInternalServerError) return } - if len(raw_path_spec) != 0 && raw_path_spec[len(raw_path_spec)-1] == '/' { - http.Redirect(w, r, "../"+path_spec, http.StatusSeeOther) + if len(rawPathSpec) != 0 && rawPathSpec[len(rawPathSpec)-1] == '/' { + http.Redirect(w, r, "../"+pathSpec, http.StatusSeeOther) return } - if file_contents, err = file.Contents(); err != nil { + if fileContent, err = file.Contents(); err != nil { http.Error(w, "Error reading file: "+err.Error(), http.StatusInternalServerError) return } - fmt.Fprint(w, file_contents) + fmt.Fprint(w, fileContent) return } } - if len(raw_path_spec) != 0 && raw_path_spec[len(raw_path_spec)-1] != '/' { - http.Redirect(w, r, path.Base(path_spec)+"/", http.StatusSeeOther) + if len(rawPathSpec) != 0 && rawPathSpec[len(rawPathSpec)-1] != '/' { + http.Redirect(w, r, path.Base(pathSpec)+"/", http.StatusSeeOther) return } - params["files"] = build_display_git_tree(target) + params["files"] = makeDisplayTree(target) - render_template(w, "repo_raw_dir", params) + renderTemplate(w, "repo_raw_dir", params) } |