diff options
author | Runxi Yu <me@runxiyu.org> | 2025-03-05 09:32:40 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-03-05 09:47:01 +0800 |
commit | 134b84f2672a9fe3e2e8a92b712261b47c4bd022 (patch) | |
tree | 5d666a509384f210a78b0e691d8f531b71b04875 /http_handle_repo_log.go | |
parent | *: Replace some := with var (diff) | |
download | forge-134b84f2672a9fe3e2e8a92b712261b47c4bd022.tar.gz forge-134b84f2672a9fe3e2e8a92b712261b47c4bd022.tar.zst forge-134b84f2672a9fe3e2e8a92b712261b47c4bd022.zip |
repo/*: Use var instead of :=
Diffstat (limited to '')
-rw-r--r-- | http_handle_repo_log.go | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/http_handle_repo_log.go b/http_handle_repo_log.go index 52762a3..65719e4 100644 --- a/http_handle_repo_log.go +++ b/http_handle_repo_log.go @@ -7,20 +7,25 @@ import ( "net/http" "github.com/go-git/go-git/v5" + "github.com/go-git/go-git/v5/plumbing" + "github.com/go-git/go-git/v5/plumbing/object" ) // TODO: I probably shouldn't include *all* commits here... func handle_repo_log(w http.ResponseWriter, r *http.Request, params map[string]any) { - repo := params["repo"].(*git.Repository) + var repo *git.Repository + var ref_hash plumbing.Hash + var err error + var commits []*object.Commit - ref_hash, err := get_ref_hash_from_type_and_name(repo, params["ref_type"].(string), params["ref_name"].(string)) - if err != nil { + repo = params["repo"].(*git.Repository) + + if ref_hash, err = get_ref_hash_from_type_and_name(repo, params["ref_type"].(string), params["ref_name"].(string)); err != nil { http.Error(w, "Error getting ref hash: "+err.Error(), http.StatusInternalServerError) return } - commits, err := get_recent_commits(repo, ref_hash, -1) - if err != nil { + if commits, err = get_recent_commits(repo, ref_hash, -1); err != nil { http.Error(w, "Error getting recent commits: "+err.Error(), http.StatusInternalServerError) return } |