From 4e946e5a7d79c3a933eefc8584444bc02f52b874 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 2 Feb 2023 11:49:28 +0800 Subject: [PATCH] Small refactor for loading PRs (#22652) --- models/issues/pull_list.go | 5 +++-- services/pull/pull.go | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/models/issues/pull_list.go b/models/issues/pull_list.go index 12dbff107d..007c2fd903 100644 --- a/models/issues/pull_list.go +++ b/models/issues/pull_list.go @@ -173,8 +173,9 @@ func (prs PullRequestList) loadAttributes(ctx context.Context) error { for i := range issues { set[issues[i].ID] = issues[i] } - for i := range prs { - prs[i].Issue = set[prs[i].IssueID] + for _, pr := range prs { + pr.Issue = set[pr.IssueID] + pr.Issue.PullRequest = pr // panic here means issueIDs and prs are not in sync } return nil } diff --git a/services/pull/pull.go b/services/pull/pull.go index c983c4f3e7..317875d211 100644 --- a/services/pull/pull.go +++ b/services/pull/pull.go @@ -298,7 +298,6 @@ func AddTestPullRequestTask(doer *user_model.User, repoID int64, branch string, } } - pr.Issue.PullRequest = pr notification.NotifyPullRequestSynchronized(ctx, doer, pr) } }