diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-04-08 17:11:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-08 17:11:15 +0800 |
commit | 1dfa26e00e8e1ce6f6125335871da1d402a63466 (patch) | |
tree | d39414fb085ae52d6633ae9d064aabab2e7f75f8 /modules | |
parent | 84ceaa98bd731431c7d3a7f65e59e7ad076a540f (diff) | |
download | gitea-1dfa26e00e8e1ce6f6125335871da1d402a63466.tar.gz gitea-1dfa26e00e8e1ce6f6125335871da1d402a63466.zip |
Move milestone to models/issues/ (#19278)
* Move milestone to models/issues/
* Fix lint
* Fix test
* Fix lint
* Fix lint
Diffstat (limited to 'modules')
-rw-r--r-- | modules/convert/issue.go | 5 | ||||
-rw-r--r-- | modules/convert/issue_test.go | 3 | ||||
-rw-r--r-- | modules/convert/pull.go | 2 | ||||
-rw-r--r-- | modules/notification/action/action.go | 5 | ||||
-rw-r--r-- | modules/notification/mail/mail.go | 2 | ||||
-rw-r--r-- | modules/notification/webhook/webhook.go | 11 |
6 files changed, 16 insertions, 12 deletions
diff --git a/modules/convert/issue.go b/modules/convert/issue.go index 4972b070a7..6cdb10f7da 100644 --- a/modules/convert/issue.go +++ b/modules/convert/issue.go @@ -11,6 +11,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/db" + issues_model "code.gitea.io/gitea/models/issues" repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/log" @@ -29,7 +30,7 @@ func ToAPIIssue(issue *models.Issue) *api.Issue { if err := issue.LoadPoster(); err != nil { return &api.Issue{} } - if err := issue.LoadRepo(); err != nil { + if err := issue.LoadRepo(db.DefaultContext); err != nil { return &api.Issue{} } if err := issue.Repo.GetOwner(db.DefaultContext); err != nil { @@ -214,7 +215,7 @@ func ToLabelList(labels []*models.Label, repo *repo_model.Repository, org *user_ } // ToAPIMilestone converts Milestone into API Format -func ToAPIMilestone(m *models.Milestone) *api.Milestone { +func ToAPIMilestone(m *issues_model.Milestone) *api.Milestone { apiMilestone := &api.Milestone{ ID: m.ID, State: m.State(), diff --git a/modules/convert/issue_test.go b/modules/convert/issue_test.go index fb75413eab..b237c18f69 100644 --- a/modules/convert/issue_test.go +++ b/modules/convert/issue_test.go @@ -10,6 +10,7 @@ import ( "time" "code.gitea.io/gitea/models" + issues_model "code.gitea.io/gitea/models/issues" repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/setting" @@ -32,7 +33,7 @@ func TestLabel_ToLabel(t *testing.T) { } func TestMilestone_APIFormat(t *testing.T) { - milestone := &models.Milestone{ + milestone := &issues_model.Milestone{ ID: 3, RepoID: 4, Name: "milestoneName", diff --git a/modules/convert/pull.go b/modules/convert/pull.go index cea1028e16..9c53afe8f3 100644 --- a/modules/convert/pull.go +++ b/modules/convert/pull.go @@ -27,7 +27,7 @@ func ToAPIPullRequest(ctx context.Context, pr *models.PullRequest, doer *user_mo err error ) - if err = pr.Issue.LoadRepo(); err != nil { + if err = pr.Issue.LoadRepo(ctx); err != nil { log.Error("pr.Issue.LoadRepo[%d]: %v", pr.ID, err) return nil } diff --git a/modules/notification/action/action.go b/modules/notification/action/action.go index bab28db475..547498a9dc 100644 --- a/modules/notification/action/action.go +++ b/modules/notification/action/action.go @@ -10,6 +10,7 @@ import ( "strings" "code.gitea.io/gitea/models" + "code.gitea.io/gitea/models/db" repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/graceful" @@ -37,7 +38,7 @@ func (a *actionNotifier) NotifyNewIssue(issue *models.Issue, mentions []*user_mo log.Error("issue.LoadPoster: %v", err) return } - if err := issue.LoadRepo(); err != nil { + if err := issue.LoadRepo(db.DefaultContext); err != nil { log.Error("issue.LoadRepo: %v", err) return } @@ -130,7 +131,7 @@ func (a *actionNotifier) NotifyNewPullRequest(pull *models.PullRequest, mentions log.Error("pull.LoadIssue: %v", err) return } - if err := pull.Issue.LoadRepo(); err != nil { + if err := pull.Issue.LoadRepo(db.DefaultContext); err != nil { log.Error("pull.Issue.LoadRepo: %v", err) return } diff --git a/modules/notification/mail/mail.go b/modules/notification/mail/mail.go index b74482fbf7..6636d18b99 100644 --- a/modules/notification/mail/mail.go +++ b/modules/notification/mail/mail.go @@ -161,7 +161,7 @@ func (m *mailNotifier) NotifyPullRequestPushCommits(doer *user_model.User, pr *m log.Error("comment.LoadIssue: %v", err) return } - if err = comment.Issue.LoadRepo(); err != nil { + if err = comment.Issue.LoadRepo(ctx); err != nil { log.Error("comment.Issue.LoadRepo: %v", err) return } diff --git a/modules/notification/webhook/webhook.go b/modules/notification/webhook/webhook.go index 94d4d180be..d24440d585 100644 --- a/modules/notification/webhook/webhook.go +++ b/modules/notification/webhook/webhook.go @@ -8,6 +8,7 @@ import ( "fmt" "code.gitea.io/gitea/models" + "code.gitea.io/gitea/models/db" packages_model "code.gitea.io/gitea/models/packages" "code.gitea.io/gitea/models/perm" repo_model "code.gitea.io/gitea/models/repo" @@ -46,7 +47,7 @@ func (m *webhookNotifier) NotifyIssueClearLabels(doer *user_model.User, issue *m return } - if err := issue.LoadRepo(); err != nil { + if err := issue.LoadRepo(ctx); err != nil { log.Error("LoadRepo: %v", err) return } @@ -282,7 +283,7 @@ func (m *webhookNotifier) NotifyIssueChangeStatus(doer *user_model.User, issue * } func (m *webhookNotifier) NotifyNewIssue(issue *models.Issue, mentions []*user_model.User) { - if err := issue.LoadRepo(); err != nil { + if err := issue.LoadRepo(db.DefaultContext); err != nil { log.Error("issue.LoadRepo: %v", err) return } @@ -311,7 +312,7 @@ func (m *webhookNotifier) NotifyNewPullRequest(pull *models.PullRequest, mention log.Error("pull.LoadIssue: %v", err) return } - if err := pull.Issue.LoadRepo(); err != nil { + if err := pull.Issue.LoadRepo(ctx); err != nil { log.Error("pull.Issue.LoadRepo: %v", err) return } @@ -507,7 +508,7 @@ func (m *webhookNotifier) NotifyIssueChangeLabels(doer *user_model.User, issue * var err error - if err = issue.LoadRepo(); err != nil { + if err = issue.LoadRepo(ctx); err != nil { log.Error("LoadRepo: %v", err) return } @@ -634,7 +635,7 @@ func (*webhookNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *use return } - if err := pr.Issue.LoadRepo(); err != nil { + if err := pr.Issue.LoadRepo(ctx); err != nil { log.Error("pr.Issue.LoadRepo: %v", err) return } |