aboutsummaryrefslogtreecommitdiffstats
path: root/models/issues/pull_list.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-01-18 05:03:44 +0800
committerGitHub <noreply@github.com>2023-01-17 15:03:44 -0600
commitdb2286bbb69f5453f5b184a16a9dca999f3f3eb8 (patch)
tree3d425b4e184233b8f776762a0b46e49a12ec1532 /models/issues/pull_list.go
parent60c4725cc2e908bedcbece00cd1efa0be9b7d540 (diff)
downloadgitea-db2286bbb69f5453f5b184a16a9dca999f3f3eb8.tar.gz
gitea-db2286bbb69f5453f5b184a16a9dca999f3f3eb8.zip
some refactor about code comments (#20821)
Diffstat (limited to 'models/issues/pull_list.go')
-rw-r--r--models/issues/pull_list.go27
1 files changed, 3 insertions, 24 deletions
diff --git a/models/issues/pull_list.go b/models/issues/pull_list.go
index 432e848e97..12dbff107d 100644
--- a/models/issues/pull_list.go
+++ b/models/issues/pull_list.go
@@ -12,7 +12,6 @@ import (
"code.gitea.io/gitea/models/unit"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/base"
- "code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"xorm.io/xorm"
@@ -161,7 +160,7 @@ func (prs PullRequestList) loadAttributes(ctx context.Context) error {
}
// Load issues.
- issueIDs := prs.getIssueIDs()
+ issueIDs := prs.GetIssueIDs()
issues := make([]*Issue, 0, len(issueIDs))
if err := db.GetEngine(ctx).
Where("id > 0").
@@ -180,7 +179,8 @@ func (prs PullRequestList) loadAttributes(ctx context.Context) error {
return nil
}
-func (prs PullRequestList) getIssueIDs() []int64 {
+// GetIssueIDs returns all issue ids
+func (prs PullRequestList) GetIssueIDs() []int64 {
issueIDs := make([]int64, 0, len(prs))
for i := range prs {
issueIDs = append(issueIDs, prs[i].IssueID)
@@ -192,24 +192,3 @@ func (prs PullRequestList) getIssueIDs() []int64 {
func (prs PullRequestList) LoadAttributes() error {
return prs.loadAttributes(db.DefaultContext)
}
-
-// InvalidateCodeComments will lookup the prs for code comments which got invalidated by change
-func (prs PullRequestList) InvalidateCodeComments(ctx context.Context, doer *user_model.User, repo *git.Repository, branch string) error {
- if len(prs) == 0 {
- return nil
- }
- issueIDs := prs.getIssueIDs()
- var codeComments []*Comment
- if err := db.GetEngine(ctx).
- Where("type = ? and invalidated = ?", CommentTypeCode, false).
- In("issue_id", issueIDs).
- Find(&codeComments); err != nil {
- return fmt.Errorf("find code comments: %w", err)
- }
- for _, comment := range codeComments {
- if err := comment.CheckInvalidation(repo, doer, branch); err != nil {
- return err
- }
- }
- return nil
-}