diff options
author | Runxi Yu <me@runxiyu.org> | 2025-03-05 10:44:38 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-03-05 10:44:38 +0800 |
commit | a79962edfbc31848d44bffc0fd75676d4c8fdb37 (patch) | |
tree | 1e073d1513df8840aa08a2a2e652be1f78fd60ce | |
parent | repo/contrib/one: Diff against merge base (diff) | |
download | forge-a79962edfbc31848d44bffc0fd75676d4c8fdb37.tar.gz forge-a79962edfbc31848d44bffc0fd75676d4c8fdb37.tar.zst forge-a79962edfbc31848d44bffc0fd75676d4c8fdb37.zip |
repo/contrib/one: var/etc code quality modifications
-rw-r--r-- | http_handle_repo_contrib_one.go | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/http_handle_repo_contrib_one.go b/http_handle_repo_contrib_one.go index 7ed0d6f..f4db20c 100644 --- a/http_handle_repo_contrib_one.go +++ b/http_handle_repo_contrib_one.go @@ -19,7 +19,8 @@ func handle_repo_contrib_one(w http.ResponseWriter, r *http.Request, params map[ var title, status, source_ref, destination_branch string var repo *git.Repository var source_ref_hash plumbing.Hash - var source_commit *object.Commit + var source_commit, destination_commit, merge_base *object.Commit + var merge_bases []*object.Commit mr_id_string = params["mr_id"].(string) mr_id_int64, err := strconv.ParseInt(mr_id_string, 10, strconv.IntSize) @@ -61,19 +62,17 @@ func handle_repo_contrib_one(w http.ResponseWriter, r *http.Request, params map[ return } - destination_commit, err := repo.CommitObject(destination_branch_hash) - if err != nil { + if destination_commit, err = repo.CommitObject(destination_branch_hash); err != nil { http.Error(w, "Error getting destination commit: "+err.Error(), http.StatusInternalServerError) return } params["destination_commit"] = destination_commit - merge_bases, err := source_commit.MergeBase(destination_commit) - if err != nil { + if merge_bases, err = source_commit.MergeBase(destination_commit); err != nil { http.Error(w, "Error getting merge base: "+err.Error(), http.StatusInternalServerError) return } - merge_base := merge_bases[0] + merge_base = merge_bases[0] params["merge_base"] = merge_base patch, err := merge_base.Patch(source_commit) |