aboutsummaryrefslogtreecommitdiffstats
path: root/models/issues/pull.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/issues/pull.go')
-rw-r--r--models/issues/pull.go30
1 files changed, 27 insertions, 3 deletions
diff --git a/models/issues/pull.go b/models/issues/pull.go
index 218a265741..3f37d8d243 100644
--- a/models/issues/pull.go
+++ b/models/issues/pull.go
@@ -175,9 +175,10 @@ type PullRequest struct {
ChangedProtectedFiles []string `xorm:"TEXT JSON"`
- IssueID int64 `xorm:"INDEX"`
- Issue *Issue `xorm:"-"`
- Index int64
+ IssueID int64 `xorm:"INDEX"`
+ Issue *Issue `xorm:"-"`
+ Index int64
+ RequestedReviewers []*user_model.User `xorm:"-"`
HeadRepoID int64 `xorm:"INDEX"`
HeadRepo *repo_model.Repository `xorm:"-"`
@@ -302,6 +303,29 @@ func (pr *PullRequest) LoadHeadRepo(ctx context.Context) (err error) {
return nil
}
+// LoadRequestedReviewers loads the requested reviewers.
+func (pr *PullRequest) LoadRequestedReviewers(ctx context.Context) error {
+ if len(pr.RequestedReviewers) > 0 {
+ return nil
+ }
+
+ reviews, err := GetReviewsByIssueID(pr.Issue.ID)
+ if err != nil {
+ return err
+ }
+
+ if len(reviews) > 0 {
+ err = LoadReviewers(ctx, reviews)
+ if err != nil {
+ return err
+ }
+ for _, review := range reviews {
+ pr.RequestedReviewers = append(pr.RequestedReviewers, review.Reviewer)
+ }
+ }
+ return nil
+}
+
// LoadBaseRepo loads the target repository. ErrRepoNotExist may be returned.
func (pr *PullRequest) LoadBaseRepo(ctx context.Context) (err error) {
if pr.BaseRepo != nil {