1
0
Fork 0
forked from forgejo/forgejo

[Port] gitea#29842: Notify reviewers added via CODEOWNERS

Fixes https://github.com/go-gitea/gitea/issues/28297

This PR also fixed a problem that it needs a database transaction when
removing the WIP title.

---

Resolves #2771
Also partially ports gitea#29783

(cherry picked from commit 17d7ab5ad4ce3d0fbc1251572c22687c237a30b1)
This commit is contained in:
Jimmy Praet 2024-03-19 06:28:43 +01:00 committed by Gusted
parent 33d6b5b11a
commit 003881b06d
No known key found for this signature in database
GPG key ID: FD821B732837125F
6 changed files with 310 additions and 104 deletions

View file

@ -74,6 +74,7 @@ func NewPullRequest(ctx context.Context, repo *repo_model.Repository, issue *iss
}
defer baseGitRepo.Close()
var reviewNotifers []*issue_service.ReviewRequestNotifier
if err := db.WithTx(ctx, func(ctx context.Context) error {
if err := issues_model.NewPullRequest(ctx, repo, issue, labelIDs, uuids, pr); err != nil {
return err
@ -133,7 +134,8 @@ func NewPullRequest(ctx context.Context, repo *repo_model.Repository, issue *iss
}
if !pr.IsWorkInProgress(ctx) {
if err := issues_model.PullRequestCodeOwnersReview(ctx, issue, pr); err != nil {
reviewNotifers, err = issue_service.PullRequestCodeOwnersReview(ctx, issue, pr)
if err != nil {
return err
}
}
@ -147,11 +149,12 @@ func NewPullRequest(ctx context.Context, repo *repo_model.Repository, issue *iss
}
baseGitRepo.Close() // close immediately to avoid notifications will open the repository again
issue_service.ReviewRequestNotify(ctx, issue, issue.Poster, reviewNotifers)
mentions, err := issues_model.FindAndUpdateIssueMentions(ctx, issue, issue.Poster, issue.Content)
if err != nil {
return err
}
notify_service.NewPullRequest(ctx, pr, mentions)
if len(issue.Labels) > 0 {
notify_service.IssueChangeLabels(ctx, issue.Poster, issue, issue.Labels, nil)