From 1dfa26e00e8e1ce6f6125335871da1d402a63466 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Fri, 8 Apr 2022 17:11:15 +0800 Subject: Move milestone to models/issues/ (#19278) * Move milestone to models/issues/ * Fix lint * Fix test * Fix lint * Fix lint --- modules/convert/issue.go | 5 +++-- modules/convert/issue_test.go | 3 ++- modules/convert/pull.go | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'modules/convert') 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 } -- cgit v1.2.3