From c27412e76ea6627d03a57818e116c13ae8687e36 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Tue, 18 Feb 2025 22:59:22 +0800 Subject: http: Refactor more handler code duplication into the router --- http_handle_repo_log.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'http_handle_repo_log.go') diff --git a/http_handle_repo_log.go b/http_handle_repo_log.go index cbc3284..f2c96b4 100644 --- a/http_handle_repo_log.go +++ b/http_handle_repo_log.go @@ -2,16 +2,13 @@ package main import ( "net/http" + + "github.com/go-git/go-git/v5" ) // TODO: I probably shouldn't include *all* commits here... func handle_repo_log(w http.ResponseWriter, r *http.Request, params map[string]any) { - repo, description, err := open_git_repo(r.Context(), params["group_name"].(string), params["repo_name"].(string)) - if err != nil { - http.Error(w, "Error opening repo: "+err.Error(), http.StatusInternalServerError) - return - } - params["repo_description"] = description + repo := params["repo"].(*git.Repository) ref_hash, err := get_ref_hash_from_type_and_name(repo, params["ref_type"].(string), params["ref_name"].(string)) if err != nil { -- cgit v1.2.3