diff --git a/bots-common/gitea_utils.go b/bots-common/gitea_utils.go index babd98f..7166f9c 100644 --- a/bots-common/gitea_utils.go +++ b/bots-common/gitea_utils.go @@ -91,7 +91,7 @@ func (h *RequestHandler) CreateRepositoryIfNotExist(org Organization, repoName s return repo.Payload } -func (h *RequestHandler) CreatePullRequest(repo *models.Repository, srcId, targetId string) *models.PullRequest { +func (h *RequestHandler) CreatePullRequest(repo *models.Repository, srcId, targetId, title, body string) *models.PullRequest { if h.HasError() { return nil } @@ -99,9 +99,12 @@ func (h *RequestHandler) CreatePullRequest(repo *models.Repository, srcId, targe transport := h.allocateGiteaTransport() client := apiclient.New(transport, nil) - var prOptions models.CreatePullRequestOption - prOptions.Base = repo.DefaultBranch - prOptions.Head = srcId + prOptions := models.CreatePullRequestOption{ + Base: repo.DefaultBranch, + Head: srcId, + Title: title, + Body: body, + } pr, err := client.Repository.RepoCreatePullRequest( repository. @@ -136,8 +139,9 @@ func (h *RequestHandler) RequestReviews(pr *models.PullRequest, reviewer string) transport := h.allocateGiteaTransport() client := apiclient.New(transport, nil) - var reviewOptions models.PullReviewRequestOptions - reviewOptions.Reviewers = []string{reviewer} + reviewOptions := models.PullReviewRequestOptions{ + Reviewers: []string{reviewer}, + } review, err := client.Repository.RepoCreatePullReviewRequests( repository. diff --git a/pr-review/main.go b/pr-review/main.go index 6b39580..db3c5eb 100644 --- a/pr-review/main.go +++ b/pr-review/main.go @@ -12,7 +12,6 @@ const ( GitAuthor = "GiteaBot - AutoStaging" PrReview = "pr-review" - ) func processPullRequestOpened(h *common.RequestHandler) error { @@ -45,7 +44,15 @@ PullRequest: %s#%d`, req.Repository.Name, GitAuthor, req.Repository.Name, req.Pu h.GitExec(common.DefaultGitPrj, "commit", "-a", "-m", commitMsg) h.GitExec(common.DefaultGitPrj, "push", "-f", "origin", branchName) - PR := h.CreatePullRequest(prjGit, branchName, prjGit.DefaultBranch) + PR := h.CreatePullRequest(prjGit, branchName, prjGit.DefaultBranch, + fmt.Sprintf("Forwarded PR: %s", req.Repository.Name), + fmt.Sprintf(`This is a forwarded pull request by %s +referencing the following pull request: + +PullRequest: %s#%d +`, GitAuthor, req.Repository.Name, req.Pull_Request.Number), + ) + if h.HasError() { return h.Error }