From ec57d14a3443aa1459e7853a663de582cc25b38c Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 29 Jan 2023 18:22:07 +0800 Subject: [PATCH 1/2] small refactor --- models/issues/pull_list.go | 1 + services/pull/pull.go | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/models/issues/pull_list.go b/models/issues/pull_list.go index 12dbff107d15d..a335bf44858ad 100644 --- a/models/issues/pull_list.go +++ b/models/issues/pull_list.go @@ -175,6 +175,7 @@ func (prs PullRequestList) loadAttributes(ctx context.Context) error { } for i := range prs { prs[i].Issue = set[prs[i].IssueID] + prs[i].Issue.PullRequest = prs[i] // if 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 c983c4f3e78ec..317875d2112d1 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) } } From 6338b67a127e232d6648aab7f9337d63f15ea14b Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 29 Jan 2023 22:00:56 +0800 Subject: [PATCH 2/2] Update models/issues/pull_list.go Co-authored-by: delvh --- models/issues/pull_list.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/models/issues/pull_list.go b/models/issues/pull_list.go index a335bf44858ad..007c2fd90333a 100644 --- a/models/issues/pull_list.go +++ b/models/issues/pull_list.go @@ -173,9 +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] - prs[i].Issue.PullRequest = prs[i] // if panic here, means issueIDs and prs are not in sync + 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 }