From 8af621955464c2740eed4b3686bd7d45bf465f81cceac852a79d1a9f92a19865 Mon Sep 17 00:00:00 2001 From: Adam Majer Date: Tue, 16 Jul 2024 15:19:14 +0200 Subject: [PATCH] . --- pr-review/main.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pr-review/main.go b/pr-review/main.go index f9d64bc..d16919f 100644 --- a/pr-review/main.go +++ b/pr-review/main.go @@ -5,7 +5,6 @@ import ( "path" "src.opensuse.org/autogits/common" - "src.opensuse.org/autogits/common/gitea-generated/models" ) const ( @@ -29,11 +28,9 @@ func prGitBranchNameForPR(req *common.PullRequestAction) string { return fmt.Sprintf("PR_%s#%d", req.Repository.Name, req.Pull_Request.Number) } -func updateOrCreatePRBranch(h *common.RequestHandler, prjGit *models.Repository, commitMsg, branchName string) { +func updateOrCreatePRBranch(h *common.RequestHandler, commitMsg, branchName string) { req := h.Data.(*common.PullRequestAction) - h.GitExec("", "clone", "--depth", "1", prjGit.SSHURL, common.DefaultGitPrj) - h.GitExec(common.DefaultGitPrj, "checkout", "-B", branchName, prjGit.DefaultBranch) h.GitExec(common.DefaultGitPrj, "submodule", "update", "--init", "--checkout", "--depth", "1", req.Repository.Name) h.GitExec(path.Join(common.DefaultGitPrj, req.Repository.Name), "fetch", "--depth", "1", "origin", req.Pull_Request.Head.Sha) h.GitExec(path.Join(common.DefaultGitPrj, req.Repository.Name), "checkout", req.Pull_Request.Head.Sha) @@ -79,7 +76,7 @@ Update to %s`, req.Pull_Request.Head.Sha) // we need to update prjgit PR with the new head hash branchName := prGitBranchNameForPR(req) - updateOrCreatePRBranch(h, prjPr.Base.Repo, commitMsg, branchName) + updateOrCreatePRBranch(h, commitMsg, branchName) return h.Error } @@ -107,7 +104,9 @@ PullRequest: %s/%s#%d`, req.Repository.Owner.Username, return h.Error } - updateOrCreatePRBranch(h, prjGit, commitMsg, branchName) + h.GitExec("", "clone", "--depth", "1", prjGit.SSHURL, common.DefaultGitPrj) + h.GitExec(common.DefaultGitPrj, "checkout", "-B", branchName, prjGit.DefaultBranch) + updateOrCreatePRBranch(h, commitMsg, branchName) PR := h.CreatePullRequest(prjGit, branchName, prjGit.DefaultBranch, fmt.Sprintf("Forwarded PR: %s", req.Repository.Name),