From ebaf4c48ea278955c5d79c5f37a2039ccb3cf775 Mon Sep 17 00:00:00 2001 From: Gusted Date: Mon, 8 Nov 2021 08:04:13 +0100 Subject: [PATCH] Avoid double imports (#17569) Co-authored-by: Lunny Xiao Co-authored-by: techknowlogick Co-authored-by: wxiaoguang --- .revive.toml | 1 + models/issue.go | 5 ++--- modules/convert/convert.go | 3 +-- modules/migrations/gitea_uploader.go | 5 ++--- routers/api/v1/repo/transfer.go | 3 +-- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.revive.toml b/.revive.toml index 74743d5ef4..499a4051a1 100644 --- a/.revive.toml +++ b/.revive.toml @@ -23,3 +23,4 @@ warningCode = 1 [rule.unexported-return] [rule.indent-error-flow] [rule.errorf] +[rule.duplicated-imports] diff --git a/models/issue.go b/models/issue.go index a27bb1cc7d..0bc1ebd209 100644 --- a/models/issue.go +++ b/models/issue.go @@ -18,7 +18,6 @@ import ( "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/references" - "code.gitea.io/gitea/modules/structs" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/util" @@ -2116,7 +2115,7 @@ func (issue *Issue) ResolveMentionsByVisibility(ctx context.Context, doer *User, } // UpdateIssuesMigrationsByType updates all migrated repositories' issues from gitServiceType to replace originalAuthorID to posterID -func UpdateIssuesMigrationsByType(gitServiceType structs.GitServiceType, originalAuthorID string, posterID int64) error { +func UpdateIssuesMigrationsByType(gitServiceType api.GitServiceType, originalAuthorID string, posterID int64) error { _, err := db.GetEngine(db.DefaultContext).Table("issue"). Where("repo_id IN (SELECT id FROM repository WHERE original_service_type = ?)", gitServiceType). And("original_author_id = ?", originalAuthorID). @@ -2129,7 +2128,7 @@ func UpdateIssuesMigrationsByType(gitServiceType structs.GitServiceType, origina } // UpdateReactionsMigrationsByType updates all migrated repositories' reactions from gitServiceType to replace originalAuthorID to posterID -func UpdateReactionsMigrationsByType(gitServiceType structs.GitServiceType, originalAuthorID string, userID int64) error { +func UpdateReactionsMigrationsByType(gitServiceType api.GitServiceType, originalAuthorID string, userID int64) error { _, err := db.GetEngine(db.DefaultContext).Table("reaction"). Where("original_author_id = ?", originalAuthorID). And(migratedIssueCond(gitServiceType)). diff --git a/modules/convert/convert.go b/modules/convert/convert.go index 3c309a82f8..2960f7741a 100644 --- a/modules/convert/convert.go +++ b/modules/convert/convert.go @@ -15,7 +15,6 @@ import ( "code.gitea.io/gitea/models/login" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" - "code.gitea.io/gitea/modules/structs" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/services/webhook" @@ -158,7 +157,7 @@ func ToVerification(c *git.Commit) *api.PayloadCommitVerification { commitVerification.Payload = c.Signature.Payload } if verif.SigningUser != nil { - commitVerification.Signer = &structs.PayloadUser{ + commitVerification.Signer = &api.PayloadUser{ Name: verif.SigningUser.Name, Email: verif.SigningUser.Email, } diff --git a/modules/migrations/gitea_uploader.go b/modules/migrations/gitea_uploader.go index 62e8924e54..d62ce80c77 100644 --- a/modules/migrations/gitea_uploader.go +++ b/modules/migrations/gitea_uploader.go @@ -20,7 +20,6 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/migrations/base" - "code.gitea.io/gitea/modules/repository" repo_module "code.gitea.io/gitea/modules/repository" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/storage" @@ -111,7 +110,7 @@ func (g *GiteaLocalUploader) CreateRepo(repo *base.Repository, opts base.Migrate } r.DefaultBranch = repo.DefaultBranch - r, err = repository.MigrateRepositoryGitData(g.ctx, owner, r, base.MigrateOptions{ + r, err = repo_module.MigrateRepositoryGitData(g.ctx, owner, r, base.MigrateOptions{ RepoName: g.repoName, Description: repo.Description, OriginalURL: repo.OriginalURL, @@ -341,7 +340,7 @@ func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error { // SyncTags syncs releases with tags in the database func (g *GiteaLocalUploader) SyncTags() error { - return repository.SyncReleasesWithTags(g.repo, g.gitRepo) + return repo_module.SyncReleasesWithTags(g.repo, g.gitRepo) } // CreateIssues creates issues diff --git a/routers/api/v1/repo/transfer.go b/routers/api/v1/repo/transfer.go index 2e052aa4ff..c13a2e4857 100644 --- a/routers/api/v1/repo/transfer.go +++ b/routers/api/v1/repo/transfer.go @@ -12,7 +12,6 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/convert" "code.gitea.io/gitea/modules/log" - "code.gitea.io/gitea/modules/structs" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/web" repo_service "code.gitea.io/gitea/services/repository" @@ -65,7 +64,7 @@ func Transfer(ctx *context.APIContext) { } if newOwner.Type == models.UserTypeOrganization { - if !ctx.User.IsAdmin && newOwner.Visibility == structs.VisibleTypePrivate && !newOwner.HasMemberWithUserID(ctx.User.ID) { + if !ctx.User.IsAdmin && newOwner.Visibility == api.VisibleTypePrivate && !newOwner.HasMemberWithUserID(ctx.User.ID) { // The user shouldn't know about this organization ctx.Error(http.StatusNotFound, "", "The new owner does not exist or cannot be found") return