From 2ecd0ecba241409777c77531a5f247aee78b54e9 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 17 Nov 2021 16:31:17 +0800 Subject: [PATCH 1/3] go build / format tools --- Makefile | 12 +- build/code-batch-process.go | 284 +++++++++++++++++++++++++ build/codeformat/formatimports.go | 187 ++++++++++++++++ build/codeformat/formatimports_test.go | 127 +++++++++++ build/gitea-format-imports.go | 27 +++ models/db/engine.go | 10 +- routers/web/web.go | 4 +- 7 files changed, 635 insertions(+), 16 deletions(-) create mode 100644 build/code-batch-process.go create mode 100644 build/codeformat/formatimports.go create mode 100644 build/codeformat/formatimports_test.go create mode 100644 build/gitea-format-imports.go diff --git a/Makefile b/Makefile index ecd91680ee222..eea9f7ad53013 100644 --- a/Makefile +++ b/Makefile @@ -58,8 +58,6 @@ else SED_INPLACE := sed -i '' endif -GOFMT ?= gofmt -s - EXTRA_GOFLAGS ?= MAKE_VERSION := $(shell $(MAKE) -v | head -n 1) @@ -127,8 +125,6 @@ ifeq ($(filter $(TAGS_SPLIT),bindata),bindata) GO_SOURCES += $(BINDATA_DEST) endif -GO_SOURCES_OWN := $(filter-out vendor/% %/bindata.go, $(GO_SOURCES)) - #To update swagger use: GO111MODULE=on go get -u github.com/go-swagger/go-swagger/cmd/swagger SWAGGER := $(GO) run -mod=vendor github.com/go-swagger/go-swagger/cmd/swagger SWAGGER_SPEC := templates/swagger/v1_json.tmpl @@ -238,7 +234,7 @@ clean: .PHONY: fmt fmt: @echo "Running go fmt..." - @$(GOFMT) -w $(GO_SOURCES_OWN) + @$(GO) run build/code-batch-process.go gitea-fmt -s -w '{file-list}' .PHONY: vet vet: @@ -298,7 +294,7 @@ misspell-check: $(GO) install github.com/client9/misspell/cmd/misspell@v0.3.4; \ fi @echo "Running misspell-check..." - @misspell -error -i unknwon $(GO_SOURCES_OWN) + @$(GO) run build/code-batch-process.go misspell -error -i unknwon '{file-list}' .PHONY: misspell misspell: @@ -306,12 +302,12 @@ misspell: $(GO) install github.com/client9/misspell/cmd/misspell@v0.3.4; \ fi @echo "Running go misspell..." - @misspell -w -i unknwon $(GO_SOURCES_OWN) + @$(GO) run build/code-batch-process.go misspell -w -i unknwon '{file-list}' .PHONY: fmt-check fmt-check: # get all go files and run go fmt on them - @diff=$$($(GOFMT) -d $(GO_SOURCES_OWN)); \ + @diff=$$($(GO) run build/code-batch-process.go gitea-fmt -s -d '{file-list}'); \ if [ -n "$$diff" ]; then \ echo "Please run 'make fmt' and commit the result:"; \ echo "$${diff}"; \ diff --git a/build/code-batch-process.go b/build/code-batch-process.go new file mode 100644 index 0000000000000..4759baf906991 --- /dev/null +++ b/build/code-batch-process.go @@ -0,0 +1,284 @@ +// Copyright 2021 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +//go:build ignore +// +build ignore + +package main + +import ( + "fmt" + "log" + "os" + "os/exec" + "path/filepath" + "regexp" + "strconv" + "strings" + + "code.gitea.io/gitea/build/codeformat" +) + +// Windows has a limitation for command line arguments, the size can not exceed 32KB. +// So we have to feed the files to some tools (like gofmt/misspell`) batch by batch + +// We also introduce a `gitea-fmt` command, it does better import formatting than gofmt/goimports + +var optionLogVerbose bool + +func logVerbose(msg string, args ...interface{}) { + if optionLogVerbose { + log.Printf(msg, args...) + } +} + +func passThroughCmd(cmd string, args []string) error { + foundCmd, err := exec.LookPath(cmd) + if err != nil { + log.Fatalf("can not find cmd: %s", cmd) + } + c := exec.Cmd{ + Path: foundCmd, + Args: args, + Stdin: os.Stdin, + Stdout: os.Stdout, + Stderr: os.Stderr, + } + return c.Run() +} + +type fileCollector struct { + dirs []string + includePatterns []*regexp.Regexp + excludePatterns []*regexp.Regexp + batchSize int +} + +func newFileCollector(fileFilter string, batchSize int) (*fileCollector, error) { + co := &fileCollector{batchSize: batchSize} + if fileFilter == "go-own" { + co.dirs = []string{ + "build", + "cmd", + "contrib", + "integrations", + "models", + "modules", + "routers", + "services", + "tools", + } + co.includePatterns = append(co.includePatterns, regexp.MustCompile(`.*\.go$`)) + + co.excludePatterns = append(co.excludePatterns, regexp.MustCompile(`.*\bbindata\.go$`)) + co.excludePatterns = append(co.excludePatterns, regexp.MustCompile(`integrations/gitea-repositories-meta`)) + co.excludePatterns = append(co.excludePatterns, regexp.MustCompile(`integrations/migration-test`)) + co.excludePatterns = append(co.excludePatterns, regexp.MustCompile(`modules/git/tests`)) + co.excludePatterns = append(co.excludePatterns, regexp.MustCompile(`models/fixtures`)) + co.excludePatterns = append(co.excludePatterns, regexp.MustCompile(`models/migrations/fixtures`)) + co.excludePatterns = append(co.excludePatterns, regexp.MustCompile(`services/gitdiff/testdata`)) + } + + if co.dirs == nil { + return nil, fmt.Errorf("unknown file-filter: %s", fileFilter) + } + return co, nil +} + +func (fc *fileCollector) matchPatterns(path string, regexps []*regexp.Regexp) bool { + path = strings.ReplaceAll(path, "\\", "/") + for _, re := range regexps { + if re.MatchString(path) { + return true + } + } + return false +} + +func (fc *fileCollector) collectFiles() (res [][]string, err error) { + var batch []string + for _, dir := range fc.dirs { + err = filepath.WalkDir(dir, func(path string, d os.DirEntry, err error) error { + include := len(fc.includePatterns) == 0 || fc.matchPatterns(path, fc.includePatterns) + exclude := fc.matchPatterns(path, fc.excludePatterns) + process := include && !exclude + if !process { + if d.IsDir() { + if exclude { + logVerbose("exclude dir %s", path) + return filepath.SkipDir + } + // for a directory, if it is not excluded explicitly, we should walk into + return nil + } + // for a file, we skip it if it shouldn't be processed + logVerbose("skip process %s", path) + return nil + } + if d.IsDir() { + // skip dir, we don't add dirs to the file list now + return nil + } + if len(batch) >= fc.batchSize { + res = append(res, batch) + batch = nil + } + batch = append(batch, path) + return nil + }) + if err != nil { + return nil, err + } + } + res = append(res, batch) + return res, nil +} + +// substArgFiles expands the {file-list} to a real file list for commands +func substArgFiles(args []string, files []string) []string { + for i, s := range args { + if s == "{file-list}" { + newArgs := append(args[:i], files...) + newArgs = append(newArgs, args[i+1:]...) + return newArgs + } + } + return args +} + +func exitWithCmdErrors(subCmd string, subArgs []string, cmdErrors []error) { + for _, err := range cmdErrors { + if err != nil { + if exitError, ok := err.(*exec.ExitError); ok { + exitCode := exitError.ExitCode() + log.Printf("run command failed (code=%d): %s %v", exitCode, subCmd, subArgs) + os.Exit(exitCode) + } else { + log.Fatalf("run command failed (err=%s) %s %v", err, subCmd, subArgs) + } + } + } +} + +func parseArgs() (mainOptions map[string]string, subCmd string, subArgs []string) { + mainOptions = map[string]string{} + for i := 1; i < len(os.Args); i++ { + arg := os.Args[i] + if arg == "" { + break + } + if arg[0] == '-' { + arg = strings.TrimPrefix(arg, "-") + arg = strings.TrimPrefix(arg, "-") + fields := strings.SplitN(arg, "=", 2) + if len(fields) == 1 { + mainOptions[fields[0]] = "1" + } else { + mainOptions[fields[0]] = fields[1] + } + } else { + subCmd = arg + subArgs = os.Args[i+1:] + break + } + } + return +} + +func showUsage() { + fmt.Printf(`Usage: %[1]s [options] {command} [arguments] + +Options: + --verbose + --file-filter=go-own + --batch-size=100 + +Commands: + %[1]s gofmt ... + %[1]s misspell ... + +Arguments: + {file-list} the file list + +Example: + %[1]s gofmt -s -d {file-list} + +`, "file-batch-exec") +} + +func newFileCollectorFromMainOptions(mainOptions map[string]string) (fc *fileCollector, err error) { + fileFilter := mainOptions["file-filter"] + if fileFilter == "" { + fileFilter = "go-own" + } + batchSize, _ := strconv.Atoi(mainOptions["batch-size"]) + if batchSize == 0 { + batchSize = 100 + } + + return newFileCollector(fileFilter, batchSize) +} + +func containsString(a []string, s string) bool { + for _, v := range a { + if v == s { + return true + } + } + return false +} + +func giteaFormatGoImports(files []string) error { + for _, file := range files { + if err := codeformat.FormatGoImports(file); err != nil { + log.Printf("failed to format go imports: %s, err=%v", file, err) + return err + } + } + return nil +} + +func main() { + mainOptions, subCmd, subArgs := parseArgs() + if subCmd == "" { + showUsage() + os.Exit(1) + } + optionLogVerbose = mainOptions["verbose"] != "" + + fc, err := newFileCollectorFromMainOptions(mainOptions) + if err != nil { + log.Fatalf("can not create file collector: %s", err.Error()) + } + + fileBatches, err := fc.collectFiles() + if err != nil { + log.Fatalf("can not collect files: %s", err.Error()) + } + + processed := 0 + var cmdErrors []error + for _, files := range fileBatches { + if len(files) == 0 { + break + } + substArgs := substArgFiles(subArgs, files) + logVerbose("batch cmd: %s %v", subCmd, substArgs) + switch subCmd { + case "gitea-fmt": + cmdErrors = append(cmdErrors, passThroughCmd("gofmt", substArgs)) + if containsString(subArgs, "-w") { + cmdErrors = append(cmdErrors, giteaFormatGoImports(files)) + } + case "misspell": + cmdErrors = append(cmdErrors, passThroughCmd("misspell", substArgs)) + default: + log.Fatalf("unknown cmd: %s %v", subCmd, subArgs) + } + processed += len(files) + } + + logVerbose("processed %d files", processed) + exitWithCmdErrors(subCmd, subArgs, cmdErrors) +} diff --git a/build/codeformat/formatimports.go b/build/codeformat/formatimports.go new file mode 100644 index 0000000000000..59176500e0527 --- /dev/null +++ b/build/codeformat/formatimports.go @@ -0,0 +1,187 @@ +// Copyright 2021 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package codeformat + +import ( + "bytes" + "errors" + "io" + "os" + "sort" + "strings" +) + +var importPackageGroupOrders = map[string]int{ + "": 1, // internal + "code.gitea.io/gitea/": 2, +} + +var errInvalidCommentBetweenImports = errors.New("comments between imported packages are invalid, please move comments to the end of the package line") + +var importBlockBegin = []byte("\nimport (\n") +var importBlockEnd = []byte("\n)") + +type importLineParsed struct { + group string + pkg string + content string +} + +func parseImportLine(line string) (*importLineParsed, error) { + il := &importLineParsed{content: line} + p1 := strings.IndexRune(line, '"') + if p1 == -1 { + return nil, errors.New("invalid import line: " + line) + } + p1++ + p := strings.IndexRune(line[p1:], '"') + if p == -1 { + return nil, errors.New("invalid import line: " + line) + } + p2 := p1 + p + il.pkg = line[p1:p2] + + pDot := strings.IndexRune(il.pkg, '.') + pSlash := strings.IndexRune(il.pkg, '/') + if pDot != -1 && pDot < pSlash { + il.group = il.pkg[:pSlash] + } + for groupName := range importPackageGroupOrders { + if groupName == "" { + continue // skip internal + } + if strings.HasPrefix(il.pkg, groupName) { + il.group = groupName + } + } + return il, nil +} + +type importLineGroup []*importLineParsed +type importLineGroupMap map[string]importLineGroup + +func formatGoImports(contentBytes []byte) ([]byte, error) { + p1 := bytes.Index(contentBytes, importBlockBegin) + if p1 == -1 { + return nil, nil + } + p1 += len(importBlockBegin) + p := bytes.Index(contentBytes[p1:], importBlockEnd) + if p == -1 { + return nil, nil + } + p2 := p1 + p + + importGroups := importLineGroupMap{} + r := bytes.NewBuffer(contentBytes[p1:p2]) + eof := false + for !eof { + line, err := r.ReadString('\n') + eof = err == io.EOF + if err != nil && !eof { + return nil, err + } + line = strings.TrimSpace(line) + if line != "" { + if strings.HasPrefix(line, "//") || strings.HasPrefix(line, "/*") { + return nil, errInvalidCommentBetweenImports + } + importLine, err := parseImportLine(line) + if err != nil { + return nil, err + } + importGroups[importLine.group] = append(importGroups[importLine.group], importLine) + } + } + + var groupNames []string + for groupName, importLines := range importGroups { + groupNames = append(groupNames, groupName) + sort.Slice(importLines, func(i, j int) bool { + return strings.Compare(importLines[i].pkg, importLines[j].pkg) < 0 + }) + } + + sort.Slice(groupNames, func(i, j int) bool { + n1 := groupNames[i] + n2 := groupNames[j] + o1 := importPackageGroupOrders[n1] + o2 := importPackageGroupOrders[n2] + if o1 != 0 && o2 != 0 { + return o1 < o2 + } + if o1 == 0 && o2 == 0 { + return strings.Compare(n1, n2) < 0 + } + return o1 != 0 + }) + + formattedBlock := bytes.Buffer{} + for _, groupName := range groupNames { + hasNormalImports := false + hasDummyImports := false + // non-dummy import comes first + for _, importLine := range importGroups[groupName] { + if strings.HasPrefix(importLine.content, "_") { + hasDummyImports = true + } else { + formattedBlock.WriteString("\t" + importLine.content + "\n") + hasNormalImports = true + } + } + // dummy (_ "pkg") comes later + if hasDummyImports { + if hasNormalImports { + formattedBlock.WriteString("\n") + } + for _, importLine := range importGroups[groupName] { + if strings.HasPrefix(importLine.content, "_") { + formattedBlock.WriteString("\t" + importLine.content + "\n") + } + } + } + formattedBlock.WriteString("\n") + } + formattedBlockBytes := bytes.TrimRight(formattedBlock.Bytes(), "\n") + + var formattedBytes []byte + formattedBytes = append(formattedBytes, contentBytes[:p1]...) + formattedBytes = append(formattedBytes, formattedBlockBytes...) + formattedBytes = append(formattedBytes, contentBytes[p2:]...) + return formattedBytes, nil +} + +//FormatGoImports format the imports by our rules (see unit tests) +func FormatGoImports(file string) error { + f, err := os.Open(file) + if err != nil { + return err + } + var contentBytes []byte + { + defer f.Close() + contentBytes, err = io.ReadAll(f) + if err != nil { + return err + } + } + formattedBytes, err := formatGoImports(contentBytes) + if err != nil { + return err + } + if formattedBytes == nil { + return nil + } + if bytes.Equal(contentBytes, formattedBytes) { + return nil + } + f, err = os.OpenFile(file, os.O_TRUNC|os.O_WRONLY, 0644) + if err != nil { + return err + } + defer f.Close() + _, err = f.Write(formattedBytes) + return err +} diff --git a/build/codeformat/formatimports_test.go b/build/codeformat/formatimports_test.go new file mode 100644 index 0000000000000..34d0871c50e4e --- /dev/null +++ b/build/codeformat/formatimports_test.go @@ -0,0 +1,127 @@ +// Copyright 2021 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package codeformat + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestFormatImportsSimple(t *testing.T) { + formatted, err := formatGoImports([]byte(` +package codeformat + +import ( + "github.com/stretchr/testify/assert" + "testing" +) +`)) + + expected := ` +package codeformat + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) +` + + assert.NoError(t, err) + assert.Equal(t, expected, string(formatted)) +} + +func TestFormatImportsGroup(t *testing.T) { + // gofmt/goimports won't group the packages, for example, they produce such code: + // "bytes" + // "image" + // (a blank line) + // "fmt" + // "image/color/palette" + // our formatter does better, and these packages are grouped into one. + + formatted, err := formatGoImports([]byte(` +package test + +import ( + "bytes" + "fmt" + "image" + "image/color/palette" + + _ "image/gif" // for processing gif images + _ "image/jpeg" // for processing jpeg images + _ "image/png" // for processing png images + + "code.gitea.io/other/package" + + "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/util" + + "xorm.io/the/package" + + "github.com/issue9/identicon" + "github.com/nfnt/resize" + "github.com/oliamb/cutter" +) +`)) + + expected := ` +package test + +import ( + "bytes" + "fmt" + "image" + "image/color/palette" + + _ "image/gif" // for processing gif images + _ "image/jpeg" // for processing jpeg images + _ "image/png" // for processing png images + + "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/util" + + "code.gitea.io/other/package" + + "github.com/issue9/identicon" + "github.com/nfnt/resize" + "github.com/oliamb/cutter" + + "xorm.io/the/package" +) +` + + assert.NoError(t, err) + assert.Equal(t, expected, string(formatted)) +} + +func TestFormatImportsInvalidComment(t *testing.T) { + // why we shouldn't write comments between imports: it breaks the grouping of imports + // for example: + // "pkg1" + // "pkg2" + // // a comment + // "pkgA" + // "pkgB" + // the comment splits the packages into two groups, pkg1/2 are sorted separately, pkgA/B are sorted separately + // we don't want such code, so the code should be: + // "pkg1" + // "pkg2" + // "pkgA" // a comment + // "pkgB" + + _, err := formatGoImports([]byte(` +package test + +import ( + "image/jpeg" + // for processing gif images + "image/gif" +) +`)) + assert.ErrorIs(t, err, errInvalidCommentBetweenImports) +} diff --git a/build/gitea-format-imports.go b/build/gitea-format-imports.go new file mode 100644 index 0000000000000..67c8397b2d9a9 --- /dev/null +++ b/build/gitea-format-imports.go @@ -0,0 +1,27 @@ +// Copyright 2021 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +//go:build ignore +// +build ignore + +package main + +import ( + "log" + "os" + + "code.gitea.io/gitea/build/codeformat" +) + +func main() { + if len(os.Args) <= 1 { + log.Fatalf("Usage: gitea-format-imports [files...]") + } + + for _, file := range os.Args[1:] { + if err := codeformat.FormatGoImports(file); err != nil { + log.Fatalf("can not format file %s, err=%v", file, err) + } + } +} diff --git a/models/db/engine.go b/models/db/engine.go index e392008020b2c..32ef9fdbafdef 100755 --- a/models/db/engine.go +++ b/models/db/engine.go @@ -16,17 +16,15 @@ import ( "code.gitea.io/gitea/modules/setting" - // Needed for the MySQL driver - _ "github.com/go-sql-driver/mysql" + _ "github.com/go-sql-driver/mysql" // Needed for the MySQL driver "xorm.io/xorm" "xorm.io/xorm/names" "xorm.io/xorm/schemas" - // Needed for the Postgresql driver - _ "github.com/lib/pq" + _ "github.com/lib/pq" // Needed for the Postgresql driver - // Needed for the MSSQL driver - _ "github.com/denisenkom/go-mssqldb" + + _ "github.com/denisenkom/go-mssqldb" // Needed for the MSSQL driver ) var ( diff --git a/routers/web/web.go b/routers/web/web.go index 132e649d45d24..0f1bef3cffd77 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -36,8 +36,8 @@ import ( "code.gitea.io/gitea/services/lfs" "code.gitea.io/gitea/services/mailer" - // to registers all internal adapters - _ "code.gitea.io/gitea/modules/session" + + _ "code.gitea.io/gitea/modules/session" // to registers all internal adapters "gitea.com/go-chi/captcha" "github.com/NYTimes/gziphandler" From 829f78e38841a910d49ab59cc114c2224fe8f27f Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 17 Nov 2021 17:45:48 +0800 Subject: [PATCH 2/3] re-format imports --- cmd/doctor.go | 4 ++-- cmd/dump.go | 1 + cmd/mailer.go | 1 + cmd/web.go | 4 +++- contrib/environment-to-ini/environment-to-ini.go | 1 + contrib/pr/checkout.go | 1 + integrations/api_issue_label_test.go | 3 +-- integrations/api_private_serv_test.go | 1 + integrations/api_pull_commits_test.go | 1 + integrations/api_repo_git_notes_test.go | 1 + integrations/api_team_user_test.go | 1 + integrations/api_user_org_perm_test.go | 1 + integrations/create_no_session_test.go | 1 + integrations/download_test.go | 1 + integrations/eventsource_test.go | 1 + integrations/git_clone_wiki_test.go | 1 + integrations/goget_test.go | 1 + integrations/gpg_git_test.go | 2 ++ integrations/org_count_test.go | 1 + integrations/org_test.go | 1 + integrations/rename_branch_test.go | 1 + integrations/repo_migrate_test.go | 1 + integrations/repofiles_delete_test.go | 3 +-- integrations/signup_test.go | 1 + integrations/user_avatar_test.go | 1 + models/access_test.go | 1 + models/admin_test.go | 1 + models/attachment_test.go | 1 + models/branches_test.go | 1 + models/commit_status_test.go | 1 + models/consistency_test.go | 1 + models/db/engine.go | 10 ++++------ models/db/sql_postgres_with_schema.go | 1 + models/external_login_user.go | 1 + models/gpg_key.go | 1 + models/issue_assignees_test.go | 1 + models/issue_comment_test.go | 1 + models/issue_dependency_test.go | 1 + models/issue_label_test.go | 1 + models/issue_list.go | 1 + models/issue_milestone_test.go | 1 + models/issue_test.go | 1 + models/issue_tracked_time_test.go | 1 + models/issue_user_test.go | 1 + models/issue_watch_test.go | 1 + models/login/oauth2_application.go | 2 ++ models/login/source_test.go | 1 + models/login/twofactor.go | 1 + models/migrations/migrations_test.go | 1 + models/migrations/v142.go | 1 + models/migrations/v144.go | 1 + models/migrations/v166.go | 1 + models/migrations/v175.go | 1 + models/migrations/v177_test.go | 1 + models/migrations/v191.go | 1 + models/migrations/v71.go | 1 + models/notification_test.go | 1 + models/org_team_test.go | 1 + models/pull_test.go | 1 + models/repo.go | 3 ++- models/repo_collaboration_test.go | 1 + models/repo_indexer.go | 1 + models/repo_permission_test.go | 1 + models/repo_redirect_test.go | 1 + models/repo_transfer_test.go | 1 + models/review_test.go | 1 + models/ssh_key.go | 1 + models/ssh_key_deploy.go | 1 + models/ssh_key_fingerprint.go | 1 + models/ssh_key_parse.go | 1 + models/star_test.go | 1 + models/token_test.go | 1 + models/topic_test.go | 1 + models/unittest/consistency.go | 1 + models/unittest/testdb.go | 1 + models/unittest/unit_tests.go | 1 + models/user.go | 3 ++- models/user_email.go | 1 + models/user_follow_test.go | 1 + modules/cache/cache_redis.go | 1 + modules/cache/cache_twoqueue.go | 1 + modules/charset/charset.go | 1 + modules/context/context.go | 2 ++ modules/convert/utils_test.go | 3 ++- modules/doctor/fix16961.go | 1 + modules/doctor/fix16961_test.go | 1 + modules/doctor/misc.go | 1 + modules/git/commit_info_test.go | 1 + modules/git/pipeline/lfs.go | 1 + modules/git/repo_compare_test.go | 1 + modules/git/repo_tag_test.go | 1 + modules/highlight/highlight.go | 1 + modules/highlight/highlight_test.go | 1 + modules/indexer/issues/bleve_test.go | 1 + modules/indexer/issues/indexer_test.go | 4 ++-- modules/indexer/stats/indexer_test.go | 4 ++-- modules/log/console_windows.go | 1 + modules/log/file_test.go | 1 + modules/markup/html.go | 2 ++ modules/markup/markdown/renderconfig.go | 1 + modules/markup/mdstripper/mdstripper.go | 3 +-- modules/markup/renderer_test.go | 1 + modules/notification/action/action_test.go | 1 + modules/queue/queue_disk_channel_test.go | 1 + modules/queue/queue_disk_test.go | 1 + modules/repofiles/blob_test.go | 1 - modules/repofiles/content_test.go | 1 - modules/repofiles/tree_test.go | 1 - modules/repository/commits_test.go | 1 + modules/session/redis.go | 1 + modules/setting/cron_test.go | 1 + modules/setting/queue.go | 1 + modules/setting/setting.go | 2 ++ modules/setting/storage_test.go | 1 + modules/ssh/ssh.go | 1 + modules/translation/translation.go | 1 + modules/validation/binding.go | 1 + modules/validation/binding_test.go | 1 + modules/validation/glob_pattern_test.go | 1 + modules/web/middleware/binding.go | 1 + modules/web/middleware/locale.go | 1 + modules/web/route.go | 1 + routers/api/v1/api.go | 4 +++- routers/install/install.go | 1 + routers/utils/utils_test.go | 1 + routers/web/goget.go | 1 + routers/web/repo/issue_test.go | 1 + routers/web/user/home.go | 1 + routers/web/user/oauth.go | 1 + routers/web/web.go | 2 +- services/auth/signin.go | 3 +-- services/auth/source/oauth2/jwtsigningkey.go | 1 + services/auth/source/oauth2/store.go | 2 ++ services/auth/source/oauth2/token.go | 1 + services/cron/setting.go | 1 + services/forms/user_form_auth_openid.go | 1 + services/gitdiff/csv_test.go | 1 + services/gitdiff/gitdiff.go | 1 + services/gitdiff/gitdiff_test.go | 1 + services/issue/assignee_test.go | 1 + services/issue/label_test.go | 1 + services/mailer/mailer.go | 1 + services/migrations/github.go | 1 + services/repository/fork_test.go | 1 + services/webhook/deliver_test.go | 1 + services/webhook/webhook_test.go | 1 + 146 files changed, 162 insertions(+), 29 deletions(-) diff --git a/cmd/doctor.go b/cmd/doctor.go index 498b859e41842..9afbf1f0d6cb9 100644 --- a/cmd/doctor.go +++ b/cmd/doctor.go @@ -18,9 +18,9 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" - "xorm.io/xorm" - "github.com/urfave/cli" + + "xorm.io/xorm" ) // CmdDoctor represents the available doctor sub-command. diff --git a/cmd/dump.go b/cmd/dump.go index efb9397208594..f6821586d70e0 100644 --- a/cmd/dump.go +++ b/cmd/dump.go @@ -21,6 +21,7 @@ import ( "code.gitea.io/gitea/modules/util" "gitea.com/go-chi/session" + archiver "github.com/mholt/archiver/v3" "github.com/urfave/cli" ) diff --git a/cmd/mailer.go b/cmd/mailer.go index 1a4b0902e268f..a3d6baaa27a5a 100644 --- a/cmd/mailer.go +++ b/cmd/mailer.go @@ -10,6 +10,7 @@ import ( "code.gitea.io/gitea/modules/private" "code.gitea.io/gitea/modules/setting" + "github.com/urfave/cli" ) diff --git a/cmd/web.go b/cmd/web.go index 80516058fb9de..2d57951b07a03 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -9,10 +9,11 @@ import ( "fmt" "net" "net/http" - _ "net/http/pprof" // Used for debugging if enabled and a web server is running "os" "strings" + _ "net/http/pprof" // Used for debugging if enabled and a web server is running + "code.gitea.io/gitea/modules/graceful" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" @@ -20,6 +21,7 @@ import ( "code.gitea.io/gitea/routers/install" "github.com/urfave/cli" + ini "gopkg.in/ini.v1" ) diff --git a/contrib/environment-to-ini/environment-to-ini.go b/contrib/environment-to-ini/environment-to-ini.go index aade251902300..b911d84acff9c 100644 --- a/contrib/environment-to-ini/environment-to-ini.go +++ b/contrib/environment-to-ini/environment-to-ini.go @@ -15,6 +15,7 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/urfave/cli" + ini "gopkg.in/ini.v1" ) diff --git a/contrib/pr/checkout.go b/contrib/pr/checkout.go index 1e2a9714e38a6..bc18eb47b5ca3 100644 --- a/contrib/pr/checkout.go +++ b/contrib/pr/checkout.go @@ -37,6 +37,7 @@ import ( "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/config" "github.com/go-git/go-git/v5/plumbing" + "xorm.io/xorm" ) diff --git a/integrations/api_issue_label_test.go b/integrations/api_issue_label_test.go index 7cb5df812b72e..58e09c818eb7b 100644 --- a/integrations/api_issue_label_test.go +++ b/integrations/api_issue_label_test.go @@ -10,9 +10,8 @@ import ( "strings" "testing" - "code.gitea.io/gitea/models/unittest" - "code.gitea.io/gitea/models" + "code.gitea.io/gitea/models/unittest" api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" diff --git a/integrations/api_private_serv_test.go b/integrations/api_private_serv_test.go index 8d814271cd6b5..c3cb1cf328fe5 100644 --- a/integrations/api_private_serv_test.go +++ b/integrations/api_private_serv_test.go @@ -11,6 +11,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/private" + "github.com/stretchr/testify/assert" ) diff --git a/integrations/api_pull_commits_test.go b/integrations/api_pull_commits_test.go index c537f002085c6..a3d1bee58a0ba 100644 --- a/integrations/api_pull_commits_test.go +++ b/integrations/api_pull_commits_test.go @@ -11,6 +11,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/unittest" api "code.gitea.io/gitea/modules/structs" + "github.com/stretchr/testify/assert" ) diff --git a/integrations/api_repo_git_notes_test.go b/integrations/api_repo_git_notes_test.go index 21b8a931b07da..293bd769f43ec 100644 --- a/integrations/api_repo_git_notes_test.go +++ b/integrations/api_repo_git_notes_test.go @@ -12,6 +12,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/unittest" api "code.gitea.io/gitea/modules/structs" + "github.com/stretchr/testify/assert" ) diff --git a/integrations/api_team_user_test.go b/integrations/api_team_user_test.go index 7e5bb0802e397..e7f4b0ee4c94b 100644 --- a/integrations/api_team_user_test.go +++ b/integrations/api_team_user_test.go @@ -13,6 +13,7 @@ import ( "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/convert" api "code.gitea.io/gitea/modules/structs" + "github.com/stretchr/testify/assert" ) diff --git a/integrations/api_user_org_perm_test.go b/integrations/api_user_org_perm_test.go index abba24701ed17..0dcdbd77adf24 100644 --- a/integrations/api_user_org_perm_test.go +++ b/integrations/api_user_org_perm_test.go @@ -10,6 +10,7 @@ import ( "testing" api "code.gitea.io/gitea/modules/structs" + "github.com/stretchr/testify/assert" ) diff --git a/integrations/create_no_session_test.go b/integrations/create_no_session_test.go index a76ff1eaafb3d..98141288083a9 100644 --- a/integrations/create_no_session_test.go +++ b/integrations/create_no_session_test.go @@ -17,6 +17,7 @@ import ( "code.gitea.io/gitea/routers" "gitea.com/go-chi/session" + "github.com/stretchr/testify/assert" ) diff --git a/integrations/download_test.go b/integrations/download_test.go index 38de75f476a96..f46122d951080 100644 --- a/integrations/download_test.go +++ b/integrations/download_test.go @@ -9,6 +9,7 @@ import ( "testing" "code.gitea.io/gitea/modules/setting" + "github.com/stretchr/testify/assert" ) diff --git a/integrations/eventsource_test.go b/integrations/eventsource_test.go index ead01da8ca8fb..eb08c004a886e 100644 --- a/integrations/eventsource_test.go +++ b/integrations/eventsource_test.go @@ -14,6 +14,7 @@ import ( "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/eventsource" api "code.gitea.io/gitea/modules/structs" + "github.com/stretchr/testify/assert" ) diff --git a/integrations/git_clone_wiki_test.go b/integrations/git_clone_wiki_test.go index 2139ce5fe0dc2..16cee254bcf7c 100644 --- a/integrations/git_clone_wiki_test.go +++ b/integrations/git_clone_wiki_test.go @@ -14,6 +14,7 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/util" + "github.com/stretchr/testify/assert" ) diff --git a/integrations/goget_test.go b/integrations/goget_test.go index 1003d710238e9..5dc9c5e0a8d17 100644 --- a/integrations/goget_test.go +++ b/integrations/goget_test.go @@ -10,6 +10,7 @@ import ( "testing" "code.gitea.io/gitea/modules/setting" + "github.com/stretchr/testify/assert" ) diff --git a/integrations/gpg_git_test.go b/integrations/gpg_git_test.go index ecc253978407f..2099d86ebe233 100644 --- a/integrations/gpg_git_test.go +++ b/integrations/gpg_git_test.go @@ -17,7 +17,9 @@ import ( "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" + "github.com/stretchr/testify/assert" + "golang.org/x/crypto/openpgp" "golang.org/x/crypto/openpgp/armor" ) diff --git a/integrations/org_count_test.go b/integrations/org_count_test.go index c473ecd68aac8..a394dba01c2e9 100644 --- a/integrations/org_count_test.go +++ b/integrations/org_count_test.go @@ -12,6 +12,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/unittest" api "code.gitea.io/gitea/modules/structs" + "github.com/stretchr/testify/assert" ) diff --git a/integrations/org_test.go b/integrations/org_test.go index ac234de6500ae..e94e4ea74c1c3 100644 --- a/integrations/org_test.go +++ b/integrations/org_test.go @@ -11,6 +11,7 @@ import ( "testing" api "code.gitea.io/gitea/modules/structs" + "github.com/stretchr/testify/assert" ) diff --git a/integrations/rename_branch_test.go b/integrations/rename_branch_test.go index a8138ff0c58ef..1fe1983054590 100644 --- a/integrations/rename_branch_test.go +++ b/integrations/rename_branch_test.go @@ -10,6 +10,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/integrations/repo_migrate_test.go b/integrations/repo_migrate_test.go index 5a02b4ba03c09..e6ba15b137bd0 100644 --- a/integrations/repo_migrate_test.go +++ b/integrations/repo_migrate_test.go @@ -11,6 +11,7 @@ import ( "testing" "code.gitea.io/gitea/modules/structs" + "github.com/stretchr/testify/assert" ) diff --git a/integrations/repofiles_delete_test.go b/integrations/repofiles_delete_test.go index 8150673e2b32e..eb73348950260 100644 --- a/integrations/repofiles_delete_test.go +++ b/integrations/repofiles_delete_test.go @@ -8,9 +8,8 @@ import ( "net/url" "testing" - "code.gitea.io/gitea/models/unittest" - "code.gitea.io/gitea/models" + "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/repofiles" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/test" diff --git a/integrations/signup_test.go b/integrations/signup_test.go index 33e5809b289b8..38aa069f318ac 100644 --- a/integrations/signup_test.go +++ b/integrations/signup_test.go @@ -13,6 +13,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/setting" + "github.com/stretchr/testify/assert" "github.com/unknwon/i18n" ) diff --git a/integrations/user_avatar_test.go b/integrations/user_avatar_test.go index e53f0e34fe34c..edc3a47314ac9 100644 --- a/integrations/user_avatar_test.go +++ b/integrations/user_avatar_test.go @@ -16,6 +16,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/avatar" + "github.com/stretchr/testify/assert" ) diff --git a/models/access_test.go b/models/access_test.go index 96aa34edb648e..942ca4af42864 100644 --- a/models/access_test.go +++ b/models/access_test.go @@ -9,6 +9,7 @@ import ( "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/models/admin_test.go b/models/admin_test.go index 95415731b2404..8c1deda5f8cbe 100644 --- a/models/admin_test.go +++ b/models/admin_test.go @@ -8,6 +8,7 @@ import ( "testing" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/models/attachment_test.go b/models/attachment_test.go index c3949905363b0..4081811d1986d 100644 --- a/models/attachment_test.go +++ b/models/attachment_test.go @@ -10,6 +10,7 @@ import ( "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unit" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/models/branches_test.go b/models/branches_test.go index 787dd7fe8365e..187f23d41bbc1 100644 --- a/models/branches_test.go +++ b/models/branches_test.go @@ -8,6 +8,7 @@ import ( "testing" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/models/commit_status_test.go b/models/commit_status_test.go index 32d6a433ce054..02e3849357ebb 100644 --- a/models/commit_status_test.go +++ b/models/commit_status_test.go @@ -10,6 +10,7 @@ import ( "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/structs" + "github.com/stretchr/testify/assert" ) diff --git a/models/consistency_test.go b/models/consistency_test.go index 6995f47c87e23..d49a0132f09e0 100644 --- a/models/consistency_test.go +++ b/models/consistency_test.go @@ -9,6 +9,7 @@ import ( "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/models/db/engine.go b/models/db/engine.go index 32ef9fdbafdef..2f0c7bcf4f20e 100755 --- a/models/db/engine.go +++ b/models/db/engine.go @@ -16,15 +16,13 @@ import ( "code.gitea.io/gitea/modules/setting" - _ "github.com/go-sql-driver/mysql" // Needed for the MySQL driver + _ "github.com/denisenkom/go-mssqldb" // Needed for the MSSQL driver + _ "github.com/go-sql-driver/mysql" // Needed for the MySQL driver + _ "github.com/lib/pq" // Needed for the Postgresql driver + "xorm.io/xorm" "xorm.io/xorm/names" "xorm.io/xorm/schemas" - - _ "github.com/lib/pq" // Needed for the Postgresql driver - - - _ "github.com/denisenkom/go-mssqldb" // Needed for the MSSQL driver ) var ( diff --git a/models/db/sql_postgres_with_schema.go b/models/db/sql_postgres_with_schema.go index d6b6262927c4a..45041bc173814 100644 --- a/models/db/sql_postgres_with_schema.go +++ b/models/db/sql_postgres_with_schema.go @@ -12,6 +12,7 @@ import ( "code.gitea.io/gitea/modules/setting" "github.com/lib/pq" + "xorm.io/xorm/dialects" ) diff --git a/models/external_login_user.go b/models/external_login_user.go index 6b023a4cb2a98..67358b1dc4f3f 100644 --- a/models/external_login_user.go +++ b/models/external_login_user.go @@ -12,6 +12,7 @@ import ( "code.gitea.io/gitea/modules/structs" "github.com/markbates/goth" + "xorm.io/builder" ) diff --git a/models/gpg_key.go b/models/gpg_key.go index 357dc2b964cbf..b5529cd95233a 100644 --- a/models/gpg_key.go +++ b/models/gpg_key.go @@ -16,6 +16,7 @@ import ( "github.com/keybase/go-crypto/openpgp" "github.com/keybase/go-crypto/openpgp/packet" + "xorm.io/xorm" ) diff --git a/models/issue_assignees_test.go b/models/issue_assignees_test.go index 8e2256072a595..d1ce000de6b53 100644 --- a/models/issue_assignees_test.go +++ b/models/issue_assignees_test.go @@ -8,6 +8,7 @@ import ( "testing" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/models/issue_comment_test.go b/models/issue_comment_test.go index 27c50a3ae4c6d..4d3607b3e15b3 100644 --- a/models/issue_comment_test.go +++ b/models/issue_comment_test.go @@ -9,6 +9,7 @@ import ( "time" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/models/issue_dependency_test.go b/models/issue_dependency_test.go index c357d35c501f9..86ac98b733a6b 100644 --- a/models/issue_dependency_test.go +++ b/models/issue_dependency_test.go @@ -8,6 +8,7 @@ import ( "testing" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/models/issue_label_test.go b/models/issue_label_test.go index 658c459ba5277..d0f807a56e6a3 100644 --- a/models/issue_label_test.go +++ b/models/issue_label_test.go @@ -10,6 +10,7 @@ import ( "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/models/issue_list.go b/models/issue_list.go index ac7ec7ccbf240..04dcc5842211f 100644 --- a/models/issue_list.go +++ b/models/issue_list.go @@ -8,6 +8,7 @@ import ( "fmt" "code.gitea.io/gitea/models/db" + "xorm.io/builder" ) diff --git a/models/issue_milestone_test.go b/models/issue_milestone_test.go index 2956e40f06580..946c531d6d499 100644 --- a/models/issue_milestone_test.go +++ b/models/issue_milestone_test.go @@ -15,6 +15,7 @@ import ( "code.gitea.io/gitea/modules/timeutil" "github.com/stretchr/testify/assert" + "xorm.io/builder" ) diff --git a/models/issue_test.go b/models/issue_test.go index f53febb1b30c3..7942b7e78539a 100644 --- a/models/issue_test.go +++ b/models/issue_test.go @@ -13,6 +13,7 @@ import ( "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/models/issue_tracked_time_test.go b/models/issue_tracked_time_test.go index 9bc966452178d..83420f5a152a6 100644 --- a/models/issue_tracked_time_test.go +++ b/models/issue_tracked_time_test.go @@ -9,6 +9,7 @@ import ( "time" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/models/issue_user_test.go b/models/issue_user_test.go index 1be276370375c..daa68d731e336 100644 --- a/models/issue_user_test.go +++ b/models/issue_user_test.go @@ -9,6 +9,7 @@ import ( "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/models/issue_watch_test.go b/models/issue_watch_test.go index 18d49bfce55bc..f75677d68cf80 100644 --- a/models/issue_watch_test.go +++ b/models/issue_watch_test.go @@ -9,6 +9,7 @@ import ( "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/models/login/oauth2_application.go b/models/login/oauth2_application.go index 060bfe5bc3b0f..c1f9e30081059 100644 --- a/models/login/oauth2_application.go +++ b/models/login/oauth2_application.go @@ -17,7 +17,9 @@ import ( "code.gitea.io/gitea/modules/util" uuid "github.com/google/uuid" + "golang.org/x/crypto/bcrypt" + "xorm.io/xorm" ) diff --git a/models/login/source_test.go b/models/login/source_test.go index e7ef7c70488c2..a6aac3e47e4ec 100644 --- a/models/login/source_test.go +++ b/models/login/source_test.go @@ -13,6 +13,7 @@ import ( "code.gitea.io/gitea/modules/json" "github.com/stretchr/testify/assert" + "xorm.io/xorm/schemas" ) diff --git a/models/login/twofactor.go b/models/login/twofactor.go index acb5e1b2d50ec..ff244df38e9e8 100644 --- a/models/login/twofactor.go +++ b/models/login/twofactor.go @@ -18,6 +18,7 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/pquerna/otp/totp" + "golang.org/x/crypto/pbkdf2" ) diff --git a/models/migrations/migrations_test.go b/models/migrations/migrations_test.go index f46070cf8e588..7e962a9623e0e 100644 --- a/models/migrations/migrations_test.go +++ b/models/migrations/migrations_test.go @@ -24,6 +24,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/unknwon/com" + "xorm.io/xorm" "xorm.io/xorm/names" ) diff --git a/models/migrations/v142.go b/models/migrations/v142.go index 1abdd34961df0..d8ccc112d6eeb 100644 --- a/models/migrations/v142.go +++ b/models/migrations/v142.go @@ -6,6 +6,7 @@ package migrations import ( "code.gitea.io/gitea/modules/log" + "xorm.io/builder" "xorm.io/xorm" ) diff --git a/models/migrations/v144.go b/models/migrations/v144.go index 311bb93e3b0ec..81279a54c9102 100644 --- a/models/migrations/v144.go +++ b/models/migrations/v144.go @@ -6,6 +6,7 @@ package migrations import ( "code.gitea.io/gitea/modules/log" + "xorm.io/builder" "xorm.io/xorm" ) diff --git a/models/migrations/v166.go b/models/migrations/v166.go index 1b6e68b5733ab..ac27676ef655b 100644 --- a/models/migrations/v166.go +++ b/models/migrations/v166.go @@ -12,6 +12,7 @@ import ( "golang.org/x/crypto/bcrypt" "golang.org/x/crypto/pbkdf2" "golang.org/x/crypto/scrypt" + "xorm.io/builder" "xorm.io/xorm" ) diff --git a/models/migrations/v175.go b/models/migrations/v175.go index 0044ed1845dcc..2dfefe987b688 100644 --- a/models/migrations/v175.go +++ b/models/migrations/v175.go @@ -10,6 +10,7 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + "xorm.io/xorm" ) diff --git a/models/migrations/v177_test.go b/models/migrations/v177_test.go index 02cb1d2652560..f5fc793aa4230 100644 --- a/models/migrations/v177_test.go +++ b/models/migrations/v177_test.go @@ -8,6 +8,7 @@ import ( "testing" "code.gitea.io/gitea/modules/timeutil" + "github.com/stretchr/testify/assert" ) diff --git a/models/migrations/v191.go b/models/migrations/v191.go index 10dfad4f04f57..c91990e0f33d7 100644 --- a/models/migrations/v191.go +++ b/models/migrations/v191.go @@ -6,6 +6,7 @@ package migrations import ( "code.gitea.io/gitea/modules/setting" + "xorm.io/xorm" ) diff --git a/models/migrations/v71.go b/models/migrations/v71.go index e4ed46a21a5b1..f600c68f0b34c 100644 --- a/models/migrations/v71.go +++ b/models/migrations/v71.go @@ -12,6 +12,7 @@ import ( "code.gitea.io/gitea/modules/util" "golang.org/x/crypto/pbkdf2" + "xorm.io/xorm" ) diff --git a/models/notification_test.go b/models/notification_test.go index db2164a2f59b4..19fad25f99fbb 100644 --- a/models/notification_test.go +++ b/models/notification_test.go @@ -8,6 +8,7 @@ import ( "testing" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/models/org_team_test.go b/models/org_team_test.go index 9277ac4f5edf5..b912dd83f2644 100644 --- a/models/org_team_test.go +++ b/models/org_team_test.go @@ -9,6 +9,7 @@ import ( "testing" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/models/pull_test.go b/models/pull_test.go index 0225b421fb532..c967cca313916 100644 --- a/models/pull_test.go +++ b/models/pull_test.go @@ -10,6 +10,7 @@ import ( "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unit" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/models/repo.go b/models/repo.go index 16396e181db7a..d45f1b2fc357e 100644 --- a/models/repo.go +++ b/models/repo.go @@ -10,7 +10,6 @@ import ( "errors" "fmt" "html/template" - _ "image/jpeg" // Needed for jpeg support "net" "net/url" "os" @@ -22,6 +21,8 @@ import ( "time" "unicode/utf8" + _ "image/jpeg" // Needed for jpeg support + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unit" "code.gitea.io/gitea/models/webhook" diff --git a/models/repo_collaboration_test.go b/models/repo_collaboration_test.go index 9b698c0af6408..060afc2139bd7 100644 --- a/models/repo_collaboration_test.go +++ b/models/repo_collaboration_test.go @@ -9,6 +9,7 @@ import ( "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/models/repo_indexer.go b/models/repo_indexer.go index 7029b0922b07f..e0511b325ead8 100644 --- a/models/repo_indexer.go +++ b/models/repo_indexer.go @@ -8,6 +8,7 @@ import ( "fmt" "code.gitea.io/gitea/models/db" + "xorm.io/builder" ) diff --git a/models/repo_permission_test.go b/models/repo_permission_test.go index b64fe37911df9..180a85a2f5dce 100644 --- a/models/repo_permission_test.go +++ b/models/repo_permission_test.go @@ -10,6 +10,7 @@ import ( "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unit" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/models/repo_redirect_test.go b/models/repo_redirect_test.go index a9d3cc14942a8..6e5b9fc080334 100644 --- a/models/repo_redirect_test.go +++ b/models/repo_redirect_test.go @@ -9,6 +9,7 @@ import ( "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/models/repo_transfer_test.go b/models/repo_transfer_test.go index df4f83919ba15..368fea598deac 100644 --- a/models/repo_transfer_test.go +++ b/models/repo_transfer_test.go @@ -8,6 +8,7 @@ import ( "testing" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/models/review_test.go b/models/review_test.go index 2d07ea2ce4d5d..7b8b86df1320b 100644 --- a/models/review_test.go +++ b/models/review_test.go @@ -8,6 +8,7 @@ import ( "testing" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/models/ssh_key.go b/models/ssh_key.go index c08fb72e75133..3cba85c1af4a8 100644 --- a/models/ssh_key.go +++ b/models/ssh_key.go @@ -15,6 +15,7 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/util" + "golang.org/x/crypto/ssh" "xorm.io/builder" diff --git a/models/ssh_key_deploy.go b/models/ssh_key_deploy.go index 34cf03e925186..4e3910d556100 100644 --- a/models/ssh_key_deploy.go +++ b/models/ssh_key_deploy.go @@ -10,6 +10,7 @@ import ( "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" + "xorm.io/builder" "xorm.io/xorm" ) diff --git a/models/ssh_key_fingerprint.go b/models/ssh_key_fingerprint.go index 93c455e48938a..85296c961c3eb 100644 --- a/models/ssh_key_fingerprint.go +++ b/models/ssh_key_fingerprint.go @@ -14,6 +14,7 @@ import ( "code.gitea.io/gitea/modules/process" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" + "golang.org/x/crypto/ssh" ) diff --git a/models/ssh_key_parse.go b/models/ssh_key_parse.go index d2c24b0a2a502..748c66da7dad6 100644 --- a/models/ssh_key_parse.go +++ b/models/ssh_key_parse.go @@ -22,6 +22,7 @@ import ( "code.gitea.io/gitea/modules/process" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" + "golang.org/x/crypto/ssh" ) diff --git a/models/star_test.go b/models/star_test.go index e1313727332ec..f9a7ddb0f2af4 100644 --- a/models/star_test.go +++ b/models/star_test.go @@ -9,6 +9,7 @@ import ( "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/models/token_test.go b/models/token_test.go index 191da7820ed40..007148870a1ad 100644 --- a/models/token_test.go +++ b/models/token_test.go @@ -8,6 +8,7 @@ import ( "testing" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/models/topic_test.go b/models/topic_test.go index def946b66688e..a38ed6494002e 100644 --- a/models/topic_test.go +++ b/models/topic_test.go @@ -9,6 +9,7 @@ import ( "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/models/unittest/consistency.go b/models/unittest/consistency.go index 2645084d3ede3..8d8a33be2435b 100644 --- a/models/unittest/consistency.go +++ b/models/unittest/consistency.go @@ -12,6 +12,7 @@ import ( "code.gitea.io/gitea/models/db" "github.com/stretchr/testify/assert" + "xorm.io/builder" ) diff --git a/models/unittest/testdb.go b/models/unittest/testdb.go index 8771bc1d2139a..bda8bc403e351 100644 --- a/models/unittest/testdb.go +++ b/models/unittest/testdb.go @@ -18,6 +18,7 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/stretchr/testify/assert" + "xorm.io/xorm" "xorm.io/xorm/names" ) diff --git a/models/unittest/unit_tests.go b/models/unittest/unit_tests.go index 6c20c2781bb4d..b75a61edc9c29 100644 --- a/models/unittest/unit_tests.go +++ b/models/unittest/unit_tests.go @@ -10,6 +10,7 @@ import ( "code.gitea.io/gitea/models/db" "github.com/stretchr/testify/assert" + "xorm.io/builder" ) diff --git a/models/user.go b/models/user.go index 8146c184e70a3..6cfaf78e6cb91 100644 --- a/models/user.go +++ b/models/user.go @@ -12,7 +12,6 @@ import ( "encoding/hex" "errors" "fmt" - _ "image/jpeg" // Needed for jpeg support "net/url" "os" "path/filepath" @@ -21,6 +20,8 @@ import ( "time" "unicode/utf8" + _ "image/jpeg" // Needed for jpeg support + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/login" "code.gitea.io/gitea/models/unit" diff --git a/models/user_email.go b/models/user_email.go index 7de577bc2ce8b..bd0da65405e34 100644 --- a/models/user_email.go +++ b/models/user_email.go @@ -11,6 +11,7 @@ import ( "code.gitea.io/gitea/models/db" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/util" + "xorm.io/builder" ) diff --git a/models/user_follow_test.go b/models/user_follow_test.go index 5ba922728a9a5..fab1e2415b462 100644 --- a/models/user_follow_test.go +++ b/models/user_follow_test.go @@ -8,6 +8,7 @@ import ( "testing" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/modules/cache/cache_redis.go b/modules/cache/cache_redis.go index 148725ae66015..f56e93b133084 100644 --- a/modules/cache/cache_redis.go +++ b/modules/cache/cache_redis.go @@ -12,6 +12,7 @@ import ( "code.gitea.io/gitea/modules/nosql" "gitea.com/go-chi/cache" + "github.com/go-redis/redis/v8" "github.com/unknwon/com" ) diff --git a/modules/cache/cache_twoqueue.go b/modules/cache/cache_twoqueue.go index 275b73f068f29..d1082d46936b7 100644 --- a/modules/cache/cache_twoqueue.go +++ b/modules/cache/cache_twoqueue.go @@ -12,6 +12,7 @@ import ( "code.gitea.io/gitea/modules/json" mc "gitea.com/go-chi/cache" + lru "github.com/hashicorp/golang-lru" ) diff --git a/modules/charset/charset.go b/modules/charset/charset.go index ae5cf5aa1a4eb..0ca01588306dd 100644 --- a/modules/charset/charset.go +++ b/modules/charset/charset.go @@ -16,6 +16,7 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/gogs/chardet" + "golang.org/x/net/html/charset" "golang.org/x/text/transform" ) diff --git a/modules/context/context.go b/modules/context/context.go index 8adf1f306bd6d..73be26dc871da 100644 --- a/modules/context/context.go +++ b/modules/context/context.go @@ -34,10 +34,12 @@ import ( "gitea.com/go-chi/cache" "gitea.com/go-chi/session" + chi "github.com/go-chi/chi/v5" "github.com/unknwon/com" "github.com/unknwon/i18n" "github.com/unrolled/render" + "golang.org/x/crypto/pbkdf2" ) diff --git a/modules/convert/utils_test.go b/modules/convert/utils_test.go index bd59299c01bd3..e0ab15dfd838a 100644 --- a/modules/convert/utils_test.go +++ b/modules/convert/utils_test.go @@ -7,8 +7,9 @@ package convert import ( "testing" - _ "github.com/mattn/go-sqlite3" "github.com/stretchr/testify/assert" + + _ "github.com/mattn/go-sqlite3" ) func TestToCorrectPageSize(t *testing.T) { diff --git a/modules/doctor/fix16961.go b/modules/doctor/fix16961.go index e0e44b414ba43..2e1db834cd622 100644 --- a/modules/doctor/fix16961.go +++ b/modules/doctor/fix16961.go @@ -13,6 +13,7 @@ import ( "code.gitea.io/gitea/models/unit" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/timeutil" + "xorm.io/builder" ) diff --git a/modules/doctor/fix16961_test.go b/modules/doctor/fix16961_test.go index 017f585335c5f..986425b4d8811 100644 --- a/modules/doctor/fix16961_test.go +++ b/modules/doctor/fix16961_test.go @@ -8,6 +8,7 @@ import ( "testing" "code.gitea.io/gitea/models" + "github.com/stretchr/testify/assert" ) diff --git a/modules/doctor/misc.go b/modules/doctor/misc.go index 2f748bcb71870..8ef3b84685029 100644 --- a/modules/doctor/misc.go +++ b/modules/doctor/misc.go @@ -21,6 +21,7 @@ import ( "code.gitea.io/gitea/modules/util" lru "github.com/hashicorp/golang-lru" + "xorm.io/builder" ) diff --git a/modules/git/commit_info_test.go b/modules/git/commit_info_test.go index 0608801f9df45..8467bdaa9034d 100644 --- a/modules/git/commit_info_test.go +++ b/modules/git/commit_info_test.go @@ -12,6 +12,7 @@ import ( "time" "code.gitea.io/gitea/modules/util" + "github.com/stretchr/testify/assert" ) diff --git a/modules/git/pipeline/lfs.go b/modules/git/pipeline/lfs.go index 46a48b710c6f9..4551ccd3f452a 100644 --- a/modules/git/pipeline/lfs.go +++ b/modules/git/pipeline/lfs.go @@ -17,6 +17,7 @@ import ( "time" "code.gitea.io/gitea/modules/git" + gogit "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing/object" ) diff --git a/modules/git/repo_compare_test.go b/modules/git/repo_compare_test.go index 3a6cda955c5eb..ecd1aa4e6da04 100644 --- a/modules/git/repo_compare_test.go +++ b/modules/git/repo_compare_test.go @@ -11,6 +11,7 @@ import ( "testing" "code.gitea.io/gitea/modules/util" + "github.com/stretchr/testify/assert" ) diff --git a/modules/git/repo_tag_test.go b/modules/git/repo_tag_test.go index cfab9edd8f42e..136287e1a9cdd 100644 --- a/modules/git/repo_tag_test.go +++ b/modules/git/repo_tag_test.go @@ -9,6 +9,7 @@ import ( "testing" "code.gitea.io/gitea/modules/util" + "github.com/stretchr/testify/assert" ) diff --git a/modules/highlight/highlight.go b/modules/highlight/highlight.go index 6684fbe842910..9a876d2a6b21f 100644 --- a/modules/highlight/highlight.go +++ b/modules/highlight/highlight.go @@ -17,6 +17,7 @@ import ( "code.gitea.io/gitea/modules/analyze" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + "github.com/alecthomas/chroma" "github.com/alecthomas/chroma/formatters/html" "github.com/alecthomas/chroma/lexers" diff --git a/modules/highlight/highlight_test.go b/modules/highlight/highlight_test.go index 0a67e4c602697..29a15c0b53b44 100644 --- a/modules/highlight/highlight_test.go +++ b/modules/highlight/highlight_test.go @@ -9,6 +9,7 @@ import ( "testing" "code.gitea.io/gitea/modules/setting" + "gopkg.in/ini.v1" ) diff --git a/modules/indexer/issues/bleve_test.go b/modules/indexer/issues/bleve_test.go index 70a9582e1d77e..036b318d85c20 100644 --- a/modules/indexer/issues/bleve_test.go +++ b/modules/indexer/issues/bleve_test.go @@ -9,6 +9,7 @@ import ( "testing" "code.gitea.io/gitea/modules/util" + "github.com/stretchr/testify/assert" ) diff --git a/modules/indexer/issues/indexer_test.go b/modules/indexer/issues/indexer_test.go index edfaddb648fe2..a462bba433a03 100644 --- a/modules/indexer/issues/indexer_test.go +++ b/modules/indexer/issues/indexer_test.go @@ -15,9 +15,9 @@ import ( "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" - "gopkg.in/ini.v1" - "github.com/stretchr/testify/assert" + + "gopkg.in/ini.v1" ) func TestMain(m *testing.M) { diff --git a/modules/indexer/stats/indexer_test.go b/modules/indexer/stats/indexer_test.go index c451e8023838b..1a7142c7bc418 100644 --- a/modules/indexer/stats/indexer_test.go +++ b/modules/indexer/stats/indexer_test.go @@ -13,9 +13,9 @@ import ( "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/setting" - "gopkg.in/ini.v1" - "github.com/stretchr/testify/assert" + + "gopkg.in/ini.v1" ) func TestMain(m *testing.M) { diff --git a/modules/log/console_windows.go b/modules/log/console_windows.go index ea47e5d624421..8b242673e83a4 100644 --- a/modules/log/console_windows.go +++ b/modules/log/console_windows.go @@ -8,6 +8,7 @@ import ( "os" "github.com/mattn/go-isatty" + "golang.org/x/sys/windows" ) diff --git a/modules/log/file_test.go b/modules/log/file_test.go index 39d2467a1ff8a..09a07b1e27537 100644 --- a/modules/log/file_test.go +++ b/modules/log/file_test.go @@ -15,6 +15,7 @@ import ( "time" "code.gitea.io/gitea/modules/util" + "github.com/stretchr/testify/assert" ) diff --git a/modules/markup/html.go b/modules/markup/html.go index 746830720da90..a6cb91d438c5d 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -24,8 +24,10 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/unknwon/com" + "golang.org/x/net/html" "golang.org/x/net/html/atom" + "mvdan.cc/xurls/v2" ) diff --git a/modules/markup/markdown/renderconfig.go b/modules/markup/markdown/renderconfig.go index bef67e9e59bf2..3acec15dcd343 100644 --- a/modules/markup/markdown/renderconfig.go +++ b/modules/markup/markdown/renderconfig.go @@ -10,6 +10,7 @@ import ( "github.com/yuin/goldmark/ast" east "github.com/yuin/goldmark/extension/ast" + "gopkg.in/yaml.v2" ) diff --git a/modules/markup/mdstripper/mdstripper.go b/modules/markup/mdstripper/mdstripper.go index 52464f3e1b376..2977c81977893 100644 --- a/modules/markup/mdstripper/mdstripper.go +++ b/modules/markup/mdstripper/mdstripper.go @@ -6,12 +6,11 @@ package mdstripper import ( "bytes" + "io" "net/url" "strings" "sync" - "io" - "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/markup/common" "code.gitea.io/gitea/modules/setting" diff --git a/modules/markup/renderer_test.go b/modules/markup/renderer_test.go index 118fa2632ba58..4cfa022463190 100644 --- a/modules/markup/renderer_test.go +++ b/modules/markup/renderer_test.go @@ -8,6 +8,7 @@ import ( "testing" . "code.gitea.io/gitea/modules/markup" + _ "code.gitea.io/gitea/modules/markup/markdown" "github.com/stretchr/testify/assert" diff --git a/modules/notification/action/action_test.go b/modules/notification/action/action_test.go index 3adcae83fdaad..448242bcdfd37 100644 --- a/modules/notification/action/action_test.go +++ b/modules/notification/action/action_test.go @@ -11,6 +11,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/modules/queue/queue_disk_channel_test.go b/modules/queue/queue_disk_channel_test.go index 99fb65934eb8b..d464a183a0f55 100644 --- a/modules/queue/queue_disk_channel_test.go +++ b/modules/queue/queue_disk_channel_test.go @@ -10,6 +10,7 @@ import ( "testing" "code.gitea.io/gitea/modules/util" + "github.com/stretchr/testify/assert" ) diff --git a/modules/queue/queue_disk_test.go b/modules/queue/queue_disk_test.go index 549a04104ebd7..a2c21fec085bb 100644 --- a/modules/queue/queue_disk_test.go +++ b/modules/queue/queue_disk_test.go @@ -11,6 +11,7 @@ import ( "time" "code.gitea.io/gitea/modules/util" + "github.com/stretchr/testify/assert" ) diff --git a/modules/repofiles/blob_test.go b/modules/repofiles/blob_test.go index c219892aec8e7..8950c349e6443 100644 --- a/modules/repofiles/blob_test.go +++ b/modules/repofiles/blob_test.go @@ -8,7 +8,6 @@ import ( "testing" "code.gitea.io/gitea/models/unittest" - api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/test" diff --git a/modules/repofiles/content_test.go b/modules/repofiles/content_test.go index e3230698bcec7..f6a953fab9874 100644 --- a/modules/repofiles/content_test.go +++ b/modules/repofiles/content_test.go @@ -9,7 +9,6 @@ import ( "testing" "code.gitea.io/gitea/models/unittest" - api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/test" diff --git a/modules/repofiles/tree_test.go b/modules/repofiles/tree_test.go index 512313c43b364..6917b8915bcc3 100644 --- a/modules/repofiles/tree_test.go +++ b/modules/repofiles/tree_test.go @@ -8,7 +8,6 @@ import ( "testing" "code.gitea.io/gitea/models/unittest" - api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/test" diff --git a/modules/repository/commits_test.go b/modules/repository/commits_test.go index 0d6c2e4c5ce61..b6a63dc12765f 100644 --- a/modules/repository/commits_test.go +++ b/modules/repository/commits_test.go @@ -13,6 +13,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/git" + "github.com/stretchr/testify/assert" ) diff --git a/modules/session/redis.go b/modules/session/redis.go index 334418bd7e5d3..53bbcad7733fa 100644 --- a/modules/session/redis.go +++ b/modules/session/redis.go @@ -25,6 +25,7 @@ import ( "code.gitea.io/gitea/modules/nosql" "gitea.com/go-chi/session" + "github.com/go-redis/redis/v8" ) diff --git a/modules/setting/cron_test.go b/modules/setting/cron_test.go index 8670a92bac964..fd0ab2677c042 100644 --- a/modules/setting/cron_test.go +++ b/modules/setting/cron_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + ini "gopkg.in/ini.v1" ) diff --git a/modules/setting/queue.go b/modules/setting/queue.go index 1668cc63a34db..56a036aeef58b 100644 --- a/modules/setting/queue.go +++ b/modules/setting/queue.go @@ -10,6 +10,7 @@ import ( "time" "code.gitea.io/gitea/modules/log" + ini "gopkg.in/ini.v1" ) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index c5608c85bc53b..36e8bcab2cd6d 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -30,7 +30,9 @@ import ( shellquote "github.com/kballard/go-shellquote" "github.com/unknwon/com" + gossh "golang.org/x/crypto/ssh" + ini "gopkg.in/ini.v1" ) diff --git a/modules/setting/storage_test.go b/modules/setting/storage_test.go index ffd8b7aa014ba..6d2323e46c782 100644 --- a/modules/setting/storage_test.go +++ b/modules/setting/storage_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + ini "gopkg.in/ini.v1" ) diff --git a/modules/ssh/ssh.go b/modules/ssh/ssh.go index 5f19dd4a5c7ef..f955dced136fe 100644 --- a/modules/ssh/ssh.go +++ b/modules/ssh/ssh.go @@ -28,6 +28,7 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/gliderlabs/ssh" + gossh "golang.org/x/crypto/ssh" ) diff --git a/modules/translation/translation.go b/modules/translation/translation.go index 77cc9ac7f5847..ef9f824a3815a 100644 --- a/modules/translation/translation.go +++ b/modules/translation/translation.go @@ -10,6 +10,7 @@ import ( "code.gitea.io/gitea/modules/setting" "github.com/unknwon/i18n" + "golang.org/x/text/language" ) diff --git a/modules/validation/binding.go b/modules/validation/binding.go index 5d5c64611f29a..941ed12b6b523 100644 --- a/modules/validation/binding.go +++ b/modules/validation/binding.go @@ -10,6 +10,7 @@ import ( "strings" "gitea.com/go-chi/binding" + "github.com/gobwas/glob" ) diff --git a/modules/validation/binding_test.go b/modules/validation/binding_test.go index aa8a765524480..33dd5265d0977 100644 --- a/modules/validation/binding_test.go +++ b/modules/validation/binding_test.go @@ -10,6 +10,7 @@ import ( "testing" "gitea.com/go-chi/binding" + chi "github.com/go-chi/chi/v5" "github.com/stretchr/testify/assert" ) diff --git a/modules/validation/glob_pattern_test.go b/modules/validation/glob_pattern_test.go index cbaed7e66ac24..f4d36099429ad 100644 --- a/modules/validation/glob_pattern_test.go +++ b/modules/validation/glob_pattern_test.go @@ -8,6 +8,7 @@ import ( "testing" "gitea.com/go-chi/binding" + "github.com/gobwas/glob" ) diff --git a/modules/web/middleware/binding.go b/modules/web/middleware/binding.go index cbdb29b812942..e3cbeb9f1afc0 100644 --- a/modules/web/middleware/binding.go +++ b/modules/web/middleware/binding.go @@ -13,6 +13,7 @@ import ( "code.gitea.io/gitea/modules/validation" "gitea.com/go-chi/binding" + "github.com/unknwon/com" ) diff --git a/modules/web/middleware/locale.go b/modules/web/middleware/locale.go index ede38ef933c03..9e935e8f28053 100644 --- a/modules/web/middleware/locale.go +++ b/modules/web/middleware/locale.go @@ -11,6 +11,7 @@ import ( "code.gitea.io/gitea/modules/translation" "github.com/unknwon/i18n" + "golang.org/x/text/language" ) diff --git a/modules/web/route.go b/modules/web/route.go index ad9cea8bb6e14..56ca4e0055a89 100644 --- a/modules/web/route.go +++ b/modules/web/route.go @@ -15,6 +15,7 @@ import ( "code.gitea.io/gitea/modules/web/middleware" "gitea.com/go-chi/binding" + chi "github.com/go-chi/chi/v5" ) diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index f312df23db1a6..0b9682014ef00 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -83,12 +83,14 @@ import ( "code.gitea.io/gitea/routers/api/v1/org" "code.gitea.io/gitea/routers/api/v1/repo" "code.gitea.io/gitea/routers/api/v1/settings" - _ "code.gitea.io/gitea/routers/api/v1/swagger" // for swagger generation "code.gitea.io/gitea/routers/api/v1/user" "code.gitea.io/gitea/services/auth" "code.gitea.io/gitea/services/forms" + _ "code.gitea.io/gitea/routers/api/v1/swagger" // for swagger generation + "gitea.com/go-chi/binding" + "github.com/go-chi/cors" ) diff --git a/routers/install/install.go b/routers/install/install.go index 837467056dc13..926852ef670ea 100644 --- a/routers/install/install.go +++ b/routers/install/install.go @@ -32,6 +32,7 @@ import ( "code.gitea.io/gitea/services/forms" "gitea.com/go-chi/session" + "gopkg.in/ini.v1" ) diff --git a/routers/utils/utils_test.go b/routers/utils/utils_test.go index bca5263311145..f49ed77b6fc08 100644 --- a/routers/utils/utils_test.go +++ b/routers/utils/utils_test.go @@ -8,6 +8,7 @@ import ( "testing" "code.gitea.io/gitea/modules/setting" + "github.com/stretchr/testify/assert" ) diff --git a/routers/web/goget.go b/routers/web/goget.go index 9f367a92771a3..8a8e1797dcf63 100644 --- a/routers/web/goget.go +++ b/routers/web/goget.go @@ -14,6 +14,7 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" + "github.com/unknwon/com" ) diff --git a/routers/web/repo/issue_test.go b/routers/web/repo/issue_test.go index 6638baf34a16d..b8862cf43dce2 100644 --- a/routers/web/repo/issue_test.go +++ b/routers/web/repo/issue_test.go @@ -8,6 +8,7 @@ import ( "testing" "code.gitea.io/gitea/models" + "github.com/stretchr/testify/assert" ) diff --git a/routers/web/user/home.go b/routers/web/user/home.go index b9f5d044fa552..8ac3fb81f8ff6 100644 --- a/routers/web/user/home.go +++ b/routers/web/user/home.go @@ -32,6 +32,7 @@ import ( "github.com/keybase/go-crypto/openpgp" "github.com/keybase/go-crypto/openpgp/armor" + "xorm.io/builder" ) diff --git a/routers/web/user/oauth.go b/routers/web/user/oauth.go index 3210d033d3c22..cca3223e496a3 100644 --- a/routers/web/user/oauth.go +++ b/routers/web/user/oauth.go @@ -26,6 +26,7 @@ import ( "code.gitea.io/gitea/services/forms" "gitea.com/go-chi/binding" + "github.com/golang-jwt/jwt" ) diff --git a/routers/web/web.go b/routers/web/web.go index 0f1bef3cffd77..2b17e2fc3ee3d 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -36,10 +36,10 @@ import ( "code.gitea.io/gitea/services/lfs" "code.gitea.io/gitea/services/mailer" - _ "code.gitea.io/gitea/modules/session" // to registers all internal adapters "gitea.com/go-chi/captcha" + "github.com/NYTimes/gziphandler" "github.com/go-chi/chi/middleware" "github.com/go-chi/cors" diff --git a/services/auth/signin.go b/services/auth/signin.go index 5477e8643ebc1..504214f9f1626 100644 --- a/services/auth/signin.go +++ b/services/auth/signin.go @@ -13,8 +13,7 @@ import ( user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/log" - // Register the sources - _ "code.gitea.io/gitea/services/auth/source/db" + _ "code.gitea.io/gitea/services/auth/source/db" // register the sources (and below) _ "code.gitea.io/gitea/services/auth/source/ldap" _ "code.gitea.io/gitea/services/auth/source/oauth2" _ "code.gitea.io/gitea/services/auth/source/pam" diff --git a/services/auth/source/oauth2/jwtsigningkey.go b/services/auth/source/oauth2/jwtsigningkey.go index 3102be5f143a2..f995bfd51d202 100644 --- a/services/auth/source/oauth2/jwtsigningkey.go +++ b/services/auth/source/oauth2/jwtsigningkey.go @@ -26,6 +26,7 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/golang-jwt/jwt" + ini "gopkg.in/ini.v1" ) diff --git a/services/auth/source/oauth2/store.go b/services/auth/source/oauth2/store.go index fc29056c24a46..9fe8ffa4c7b11 100644 --- a/services/auth/source/oauth2/store.go +++ b/services/auth/source/oauth2/store.go @@ -10,7 +10,9 @@ import ( "net/http" "code.gitea.io/gitea/modules/log" + chiSession "gitea.com/go-chi/session" + "github.com/gorilla/sessions" ) diff --git a/services/auth/source/oauth2/token.go b/services/auth/source/oauth2/token.go index 0c7c5d8caad7b..c9a45340a18d8 100644 --- a/services/auth/source/oauth2/token.go +++ b/services/auth/source/oauth2/token.go @@ -9,6 +9,7 @@ import ( "time" "code.gitea.io/gitea/modules/timeutil" + "github.com/golang-jwt/jwt" ) diff --git a/services/cron/setting.go b/services/cron/setting.go index d55e5b60ad69e..a0393e23dc837 100644 --- a/services/cron/setting.go +++ b/services/cron/setting.go @@ -8,6 +8,7 @@ import ( "time" "code.gitea.io/gitea/models" + "github.com/unknwon/i18n" ) diff --git a/services/forms/user_form_auth_openid.go b/services/forms/user_form_auth_openid.go index b34f9dcc97246..fd3368d303a90 100644 --- a/services/forms/user_form_auth_openid.go +++ b/services/forms/user_form_auth_openid.go @@ -9,6 +9,7 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/web/middleware" + "gitea.com/go-chi/binding" ) diff --git a/services/gitdiff/csv_test.go b/services/gitdiff/csv_test.go index 4101477d89c3d..b4f725e5589b3 100644 --- a/services/gitdiff/csv_test.go +++ b/services/gitdiff/csv_test.go @@ -11,6 +11,7 @@ import ( csv_module "code.gitea.io/gitea/modules/csv" "code.gitea.io/gitea/modules/setting" + "github.com/stretchr/testify/assert" ) diff --git a/services/gitdiff/gitdiff.go b/services/gitdiff/gitdiff.go index 614f8104ecaf2..885c9cdbb8d48 100644 --- a/services/gitdiff/gitdiff.go +++ b/services/gitdiff/gitdiff.go @@ -34,6 +34,7 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/sergi/go-diff/diffmatchpatch" + stdcharset "golang.org/x/net/html/charset" "golang.org/x/text/encoding" "golang.org/x/text/transform" diff --git a/services/gitdiff/gitdiff_test.go b/services/gitdiff/gitdiff_test.go index aefd396ebbae8..7cc0cc2deed3a 100644 --- a/services/gitdiff/gitdiff_test.go +++ b/services/gitdiff/gitdiff_test.go @@ -21,6 +21,7 @@ import ( dmp "github.com/sergi/go-diff/diffmatchpatch" "github.com/stretchr/testify/assert" + "gopkg.in/ini.v1" ) diff --git a/services/issue/assignee_test.go b/services/issue/assignee_test.go index b0bbe42273d11..bc2721ebd4195 100644 --- a/services/issue/assignee_test.go +++ b/services/issue/assignee_test.go @@ -9,6 +9,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/services/issue/label_test.go b/services/issue/label_test.go index fa6ad613b6942..fdc2c4ffb6414 100644 --- a/services/issue/label_test.go +++ b/services/issue/label_test.go @@ -9,6 +9,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/services/mailer/mailer.go b/services/mailer/mailer.go index fae8d473e3419..425eeaa4361e9 100644 --- a/services/mailer/mailer.go +++ b/services/mailer/mailer.go @@ -26,6 +26,7 @@ import ( "code.gitea.io/gitea/modules/setting" "github.com/jaytaylor/html2text" + "gopkg.in/gomail.v2" ) diff --git a/services/migrations/github.go b/services/migrations/github.go index 3043d7cf75ade..73b16c77e33c3 100644 --- a/services/migrations/github.go +++ b/services/migrations/github.go @@ -24,6 +24,7 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/google/go-github/v39/github" + "golang.org/x/oauth2" ) diff --git a/services/repository/fork_test.go b/services/repository/fork_test.go index 197d76b0561ae..1280a3d84da1b 100644 --- a/services/repository/fork_test.go +++ b/services/repository/fork_test.go @@ -9,6 +9,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/unittest" + "github.com/stretchr/testify/assert" ) diff --git a/services/webhook/deliver_test.go b/services/webhook/deliver_test.go index cfc99d796a536..551c957c8d1e2 100644 --- a/services/webhook/deliver_test.go +++ b/services/webhook/deliver_test.go @@ -10,6 +10,7 @@ import ( "testing" "code.gitea.io/gitea/modules/setting" + "github.com/stretchr/testify/assert" ) diff --git a/services/webhook/webhook_test.go b/services/webhook/webhook_test.go index 0a649d36aed89..c3323327870ff 100644 --- a/services/webhook/webhook_test.go +++ b/services/webhook/webhook_test.go @@ -11,6 +11,7 @@ import ( "code.gitea.io/gitea/models/unittest" webhook_model "code.gitea.io/gitea/models/webhook" api "code.gitea.io/gitea/modules/structs" + "github.com/stretchr/testify/assert" ) From acb0007530bd0d126cb8bdad2b99e908694e4d58 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 17 Nov 2021 18:03:20 +0800 Subject: [PATCH 3/3] re-format --- build/codeformat/formatimports.go | 2 +- build/codeformat/formatimports_test.go | 2 -- cmd/doctor.go | 1 - cmd/dump.go | 1 - cmd/web.go | 1 - contrib/environment-to-ini/environment-to-ini.go | 1 - contrib/pr/checkout.go | 1 - integrations/create_no_session_test.go | 1 - integrations/gpg_git_test.go | 1 - models/db/engine.go | 8 ++++---- models/db/sql_postgres_with_schema.go | 1 - models/external_login_user.go | 1 - models/gpg_key.go | 1 - models/issue_milestone_test.go | 1 - models/login/oauth2_application.go | 2 -- models/login/source_test.go | 1 - models/login/twofactor.go | 1 - models/migrations/migrations_test.go | 1 - models/migrations/v166.go | 1 - models/migrations/v71.go | 1 - models/ssh_key.go | 1 - models/unittest/consistency.go | 1 - models/unittest/fixtures.go | 1 - models/unittest/testdb.go | 1 - models/unittest/unit_tests.go | 1 - models/user.go | 1 - modules/cache/cache_redis.go | 1 - modules/cache/cache_twoqueue.go | 1 - modules/charset/charset.go | 1 - modules/context/context.go | 2 -- modules/doctor/misc.go | 1 - modules/indexer/issues/indexer_test.go | 1 - modules/indexer/stats/indexer_test.go | 1 - modules/log/console_windows.go | 1 - modules/markup/html.go | 2 -- modules/markup/markdown/renderconfig.go | 1 - modules/session/redis.go | 1 - modules/setting/cron_test.go | 1 - modules/setting/setting.go | 2 -- modules/setting/storage_test.go | 1 - modules/ssh/ssh.go | 1 - modules/translation/translation.go | 1 - modules/validation/binding.go | 1 - modules/validation/binding_test.go | 1 - modules/validation/glob_pattern_test.go | 1 - modules/web/middleware/binding.go | 1 - modules/web/middleware/locale.go | 1 - modules/web/route.go | 1 - routers/api/v1/api.go | 1 - routers/install/install.go | 1 - routers/web/user/home.go | 1 - routers/web/user/oauth.go | 1 - routers/web/web.go | 1 - services/auth/source/oauth2/jwtsigningkey.go | 1 - services/auth/source/oauth2/store.go | 1 - services/gitdiff/gitdiff.go | 1 - services/gitdiff/gitdiff_test.go | 1 - services/mailer/mailer.go | 1 - services/migrations/github.go | 1 - 59 files changed, 5 insertions(+), 67 deletions(-) diff --git a/build/codeformat/formatimports.go b/build/codeformat/formatimports.go index 59176500e0527..c6427f6a99855 100644 --- a/build/codeformat/formatimports.go +++ b/build/codeformat/formatimports.go @@ -46,7 +46,7 @@ func parseImportLine(line string) (*importLineParsed, error) { pDot := strings.IndexRune(il.pkg, '.') pSlash := strings.IndexRune(il.pkg, '/') if pDot != -1 && pDot < pSlash { - il.group = il.pkg[:pSlash] + il.group = "domain-package" } for groupName := range importPackageGroupOrders { if groupName == "" { diff --git a/build/codeformat/formatimports_test.go b/build/codeformat/formatimports_test.go index 34d0871c50e4e..d308353bdad91 100644 --- a/build/codeformat/formatimports_test.go +++ b/build/codeformat/formatimports_test.go @@ -86,11 +86,9 @@ import ( "code.gitea.io/gitea/modules/util" "code.gitea.io/other/package" - "github.com/issue9/identicon" "github.com/nfnt/resize" "github.com/oliamb/cutter" - "xorm.io/the/package" ) ` diff --git a/cmd/doctor.go b/cmd/doctor.go index 9afbf1f0d6cb9..27f91e41bb2b3 100644 --- a/cmd/doctor.go +++ b/cmd/doctor.go @@ -19,7 +19,6 @@ import ( "code.gitea.io/gitea/modules/setting" "github.com/urfave/cli" - "xorm.io/xorm" ) diff --git a/cmd/dump.go b/cmd/dump.go index f6821586d70e0..efb9397208594 100644 --- a/cmd/dump.go +++ b/cmd/dump.go @@ -21,7 +21,6 @@ import ( "code.gitea.io/gitea/modules/util" "gitea.com/go-chi/session" - archiver "github.com/mholt/archiver/v3" "github.com/urfave/cli" ) diff --git a/cmd/web.go b/cmd/web.go index 2d57951b07a03..4b6dfa71a2305 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -21,7 +21,6 @@ import ( "code.gitea.io/gitea/routers/install" "github.com/urfave/cli" - ini "gopkg.in/ini.v1" ) diff --git a/contrib/environment-to-ini/environment-to-ini.go b/contrib/environment-to-ini/environment-to-ini.go index b911d84acff9c..aade251902300 100644 --- a/contrib/environment-to-ini/environment-to-ini.go +++ b/contrib/environment-to-ini/environment-to-ini.go @@ -15,7 +15,6 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/urfave/cli" - ini "gopkg.in/ini.v1" ) diff --git a/contrib/pr/checkout.go b/contrib/pr/checkout.go index bc18eb47b5ca3..1e2a9714e38a6 100644 --- a/contrib/pr/checkout.go +++ b/contrib/pr/checkout.go @@ -37,7 +37,6 @@ import ( "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/config" "github.com/go-git/go-git/v5/plumbing" - "xorm.io/xorm" ) diff --git a/integrations/create_no_session_test.go b/integrations/create_no_session_test.go index 98141288083a9..a76ff1eaafb3d 100644 --- a/integrations/create_no_session_test.go +++ b/integrations/create_no_session_test.go @@ -17,7 +17,6 @@ import ( "code.gitea.io/gitea/routers" "gitea.com/go-chi/session" - "github.com/stretchr/testify/assert" ) diff --git a/integrations/gpg_git_test.go b/integrations/gpg_git_test.go index 2099d86ebe233..b136e822810a0 100644 --- a/integrations/gpg_git_test.go +++ b/integrations/gpg_git_test.go @@ -19,7 +19,6 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/stretchr/testify/assert" - "golang.org/x/crypto/openpgp" "golang.org/x/crypto/openpgp/armor" ) diff --git a/models/db/engine.go b/models/db/engine.go index 2f0c7bcf4f20e..b97e954cc3a9f 100755 --- a/models/db/engine.go +++ b/models/db/engine.go @@ -16,13 +16,13 @@ import ( "code.gitea.io/gitea/modules/setting" - _ "github.com/denisenkom/go-mssqldb" // Needed for the MSSQL driver - _ "github.com/go-sql-driver/mysql" // Needed for the MySQL driver - _ "github.com/lib/pq" // Needed for the Postgresql driver - "xorm.io/xorm" "xorm.io/xorm/names" "xorm.io/xorm/schemas" + + _ "github.com/denisenkom/go-mssqldb" // Needed for the MSSQL driver + _ "github.com/go-sql-driver/mysql" // Needed for the MySQL driver + _ "github.com/lib/pq" // Needed for the Postgresql driver ) var ( diff --git a/models/db/sql_postgres_with_schema.go b/models/db/sql_postgres_with_schema.go index 45041bc173814..d6b6262927c4a 100644 --- a/models/db/sql_postgres_with_schema.go +++ b/models/db/sql_postgres_with_schema.go @@ -12,7 +12,6 @@ import ( "code.gitea.io/gitea/modules/setting" "github.com/lib/pq" - "xorm.io/xorm/dialects" ) diff --git a/models/external_login_user.go b/models/external_login_user.go index 67358b1dc4f3f..6b023a4cb2a98 100644 --- a/models/external_login_user.go +++ b/models/external_login_user.go @@ -12,7 +12,6 @@ import ( "code.gitea.io/gitea/modules/structs" "github.com/markbates/goth" - "xorm.io/builder" ) diff --git a/models/gpg_key.go b/models/gpg_key.go index b5529cd95233a..357dc2b964cbf 100644 --- a/models/gpg_key.go +++ b/models/gpg_key.go @@ -16,7 +16,6 @@ import ( "github.com/keybase/go-crypto/openpgp" "github.com/keybase/go-crypto/openpgp/packet" - "xorm.io/xorm" ) diff --git a/models/issue_milestone_test.go b/models/issue_milestone_test.go index 946c531d6d499..2956e40f06580 100644 --- a/models/issue_milestone_test.go +++ b/models/issue_milestone_test.go @@ -15,7 +15,6 @@ import ( "code.gitea.io/gitea/modules/timeutil" "github.com/stretchr/testify/assert" - "xorm.io/builder" ) diff --git a/models/login/oauth2_application.go b/models/login/oauth2_application.go index c1f9e30081059..060bfe5bc3b0f 100644 --- a/models/login/oauth2_application.go +++ b/models/login/oauth2_application.go @@ -17,9 +17,7 @@ import ( "code.gitea.io/gitea/modules/util" uuid "github.com/google/uuid" - "golang.org/x/crypto/bcrypt" - "xorm.io/xorm" ) diff --git a/models/login/source_test.go b/models/login/source_test.go index a6aac3e47e4ec..e7ef7c70488c2 100644 --- a/models/login/source_test.go +++ b/models/login/source_test.go @@ -13,7 +13,6 @@ import ( "code.gitea.io/gitea/modules/json" "github.com/stretchr/testify/assert" - "xorm.io/xorm/schemas" ) diff --git a/models/login/twofactor.go b/models/login/twofactor.go index ff244df38e9e8..acb5e1b2d50ec 100644 --- a/models/login/twofactor.go +++ b/models/login/twofactor.go @@ -18,7 +18,6 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/pquerna/otp/totp" - "golang.org/x/crypto/pbkdf2" ) diff --git a/models/migrations/migrations_test.go b/models/migrations/migrations_test.go index 7e962a9623e0e..f46070cf8e588 100644 --- a/models/migrations/migrations_test.go +++ b/models/migrations/migrations_test.go @@ -24,7 +24,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/unknwon/com" - "xorm.io/xorm" "xorm.io/xorm/names" ) diff --git a/models/migrations/v166.go b/models/migrations/v166.go index ac27676ef655b..1b6e68b5733ab 100644 --- a/models/migrations/v166.go +++ b/models/migrations/v166.go @@ -12,7 +12,6 @@ import ( "golang.org/x/crypto/bcrypt" "golang.org/x/crypto/pbkdf2" "golang.org/x/crypto/scrypt" - "xorm.io/builder" "xorm.io/xorm" ) diff --git a/models/migrations/v71.go b/models/migrations/v71.go index f600c68f0b34c..e4ed46a21a5b1 100644 --- a/models/migrations/v71.go +++ b/models/migrations/v71.go @@ -12,7 +12,6 @@ import ( "code.gitea.io/gitea/modules/util" "golang.org/x/crypto/pbkdf2" - "xorm.io/xorm" ) diff --git a/models/ssh_key.go b/models/ssh_key.go index 3cba85c1af4a8..baa0d2a54fcfe 100644 --- a/models/ssh_key.go +++ b/models/ssh_key.go @@ -17,7 +17,6 @@ import ( "code.gitea.io/gitea/modules/util" "golang.org/x/crypto/ssh" - "xorm.io/builder" ) diff --git a/models/unittest/consistency.go b/models/unittest/consistency.go index 8d8a33be2435b..2645084d3ede3 100644 --- a/models/unittest/consistency.go +++ b/models/unittest/consistency.go @@ -12,7 +12,6 @@ import ( "code.gitea.io/gitea/models/db" "github.com/stretchr/testify/assert" - "xorm.io/builder" ) diff --git a/models/unittest/fixtures.go b/models/unittest/fixtures.go index af60df7b68e87..6277d1c72591d 100644 --- a/models/unittest/fixtures.go +++ b/models/unittest/fixtures.go @@ -12,7 +12,6 @@ import ( "code.gitea.io/gitea/models/db" "github.com/go-testfixtures/testfixtures/v3" - "xorm.io/xorm" "xorm.io/xorm/schemas" ) diff --git a/models/unittest/testdb.go b/models/unittest/testdb.go index bda8bc403e351..8771bc1d2139a 100644 --- a/models/unittest/testdb.go +++ b/models/unittest/testdb.go @@ -18,7 +18,6 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/stretchr/testify/assert" - "xorm.io/xorm" "xorm.io/xorm/names" ) diff --git a/models/unittest/unit_tests.go b/models/unittest/unit_tests.go index b75a61edc9c29..6c20c2781bb4d 100644 --- a/models/unittest/unit_tests.go +++ b/models/unittest/unit_tests.go @@ -10,7 +10,6 @@ import ( "code.gitea.io/gitea/models/db" "github.com/stretchr/testify/assert" - "xorm.io/builder" ) diff --git a/models/user.go b/models/user.go index 6cfaf78e6cb91..4056cfe9e98b7 100644 --- a/models/user.go +++ b/models/user.go @@ -39,7 +39,6 @@ import ( "golang.org/x/crypto/bcrypt" "golang.org/x/crypto/pbkdf2" "golang.org/x/crypto/scrypt" - "xorm.io/builder" "xorm.io/xorm" ) diff --git a/modules/cache/cache_redis.go b/modules/cache/cache_redis.go index f56e93b133084..148725ae66015 100644 --- a/modules/cache/cache_redis.go +++ b/modules/cache/cache_redis.go @@ -12,7 +12,6 @@ import ( "code.gitea.io/gitea/modules/nosql" "gitea.com/go-chi/cache" - "github.com/go-redis/redis/v8" "github.com/unknwon/com" ) diff --git a/modules/cache/cache_twoqueue.go b/modules/cache/cache_twoqueue.go index d1082d46936b7..275b73f068f29 100644 --- a/modules/cache/cache_twoqueue.go +++ b/modules/cache/cache_twoqueue.go @@ -12,7 +12,6 @@ import ( "code.gitea.io/gitea/modules/json" mc "gitea.com/go-chi/cache" - lru "github.com/hashicorp/golang-lru" ) diff --git a/modules/charset/charset.go b/modules/charset/charset.go index 0ca01588306dd..ae5cf5aa1a4eb 100644 --- a/modules/charset/charset.go +++ b/modules/charset/charset.go @@ -16,7 +16,6 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/gogs/chardet" - "golang.org/x/net/html/charset" "golang.org/x/text/transform" ) diff --git a/modules/context/context.go b/modules/context/context.go index 73be26dc871da..8adf1f306bd6d 100644 --- a/modules/context/context.go +++ b/modules/context/context.go @@ -34,12 +34,10 @@ import ( "gitea.com/go-chi/cache" "gitea.com/go-chi/session" - chi "github.com/go-chi/chi/v5" "github.com/unknwon/com" "github.com/unknwon/i18n" "github.com/unrolled/render" - "golang.org/x/crypto/pbkdf2" ) diff --git a/modules/doctor/misc.go b/modules/doctor/misc.go index 8ef3b84685029..2f748bcb71870 100644 --- a/modules/doctor/misc.go +++ b/modules/doctor/misc.go @@ -21,7 +21,6 @@ import ( "code.gitea.io/gitea/modules/util" lru "github.com/hashicorp/golang-lru" - "xorm.io/builder" ) diff --git a/modules/indexer/issues/indexer_test.go b/modules/indexer/issues/indexer_test.go index a462bba433a03..8353891c7c21a 100644 --- a/modules/indexer/issues/indexer_test.go +++ b/modules/indexer/issues/indexer_test.go @@ -16,7 +16,6 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/stretchr/testify/assert" - "gopkg.in/ini.v1" ) diff --git a/modules/indexer/stats/indexer_test.go b/modules/indexer/stats/indexer_test.go index 1a7142c7bc418..f52d73a32e775 100644 --- a/modules/indexer/stats/indexer_test.go +++ b/modules/indexer/stats/indexer_test.go @@ -14,7 +14,6 @@ import ( "code.gitea.io/gitea/modules/setting" "github.com/stretchr/testify/assert" - "gopkg.in/ini.v1" ) diff --git a/modules/log/console_windows.go b/modules/log/console_windows.go index 8b242673e83a4..ea47e5d624421 100644 --- a/modules/log/console_windows.go +++ b/modules/log/console_windows.go @@ -8,7 +8,6 @@ import ( "os" "github.com/mattn/go-isatty" - "golang.org/x/sys/windows" ) diff --git a/modules/markup/html.go b/modules/markup/html.go index a6cb91d438c5d..746830720da90 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -24,10 +24,8 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/unknwon/com" - "golang.org/x/net/html" "golang.org/x/net/html/atom" - "mvdan.cc/xurls/v2" ) diff --git a/modules/markup/markdown/renderconfig.go b/modules/markup/markdown/renderconfig.go index 3acec15dcd343..bef67e9e59bf2 100644 --- a/modules/markup/markdown/renderconfig.go +++ b/modules/markup/markdown/renderconfig.go @@ -10,7 +10,6 @@ import ( "github.com/yuin/goldmark/ast" east "github.com/yuin/goldmark/extension/ast" - "gopkg.in/yaml.v2" ) diff --git a/modules/session/redis.go b/modules/session/redis.go index 53bbcad7733fa..334418bd7e5d3 100644 --- a/modules/session/redis.go +++ b/modules/session/redis.go @@ -25,7 +25,6 @@ import ( "code.gitea.io/gitea/modules/nosql" "gitea.com/go-chi/session" - "github.com/go-redis/redis/v8" ) diff --git a/modules/setting/cron_test.go b/modules/setting/cron_test.go index fd0ab2677c042..8670a92bac964 100644 --- a/modules/setting/cron_test.go +++ b/modules/setting/cron_test.go @@ -8,7 +8,6 @@ import ( "testing" "github.com/stretchr/testify/assert" - ini "gopkg.in/ini.v1" ) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 36e8bcab2cd6d..c5608c85bc53b 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -30,9 +30,7 @@ import ( shellquote "github.com/kballard/go-shellquote" "github.com/unknwon/com" - gossh "golang.org/x/crypto/ssh" - ini "gopkg.in/ini.v1" ) diff --git a/modules/setting/storage_test.go b/modules/setting/storage_test.go index 6d2323e46c782..ffd8b7aa014ba 100644 --- a/modules/setting/storage_test.go +++ b/modules/setting/storage_test.go @@ -8,7 +8,6 @@ import ( "testing" "github.com/stretchr/testify/assert" - ini "gopkg.in/ini.v1" ) diff --git a/modules/ssh/ssh.go b/modules/ssh/ssh.go index f955dced136fe..5f19dd4a5c7ef 100644 --- a/modules/ssh/ssh.go +++ b/modules/ssh/ssh.go @@ -28,7 +28,6 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/gliderlabs/ssh" - gossh "golang.org/x/crypto/ssh" ) diff --git a/modules/translation/translation.go b/modules/translation/translation.go index ef9f824a3815a..77cc9ac7f5847 100644 --- a/modules/translation/translation.go +++ b/modules/translation/translation.go @@ -10,7 +10,6 @@ import ( "code.gitea.io/gitea/modules/setting" "github.com/unknwon/i18n" - "golang.org/x/text/language" ) diff --git a/modules/validation/binding.go b/modules/validation/binding.go index 941ed12b6b523..5d5c64611f29a 100644 --- a/modules/validation/binding.go +++ b/modules/validation/binding.go @@ -10,7 +10,6 @@ import ( "strings" "gitea.com/go-chi/binding" - "github.com/gobwas/glob" ) diff --git a/modules/validation/binding_test.go b/modules/validation/binding_test.go index 33dd5265d0977..aa8a765524480 100644 --- a/modules/validation/binding_test.go +++ b/modules/validation/binding_test.go @@ -10,7 +10,6 @@ import ( "testing" "gitea.com/go-chi/binding" - chi "github.com/go-chi/chi/v5" "github.com/stretchr/testify/assert" ) diff --git a/modules/validation/glob_pattern_test.go b/modules/validation/glob_pattern_test.go index f4d36099429ad..cbaed7e66ac24 100644 --- a/modules/validation/glob_pattern_test.go +++ b/modules/validation/glob_pattern_test.go @@ -8,7 +8,6 @@ import ( "testing" "gitea.com/go-chi/binding" - "github.com/gobwas/glob" ) diff --git a/modules/web/middleware/binding.go b/modules/web/middleware/binding.go index e3cbeb9f1afc0..cbdb29b812942 100644 --- a/modules/web/middleware/binding.go +++ b/modules/web/middleware/binding.go @@ -13,7 +13,6 @@ import ( "code.gitea.io/gitea/modules/validation" "gitea.com/go-chi/binding" - "github.com/unknwon/com" ) diff --git a/modules/web/middleware/locale.go b/modules/web/middleware/locale.go index 9e935e8f28053..ede38ef933c03 100644 --- a/modules/web/middleware/locale.go +++ b/modules/web/middleware/locale.go @@ -11,7 +11,6 @@ import ( "code.gitea.io/gitea/modules/translation" "github.com/unknwon/i18n" - "golang.org/x/text/language" ) diff --git a/modules/web/route.go b/modules/web/route.go index 56ca4e0055a89..ad9cea8bb6e14 100644 --- a/modules/web/route.go +++ b/modules/web/route.go @@ -15,7 +15,6 @@ import ( "code.gitea.io/gitea/modules/web/middleware" "gitea.com/go-chi/binding" - chi "github.com/go-chi/chi/v5" ) diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 0b9682014ef00..ab8b07d609217 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -90,7 +90,6 @@ import ( _ "code.gitea.io/gitea/routers/api/v1/swagger" // for swagger generation "gitea.com/go-chi/binding" - "github.com/go-chi/cors" ) diff --git a/routers/install/install.go b/routers/install/install.go index 926852ef670ea..837467056dc13 100644 --- a/routers/install/install.go +++ b/routers/install/install.go @@ -32,7 +32,6 @@ import ( "code.gitea.io/gitea/services/forms" "gitea.com/go-chi/session" - "gopkg.in/ini.v1" ) diff --git a/routers/web/user/home.go b/routers/web/user/home.go index 8ac3fb81f8ff6..b9f5d044fa552 100644 --- a/routers/web/user/home.go +++ b/routers/web/user/home.go @@ -32,7 +32,6 @@ import ( "github.com/keybase/go-crypto/openpgp" "github.com/keybase/go-crypto/openpgp/armor" - "xorm.io/builder" ) diff --git a/routers/web/user/oauth.go b/routers/web/user/oauth.go index cca3223e496a3..3210d033d3c22 100644 --- a/routers/web/user/oauth.go +++ b/routers/web/user/oauth.go @@ -26,7 +26,6 @@ import ( "code.gitea.io/gitea/services/forms" "gitea.com/go-chi/binding" - "github.com/golang-jwt/jwt" ) diff --git a/routers/web/web.go b/routers/web/web.go index 2b17e2fc3ee3d..f84d357bb126e 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -39,7 +39,6 @@ import ( _ "code.gitea.io/gitea/modules/session" // to registers all internal adapters "gitea.com/go-chi/captcha" - "github.com/NYTimes/gziphandler" "github.com/go-chi/chi/middleware" "github.com/go-chi/cors" diff --git a/services/auth/source/oauth2/jwtsigningkey.go b/services/auth/source/oauth2/jwtsigningkey.go index f995bfd51d202..3102be5f143a2 100644 --- a/services/auth/source/oauth2/jwtsigningkey.go +++ b/services/auth/source/oauth2/jwtsigningkey.go @@ -26,7 +26,6 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/golang-jwt/jwt" - ini "gopkg.in/ini.v1" ) diff --git a/services/auth/source/oauth2/store.go b/services/auth/source/oauth2/store.go index 9fe8ffa4c7b11..4026abb6ecdef 100644 --- a/services/auth/source/oauth2/store.go +++ b/services/auth/source/oauth2/store.go @@ -12,7 +12,6 @@ import ( "code.gitea.io/gitea/modules/log" chiSession "gitea.com/go-chi/session" - "github.com/gorilla/sessions" ) diff --git a/services/gitdiff/gitdiff.go b/services/gitdiff/gitdiff.go index 885c9cdbb8d48..614f8104ecaf2 100644 --- a/services/gitdiff/gitdiff.go +++ b/services/gitdiff/gitdiff.go @@ -34,7 +34,6 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/sergi/go-diff/diffmatchpatch" - stdcharset "golang.org/x/net/html/charset" "golang.org/x/text/encoding" "golang.org/x/text/transform" diff --git a/services/gitdiff/gitdiff_test.go b/services/gitdiff/gitdiff_test.go index 7cc0cc2deed3a..aefd396ebbae8 100644 --- a/services/gitdiff/gitdiff_test.go +++ b/services/gitdiff/gitdiff_test.go @@ -21,7 +21,6 @@ import ( dmp "github.com/sergi/go-diff/diffmatchpatch" "github.com/stretchr/testify/assert" - "gopkg.in/ini.v1" ) diff --git a/services/mailer/mailer.go b/services/mailer/mailer.go index 425eeaa4361e9..fae8d473e3419 100644 --- a/services/mailer/mailer.go +++ b/services/mailer/mailer.go @@ -26,7 +26,6 @@ import ( "code.gitea.io/gitea/modules/setting" "github.com/jaytaylor/html2text" - "gopkg.in/gomail.v2" ) diff --git a/services/migrations/github.go b/services/migrations/github.go index 73b16c77e33c3..3043d7cf75ade 100644 --- a/services/migrations/github.go +++ b/services/migrations/github.go @@ -24,7 +24,6 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/google/go-github/v39/github" - "golang.org/x/oauth2" )