.
This commit is contained in:
parent
61b6191af2
commit
8af6219554
@ -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),
|
||||
|
Loading…
Reference in New Issue
Block a user