}
pr.Issue, err = getIssueByID(e, pr.IssueID)
+ if err == nil {
+ pr.Issue.PullRequest = pr
+ }
return err
}
"strings"
"code.gitea.io/gitea/models"
+ "code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification/base"
)
log.Error("notify watchers '%d/%d': %v", review.Reviewer.ID, review.Issue.RepoID, err)
}
}
+
+func (*actionNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *models.User, baseRepo *git.Repository) {
+ if err := models.NotifyWatchers(&models.Action{
+ ActUserID: doer.ID,
+ ActUser: doer,
+ OpType: models.ActionMergePullRequest,
+ Content: fmt.Sprintf("%d|%s", pr.Issue.Index, pr.Issue.Title),
+ RepoID: pr.Issue.Repo.ID,
+ Repo: pr.Issue.Repo,
+ IsPrivate: pr.Issue.Repo.IsPrivate,
+ }); err != nil {
+ log.Error("NotifyWatchers [%d]: %v", pr.ID, err)
+ }
+}
"fmt"
"code.gitea.io/gitea/models"
+ "code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification/base"
"code.gitea.io/gitea/services/mailer"
mailer.SendIssueAssignedMail(issue, doer, ct, comment, []string{assignee.Email})
}
}
+
+func (m *mailNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *models.User, baseRepo *git.Repository) {
+ if err := pr.LoadIssue(); err != nil {
+ log.Error("pr.LoadIssue: %v", err)
+ return
+ }
+
+ if err := mailer.MailParticipants(pr.Issue, doer, models.ActionClosePullRequest); err != nil {
+ log.Error("MailParticipants: %v", err)
+ }
+}
}
}
+func (*webhookNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *models.User, baseRepo *git.Repository) {
+ // Reload pull request information.
+ if err := pr.LoadAttributes(); err != nil {
+ log.Error("LoadAttributes: %v", err)
+ return
+ }
+
+ if err := pr.LoadIssue(); err != nil {
+ log.Error("LoadAttributes: %v", err)
+ return
+ }
+
+ if err := pr.Issue.LoadRepo(); err != nil {
+ log.Error("pr.Issue.LoadRepo: %v", err)
+ return
+ }
+
+ mode, err := models.AccessLevel(doer, pr.Issue.Repo)
+ if err != nil {
+ log.Error("models.AccessLevel: %v", err)
+ return
+ }
+
+ // Merge pull request calls issue.changeStatus so we need to handle separately.
+ apiPullRequest := &api.PullRequestPayload{
+ Index: pr.Issue.Index,
+ PullRequest: pr.APIFormat(),
+ Repository: pr.Issue.Repo.APIFormat(mode),
+ Sender: doer.APIFormat(),
+ Action: api.HookIssueClosed,
+ }
+
+ err = webhook_module.PrepareWebhooks(pr.Issue.Repo, models.HookEventPullRequest, apiPullRequest)
+ if err != nil {
+ log.Error("PrepareWebhooks: %v", err)
+ }
+}
+
func (m *webhookNotifier) NotifyPullRequestReview(pr *models.PullRequest, review *models.Review, comment *models.Comment) {
var reviewHookType models.HookEventType
return
}
- notification.NotifyMergePullRequest(pr, ctx.User, ctx.Repo.GitRepo)
-
log.Trace("Pull request merged: %d", pr.ID)
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index))
}
log.Error("setMerged [%d]: %v", pr.ID, err)
}
- if err := models.NotifyWatchers(&models.Action{
- ActUserID: doer.ID,
- ActUser: doer,
- OpType: models.ActionMergePullRequest,
- Content: fmt.Sprintf("%d|%s", pr.Issue.Index, pr.Issue.Title),
- RepoID: pr.Issue.Repo.ID,
- Repo: pr.Issue.Repo,
- IsPrivate: pr.Issue.Repo.IsPrivate,
- }); err != nil {
- log.Error("NotifyWatchers [%d]: %v", pr.ID, err)
- }
+ notification.NotifyMergePullRequest(pr, doer, baseGitRepo)
// Reset cached commit count
cache.Remove(pr.Issue.Repo.GetCommitsCountCacheKey(pr.BaseBranch, true))
- // Reload pull request information.
- if err = pr.LoadAttributes(); err != nil {
- log.Error("LoadAttributes: %v", err)
- return nil
- }
-
- notification.NotifyIssueChangeStatus(doer, pr.Issue, true)
-
// Resolve cross references
refs, err := pr.ResolveCrossReferences()
if err != nil {