-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move merge actions to notification #9024
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -521,6 +521,44 @@ func (m *webhookNotifier) NotifyPushCommits(pusher *models.User, repo *models.Re | |
} | ||
} | ||
|
||
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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's peculiar that there is no There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also realized this but for this PR I prefer to let it only a refactor. Please feel free to open a new PR to improve them. |
||
} | ||
|
||
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 | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just realizing that
mailer.MailParticipants()
will also mail the users mentioned in the content of the PR. Is that OK or should I change it so it will only do so when action is create issue?