From 70ccec328d380b40c0ad09907957ca22615cd782 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Tue, 4 Mar 2025 22:15:29 +0000 Subject: [PATCH] Update golang packages to v1.23 (v7.0/forgejo) (minor) (#7081) - Bump golangci-lint and fixes new linting issues. - Bump golang.org/x/crypto. - Bump deadcode package - Bump govulncheck. Co-authored-by: Gusted Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7081 Reviewed-by: Michael Kriese Co-authored-by: Renovate Bot Co-committed-by: Renovate Bot --- .deadcode-out | 563 +++++++++--------- .devcontainer/devcontainer.json | 2 +- .forgejo/workflows/build-release.yml | 2 +- .forgejo/workflows/e2e.yml | 2 +- .forgejo/workflows/testing.yml | 10 +- Dockerfile | 2 +- Dockerfile.rootless | 2 +- Makefile | 12 +- cmd/hook.go | 4 +- cmd/hook_test.go | 12 +- go.mod | 12 +- go.sum | 20 +- models/activities/user_heatmap_test.go | 5 +- models/asymkey/gpg_key_common.go | 4 +- models/auth/oauth2_test.go | 2 +- models/git/protected_branch_test.go | 3 +- models/migrations/v1_16/v189.go | 2 +- models/migrations/v1_16/v193_test.go | 8 +- models/project/board_test.go | 3 +- models/repo/repo_list.go | 2 +- models/user/user_test.go | 2 +- modules/activitypub/client_test.go | 3 +- modules/cache/context.go | 4 +- modules/git/log_name_status.go | 2 +- modules/issue/template/template.go | 2 +- modules/lfs/http_client_test.go | 4 +- modules/lfs/transferadapter_test.go | 6 +- modules/queue/base_channel.go | 2 +- modules/queue/workerqueue_test.go | 4 +- modules/setting/storage_test.go | 2 +- modules/util/keypair_test.go | 5 +- routers/api/v1/repo/pull.go | 2 +- routers/web/repo/pull.go | 2 +- routers/web/repo/view.go | 3 +- routers/web/user/home.go | 3 +- routers/web/user/profile.go | 2 +- services/actions/notifier_helper.go | 4 +- services/automerge/automerge.go | 2 +- services/gitdiff/gitdiff.go | 6 +- services/gitdiff/gitdiff_test.go | 5 +- services/release/release_test.go | 2 +- .../repository/contributors_graph_test.go | 2 +- tests/integration/api_issue_stopwatch_test.go | 2 +- tests/integration/api_notification_test.go | 2 +- tests/integration/api_push_mirror_test.go | 5 +- tests/integration/api_releases_test.go | 6 +- tests/integration/api_repo_teams_test.go | 2 +- tests/integration/compare_test.go | 2 +- tests/integration/migrate_test.go | 2 +- tests/integration/repo_fork_test.go | 2 +- tests/integration/repo_generate_test.go | 2 +- tests/integration/repo_test.go | 2 +- tests/integration/user_test.go | 2 +- 53 files changed, 389 insertions(+), 381 deletions(-) diff --git a/.deadcode-out b/.deadcode-out index 80359e7dbb..c467bff47d 100644 --- a/.deadcode-out +++ b/.deadcode-out @@ -1,343 +1,346 @@ -package "code.gitea.io/gitea/cmd" - func NoMainListener +code.gitea.io/gitea/cmd + NoMainListener -package "code.gitea.io/gitea/cmd/forgejo" - func ContextSetNoInit - func ContextSetNoExit - func ContextSetStderr - func ContextGetStderr - func ContextSetStdout - func ContextSetStdin +code.gitea.io/gitea/cmd/forgejo + ContextSetNoInit + ContextSetNoExit + ContextSetStderr + ContextGetStderr + ContextSetStdout + ContextSetStdin -package "code.gitea.io/gitea/models" - func IsErrUpdateTaskNotExist - func (ErrUpdateTaskNotExist).Error - func (ErrUpdateTaskNotExist).Unwrap - func IsErrSHANotFound - func IsErrMergeDivergingFastForwardOnly - func GetYamlFixturesAccess +code.gitea.io/gitea/models + IsErrUpdateTaskNotExist + ErrUpdateTaskNotExist.Error + ErrUpdateTaskNotExist.Unwrap + IsErrSHANotFound + IsErrMergeDivergingFastForwardOnly + GetYamlFixturesAccess -package "code.gitea.io/gitea/models/actions" - func (ScheduleList).GetUserIDs - func (ScheduleList).GetRepoIDs - func (ScheduleList).LoadTriggerUser - func (ScheduleList).LoadRepos +code.gitea.io/gitea/models/actions + ScheduleList.GetUserIDs + ScheduleList.GetRepoIDs + ScheduleList.LoadTriggerUser + ScheduleList.LoadRepos -package "code.gitea.io/gitea/models/asymkey" - func (ErrGPGKeyAccessDenied).Error - func (ErrGPGKeyAccessDenied).Unwrap - func HasDeployKey +code.gitea.io/gitea/models/asymkey + ErrGPGKeyAccessDenied.Error + ErrGPGKeyAccessDenied.Unwrap + HasDeployKey -package "code.gitea.io/gitea/models/auth" - func GetSourceByName - func GetWebAuthnCredentialByID - func WebAuthnCredentials +code.gitea.io/gitea/models/auth + GetSourceByName + GetWebAuthnCredentialByID + WebAuthnCredentials -package "code.gitea.io/gitea/models/db" - func TruncateBeans - func InTransaction - func DumpTables +code.gitea.io/gitea/models/db + TruncateBeans + InTransaction + DumpTables -package "code.gitea.io/gitea/models/dbfs" - func (*file).renameTo - func Create - func Rename +code.gitea.io/gitea/models/dbfs + file.renameTo + Create + Rename -package "code.gitea.io/gitea/models/forgejo/semver" - func GetVersion - func SetVersionString - func SetVersion +code.gitea.io/gitea/models/forgejo/semver + GetVersion + SetVersionString + SetVersion -package "code.gitea.io/gitea/models/git" - func RemoveDeletedBranchByID +code.gitea.io/gitea/models/git + RemoveDeletedBranchByID -package "code.gitea.io/gitea/models/issues" - func IsErrUnknownDependencyType - func (ErrNewIssueInsert).Error - func IsErrIssueWasClosed - func ChangeMilestoneStatus +code.gitea.io/gitea/models/issues + IsErrUnknownDependencyType + ErrNewIssueInsert.Error + IsErrIssueWasClosed + ChangeMilestoneStatus -package "code.gitea.io/gitea/models/migrations/base" - func removeAllWithRetry - func newXORMEngine - func deleteDB - func PrepareTestEnv - func MainTest +code.gitea.io/gitea/models/migrations/base + removeAllWithRetry + newXORMEngine + deleteDB + PrepareTestEnv + MainTest -package "code.gitea.io/gitea/models/organization" - func GetTeamNamesByID - func UpdateTeamUnits - func (SearchMembersOptions).ToConds - func UsersInTeamsCount +code.gitea.io/gitea/models/organization + GetTeamNamesByID + UpdateTeamUnits + SearchMembersOptions.ToConds + UsersInTeamsCount -package "code.gitea.io/gitea/models/perm/access" - func GetRepoWriters +code.gitea.io/gitea/models/perm/access + GetRepoWriters -package "code.gitea.io/gitea/models/project" - func UpdateBoardSorting - func ChangeProjectStatus +code.gitea.io/gitea/models/project + UpdateBoardSorting + ChangeProjectStatus -package "code.gitea.io/gitea/models/repo" - func DeleteAttachmentsByIssue - func (*releaseSorter).Len - func (*releaseSorter).Less - func (*releaseSorter).Swap - func SortReleases - func FindReposMapByIDs - func (SearchOrderBy).String - func IsErrTopicNotExist - func (ErrTopicNotExist).Error - func (ErrTopicNotExist).Unwrap - func GetTopicByName - func WatchRepoMode +code.gitea.io/gitea/models/repo + DeleteAttachmentsByIssue + releaseSorter.Len + releaseSorter.Less + releaseSorter.Swap + SortReleases + FindReposMapByIDs + SearchOrderBy.String + IsErrTopicNotExist + ErrTopicNotExist.Error + ErrTopicNotExist.Unwrap + GetTopicByName + WatchRepoMode -package "code.gitea.io/gitea/models/unittest" - func CheckConsistencyFor - func checkForConsistency - func GetXORMEngine - func OverrideFixtures - func InitFixtures - func LoadFixtures - func Copy - func CopyDir - func NewMockWebServer - func NormalizedFullPath - func FixturesDir - func fatalTestError - func InitSettings - func MainTest - func CreateTestEngine - func PrepareTestDatabase - func PrepareTestEnv - func Cond - func OrderBy - func LoadBeanIfExists - func BeanExists - func AssertExistsAndLoadBean - func GetCount - func AssertNotExistsBean - func AssertExistsIf - func AssertSuccessfulInsert - func AssertCount - func AssertInt64InRange +code.gitea.io/gitea/models/unittest + CheckConsistencyFor + checkForConsistency + GetXORMEngine + OverrideFixtures + InitFixtures + LoadFixtures + Copy + CopyDir + NewMockWebServer + NormalizedFullPath + FixturesDir + fatalTestError + InitSettings + MainTest + CreateTestEngine + PrepareTestDatabase + PrepareTestEnv + Cond + OrderBy + LoadBeanIfExists + BeanExists + AssertExistsAndLoadBean + GetCount + AssertNotExistsBean + AssertExistsIf + AssertSuccessfulInsert + AssertCount + AssertInt64InRange -package "code.gitea.io/gitea/models/user" - func IsErrPrimaryEmailCannotDelete - func (ErrUserInactive).Error - func (ErrUserInactive).Unwrap - func IsErrExternalLoginUserAlreadyExist - func IsErrExternalLoginUserNotExist - func IsErrUserSettingIsNotExist - func GetUserAllSettings - func DeleteUserSetting - func GetUserEmailsByNames - func GetUserNamesByIDs +code.gitea.io/gitea/models/user + IsErrPrimaryEmailCannotDelete + ErrUserInactive.Error + ErrUserInactive.Unwrap + IsErrExternalLoginUserAlreadyExist + IsErrExternalLoginUserNotExist + IsErrUserSettingIsNotExist + GetUserAllSettings + DeleteUserSetting + GetUserEmailsByNames + GetUserNamesByIDs -package "code.gitea.io/gitea/modules/activitypub" - func CurrentTime - func containsRequiredHTTPHeaders - func NewClient - func (*Client).NewRequest - func (*Client).Post - func GetPrivateKey +code.gitea.io/gitea/modules/activitypub + CurrentTime + containsRequiredHTTPHeaders + NewClient + Client.NewRequest + Client.Post + GetPrivateKey -package "code.gitea.io/gitea/modules/assetfs" - func Bindata +code.gitea.io/gitea/modules/assetfs + Bindata -package "code.gitea.io/gitea/modules/auth/password/hash" - func (*DummyHasher).HashWithSaltBytes - func NewDummyHasher +code.gitea.io/gitea/modules/auth/password/hash + DummyHasher.HashWithSaltBytes + NewDummyHasher -package "code.gitea.io/gitea/modules/auth/password/pwn" - func WithHTTP +code.gitea.io/gitea/modules/auth/password/pwn + WithHTTP -package "code.gitea.io/gitea/modules/base" - func SetupGiteaRoot +code.gitea.io/gitea/modules/base + SetupGiteaRoot -package "code.gitea.io/gitea/modules/cache" - func GetInt - func WithNoCacheContext - func RemoveContextData +code.gitea.io/gitea/modules/cache + GetInt + WithNoCacheContext + RemoveContextData -package "code.gitea.io/gitea/modules/charset" - func (*BreakWriter).Write +code.gitea.io/gitea/modules/charset + BreakWriter.Write -package "code.gitea.io/gitea/modules/emoji" - func ReplaceCodes +code.gitea.io/gitea/modules/emoji + ReplaceCodes -package "code.gitea.io/gitea/modules/eventsource" - func (*Event).String +code.gitea.io/gitea/modules/eventsource + Event.String -package "code.gitea.io/gitea/modules/git" - func AllowLFSFiltersArgs - func AddChanges - func AddChangesWithArgs - func CommitChanges - func CommitChangesWithArgs - func IsErrExecTimeout - func (ErrExecTimeout).Error - func (ErrUnsupportedVersion).Error - func SetUpdateHook - func openRepositoryWithDefaultContext - func IsTagExist - func ToEntryMode - func (*LimitedReaderCloser).Read - func (*LimitedReaderCloser).Close +code.gitea.io/gitea/modules/git + AllowLFSFiltersArgs + AddChanges + AddChangesWithArgs + CommitChanges + CommitChangesWithArgs + IsErrExecTimeout + ErrExecTimeout.Error + ErrUnsupportedVersion.Error + SetUpdateHook + openRepositoryWithDefaultContext + IsTagExist + ToEntryMode + LimitedReaderCloser.Read + LimitedReaderCloser.Close -package "code.gitea.io/gitea/modules/gitgraph" - func (*Parser).Reset +code.gitea.io/gitea/modules/gitgraph + Parser.Reset -package "code.gitea.io/gitea/modules/gitrepo" - func GetBranchCommitID - func GetWikiDefaultBranch +code.gitea.io/gitea/modules/gitrepo + GetBranchCommitID + GetWikiDefaultBranch -package "code.gitea.io/gitea/modules/graceful" - func (*Manager).TerminateContext - func (*Manager).Err - func (*Manager).Value - func (*Manager).Deadline +code.gitea.io/gitea/modules/graceful + Manager.TerminateContext + Manager.Err + Manager.Value + Manager.Deadline -package "code.gitea.io/gitea/modules/hcaptcha" - func WithHTTP +code.gitea.io/gitea/modules/hcaptcha + WithHTTP -package "code.gitea.io/gitea/modules/json" - func (StdJSON).Marshal - func (StdJSON).Unmarshal - func (StdJSON).NewEncoder - func (StdJSON).NewDecoder - func (StdJSON).Indent +code.gitea.io/gitea/modules/json + StdJSON.Marshal + StdJSON.Unmarshal + StdJSON.NewEncoder + StdJSON.NewDecoder + StdJSON.Indent -package "code.gitea.io/gitea/modules/markup" - func IsSameDomain - func GetRendererByType - func RenderString - func IsMarkupFile +code.gitea.io/gitea/modules/markup + IsSameDomain + GetRendererByType + RenderString + IsMarkupFile -package "code.gitea.io/gitea/modules/markup/console" - func Render - func RenderString +code.gitea.io/gitea/modules/markup/console + Render + RenderString -package "code.gitea.io/gitea/modules/markup/markdown" - func IsDetails - func IsSummary - func IsTaskCheckBoxListItem - func IsIcon - func RenderRawString +code.gitea.io/gitea/modules/markup/markdown + IsDetails + IsSummary + IsTaskCheckBoxListItem + IsIcon + RenderRawString -package "code.gitea.io/gitea/modules/markup/markdown/math" - func WithInlineDollarParser - func WithBlockDollarParser +code.gitea.io/gitea/modules/markup/markdown/math + WithInlineDollarParser + WithBlockDollarParser -package "code.gitea.io/gitea/modules/markup/mdstripper" - func StripMarkdown +code.gitea.io/gitea/modules/markup/mdstripper + stripRenderer.AddOptions + StripMarkdown -package "code.gitea.io/gitea/modules/markup/orgmode" - func RenderString +code.gitea.io/gitea/modules/markup/orgmode + RenderString -package "code.gitea.io/gitea/modules/private" - func ActionsRunnerRegister +code.gitea.io/gitea/modules/private + ActionsRunnerRegister -package "code.gitea.io/gitea/modules/process" - func (*Manager).ExecTimeout +code.gitea.io/gitea/modules/process + Manager.ExecTimeout -package "code.gitea.io/gitea/modules/queue" - func newBaseChannelSimple - func newBaseChannelUnique - func newBaseRedisSimple - func newBaseRedisUnique - func newWorkerPoolQueueForTest +code.gitea.io/gitea/modules/queue + newBaseChannelSimple + newBaseChannelUnique + newBaseRedisSimple + newBaseRedisUnique + testStateRecorder.Records + testStateRecorder.Reset + newWorkerPoolQueueForTest -package "code.gitea.io/gitea/modules/queue/lqinternal" - func QueueItemIDBytes - func QueueItemKeyBytes - func ListLevelQueueKeys +code.gitea.io/gitea/modules/queue/lqinternal + QueueItemIDBytes + QueueItemKeyBytes + ListLevelQueueKeys -package "code.gitea.io/gitea/modules/setting" - func NewConfigProviderFromData - func (*GitConfigType).GetOption - func InitLoggersForTest +code.gitea.io/gitea/modules/setting + NewConfigProviderFromData + GitConfigType.GetOption + InitLoggersForTest -package "code.gitea.io/gitea/modules/storage" - func (ErrInvalidConfiguration).Error - func IsErrInvalidConfiguration +code.gitea.io/gitea/modules/storage + ErrInvalidConfiguration.Error + IsErrInvalidConfiguration -package "code.gitea.io/gitea/modules/structs" - func ParseCreateHook - func ParsePushHook +code.gitea.io/gitea/modules/structs + ParseCreateHook + ParsePushHook -package "code.gitea.io/gitea/modules/sync" - func (*StatusTable).Start - func (*StatusTable).IsRunning +code.gitea.io/gitea/modules/sync + StatusTable.Start + StatusTable.IsRunning -package "code.gitea.io/gitea/modules/testlogger" - func (*testLoggerWriterCloser).pushT - func (*testLoggerWriterCloser).Log - func (*testLoggerWriterCloser).recordError - func (*testLoggerWriterCloser).printMsg - func (*testLoggerWriterCloser).popT - func (*testLoggerWriterCloser).Reset - func PrintCurrentTest - func Printf - func NewTestLoggerWriter - func (*TestLogEventWriter).Base - func (*TestLogEventWriter).GetLevel - func (*TestLogEventWriter).GetWriterName - func (*TestLogEventWriter).GetWriterType - func (*TestLogEventWriter).Run +code.gitea.io/gitea/modules/testlogger + testLoggerWriterCloser.pushT + testLoggerWriterCloser.Log + testLoggerWriterCloser.recordError + testLoggerWriterCloser.printMsg + testLoggerWriterCloser.popT + testLoggerWriterCloser.Reset + PrintCurrentTest + Printf + NewTestLoggerWriter + TestLogEventWriter.Base + TestLogEventWriter.GetLevel + TestLogEventWriter.GetWriterName + TestLogEventWriter.GetWriterType + TestLogEventWriter.Run -package "code.gitea.io/gitea/modules/timeutil" - func GetExecutableModTime - func MockSet - func MockUnset +code.gitea.io/gitea/modules/timeutil + GetExecutableModTime + MockSet + MockUnset -package "code.gitea.io/gitea/modules/translation" - func (MockLocale).Language - func (MockLocale).TrString - func (MockLocale).Tr - func (MockLocale).TrN - func (MockLocale).TrSize - func (MockLocale).PrettyNumber +code.gitea.io/gitea/modules/translation + MockLocale.Language + MockLocale.TrString + MockLocale.Tr + MockLocale.TrN + MockLocale.TrSize + MockLocale.PrettyNumber -package "code.gitea.io/gitea/modules/util/filebuffer" - func CreateFromReader +code.gitea.io/gitea/modules/util/filebuffer + CreateFromReader -package "code.gitea.io/gitea/modules/web" - func RouteMock - func RouteMockReset +code.gitea.io/gitea/modules/web + RouteMock + RouteMockReset -package "code.gitea.io/gitea/modules/web/middleware" - func DeleteLocaleCookie +code.gitea.io/gitea/modules/web/middleware + DeleteLocaleCookie -package "code.gitea.io/gitea/routers/web" - func NotFound +code.gitea.io/gitea/routers/web + NotFound -package "code.gitea.io/gitea/routers/web/org" - func MustEnableProjects +code.gitea.io/gitea/routers/web/org + MustEnableProjects -package "code.gitea.io/gitea/services/context" - func GetPrivateContext +code.gitea.io/gitea/services/context + GetPrivateContext -package "code.gitea.io/gitea/services/convert" - func ToSecret +code.gitea.io/gitea/services/convert + ToSecret -package "code.gitea.io/gitea/services/forms" - func (*DeadlineForm).Validate +code.gitea.io/gitea/services/forms + DeadlineForm.Validate -package "code.gitea.io/gitea/services/pull" - func IsCommitStatusContextSuccess +code.gitea.io/gitea/services/pull + IsCommitStatusContextSuccess -package "code.gitea.io/gitea/services/repository" - func IsErrForkAlreadyExist +code.gitea.io/gitea/services/repository + IsErrForkAlreadyExist -package "code.gitea.io/gitea/services/repository/archiver" - func ArchiveRepository +code.gitea.io/gitea/services/repository/archiver + ArchiveRepository -package "code.gitea.io/gitea/services/repository/files" - func (*ContentType).String - func GetFileResponseFromCommit - func (*TemporaryUploadRepository).GetLastCommit - func (*TemporaryUploadRepository).GetLastCommitByRef +code.gitea.io/gitea/services/repository/files + ContentType.String + GetFileResponseFromCommit + TemporaryUploadRepository.GetLastCommit + TemporaryUploadRepository.GetLastCommitByRef -package "code.gitea.io/gitea/services/webhook" - func NewNotifier +code.gitea.io/gitea/services/webhook + NewNotifier diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 1b1b66c7dd..aa57f871ce 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,6 @@ { "name": "Gitea DevContainer", - "image": "mcr.microsoft.com/devcontainers/go:1.21-bullseye", + "image": "mcr.microsoft.com/devcontainers/go:1.23-bullseye", "features": { // installs nodejs into container "ghcr.io/devcontainers/features/node:1": { diff --git a/.forgejo/workflows/build-release.yml b/.forgejo/workflows/build-release.yml index e50230d313..aa2779aed6 100644 --- a/.forgejo/workflows/build-release.yml +++ b/.forgejo/workflows/build-release.yml @@ -43,7 +43,7 @@ jobs: - uses: https://code.forgejo.org/actions/setup-go@v4 with: - go-version: "1.22" + go-version: "1.23" check-latest: true - name: version from ref diff --git a/.forgejo/workflows/e2e.yml b/.forgejo/workflows/e2e.yml index b998a8ed3e..5a98599a52 100644 --- a/.forgejo/workflows/e2e.yml +++ b/.forgejo/workflows/e2e.yml @@ -19,7 +19,7 @@ jobs: - uses: https://code.forgejo.org/actions/checkout@v4 - uses: https://code.forgejo.org/actions/setup-go@v4 with: - go-version: "1.22" + go-version: "1.23" check-latest: true - run: | apt-get -qq update diff --git a/.forgejo/workflows/testing.yml b/.forgejo/workflows/testing.yml index 82a947dd80..bd380da92a 100644 --- a/.forgejo/workflows/testing.yml +++ b/.forgejo/workflows/testing.yml @@ -22,7 +22,7 @@ jobs: - uses: https://code.forgejo.org/actions/checkout@v3 - uses: https://code.forgejo.org/actions/setup-go@v4 with: - go-version: "1.22" + go-version: "1.23" check-latest: true - run: make deps-backend deps-tools - run: make --always-make -j$(nproc) lint-backend checks-backend # ensure the "go-licenses" make target runs @@ -57,7 +57,7 @@ jobs: - uses: https://code.forgejo.org/actions/checkout@v3 - uses: https://code.forgejo.org/actions/setup-go@v4 with: - go-version: "1.22" + go-version: "1.23" - run: | git config --add safe.directory '*' adduser --quiet --comment forgejo --disabled-password forgejo @@ -102,7 +102,7 @@ jobs: - uses: https://code.forgejo.org/actions/checkout@v3 - uses: https://code.forgejo.org/actions/setup-go@v4 with: - go-version: "1.22" + go-version: "1.23" - name: install dependencies & git >= 2.42 run: | export DEBIAN_FRONTEND=noninteractive @@ -149,7 +149,7 @@ jobs: - uses: https://code.forgejo.org/actions/checkout@v3 - uses: https://code.forgejo.org/actions/setup-go@v4 with: - go-version: "1.22" + go-version: "1.23" - name: install dependencies & git >= 2.42 run: | export DEBIAN_FRONTEND=noninteractive @@ -186,7 +186,7 @@ jobs: - uses: https://code.forgejo.org/actions/checkout@v3 - uses: https://code.forgejo.org/actions/setup-go@v4 with: - go-version: "1.22" + go-version: "1.23" - name: install dependencies & git >= 2.42 run: | export DEBIAN_FRONTEND=noninteractive diff --git a/Dockerfile b/Dockerfile index 3c455a5411..47a946a7fe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM --platform=$BUILDPLATFORM docker.io/tonistiigi/xx AS xx -FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.22-alpine3.19 as build-env +FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.23-alpine3.19 as build-env ARG GOPROXY ENV GOPROXY ${GOPROXY:-direct} diff --git a/Dockerfile.rootless b/Dockerfile.rootless index 57db9d4adc..b85b049154 100644 --- a/Dockerfile.rootless +++ b/Dockerfile.rootless @@ -1,6 +1,6 @@ FROM --platform=$BUILDPLATFORM docker.io/tonistiigi/xx AS xx -FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.22-alpine3.19 as build-env +FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.23-alpine3.19 as build-env ARG GOPROXY ENV GOPROXY ${GOPROXY:-direct} diff --git a/Makefile b/Makefile index e3c2354c8a..5496dddb09 100644 --- a/Makefile +++ b/Makefile @@ -29,15 +29,15 @@ XGO_VERSION := go-1.21.x AIR_PACKAGE ?= github.com/cosmtrek/air@v1.49.0 EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v2/cmd/editorconfig-checker@2.8.0 GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.6.0 -GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.1 +GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.2 GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.11 MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.4.1 SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.30.6-0.20240201115257-bcc7c78b7786 XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1.6.0 -GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1.0.3 +GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1 ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/actionlint@v1.6.26 -DEADCODE_PACKAGE ?= golang.org/x/tools/internal/cmd/deadcode@v0.14.0 +DEADCODE_PACKAGE ?= golang.org/x/tools/cmd/deadcode@v0.30.0 DOCKER_IMAGE ?= gitea/gitea DOCKER_TAG ?= latest @@ -434,17 +434,19 @@ lint-spell: lint-spell-fix: @go run $(MISSPELL_PACKAGE) -w $(SPELLCHECK_FILES) +RUN_DEADCODE = $(GO) run $(DEADCODE_PACKAGE) -generated=false -f='{{println .Path}}{{range .Funcs}}{{printf "\t%s\n" .Name}}{{end}}{{println}}' -test code.gitea.io/gitea + .PHONY: lint-go lint-go: $(GO) run $(GOLANGCI_LINT_PACKAGE) run $(GOLANGCI_LINT_ARGS) - $(GO) run $(DEADCODE_PACKAGE) -generated=false -test code.gitea.io/gitea > .cur-deadcode-out + $(RUN_DEADCODE) > .cur-deadcode-out @$(DIFF) .deadcode-out .cur-deadcode-out \ || (code=$$?; echo "Please run 'make lint-go-fix' and commit the result"; exit $${code}) .PHONY: lint-go-fix lint-go-fix: $(GO) run $(GOLANGCI_LINT_PACKAGE) run $(GOLANGCI_LINT_ARGS) --fix - $(GO) run $(DEADCODE_PACKAGE) -generated=false -test code.gitea.io/gitea > .deadcode-out + $(RUN_DEADCODE) > .deadcode-out # workaround step for the lint-go-windows CI task because 'go run' can not # have distinct GOOS/GOARCH for its build and run steps diff --git a/cmd/hook.go b/cmd/hook.go index b62d8d08cb..d51afe8d56 100644 --- a/cmd/hook.go +++ b/cmd/hook.go @@ -549,14 +549,14 @@ Forgejo or set your environment appropriately.`, "") index := bytes.IndexByte(rs.Data, byte(0)) if index >= len(rs.Data) { - return fail(ctx, "Protocol: format error", "pkt-line: format error "+fmt.Sprint(rs.Data)) + return fail(ctx, "Protocol: format error", "pkt-line: format error %s", rs.Data) } if index < 0 { if len(rs.Data) == 10 && rs.Data[9] == '\n' { index = 9 } else { - return fail(ctx, "Protocol: format error", "pkt-line: format error "+fmt.Sprint(rs.Data)) + return fail(ctx, "Protocol: format error", "pkt-line: format error %s", rs.Data) } } diff --git a/cmd/hook_test.go b/cmd/hook_test.go index 077fc0ea0e..06de889531 100644 --- a/cmd/hook_test.go +++ b/cmd/hook_test.go @@ -118,7 +118,7 @@ func TestDelayWriter(t *testing.T) { defer test.MockVariableValue(&setting.InternalToken, "Random")() defer test.MockVariableValue(&setting.InstallLock, true)() defer test.MockVariableValue(&setting.Git.VerbosePush, true)() - require.NoError(t, os.Setenv("SSH_ORIGINAL_COMMAND", "true")) + t.Setenv("SSH_ORIGINAL_COMMAND", "true") // Setup the Stdin. f, err := os.OpenFile(t.TempDir()+"/stdin", os.O_RDWR|os.O_CREATE|os.O_EXCL, 0o666) @@ -165,11 +165,11 @@ func TestDelayWriter(t *testing.T) { } func TestPushOptions(t *testing.T) { - require.NoError(t, os.Setenv(private.GitPushOptionCount, "3")) - require.NoError(t, os.Setenv("GIT_PUSH_OPTION_0", "force-push")) - require.NoError(t, os.Setenv("GIT_PUSH_OPTION_1", "option=value")) - require.NoError(t, os.Setenv("GIT_PUSH_OPTION_2", "option-double=another=value")) - require.NoError(t, os.Setenv("GIT_PUSH_OPTION_3", "not=valid")) + t.Setenv(private.GitPushOptionCount, "3") + t.Setenv("GIT_PUSH_OPTION_0", "force-push") + t.Setenv("GIT_PUSH_OPTION_1", "option=value") + t.Setenv("GIT_PUSH_OPTION_2", "option-double=another=value") + t.Setenv("GIT_PUSH_OPTION_3", "not=valid") assert.Equal(t, map[string]string{ "force-push": "true", diff --git a/go.mod b/go.mod index a38ecb8ce2..ea8780ee21 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,8 @@ module code.gitea.io/gitea -go 1.22.7 +go 1.23.0 + +toolchain go1.23.6 require ( code.forgejo.org/forgejo/reply v1.0.1 @@ -100,12 +102,12 @@ require ( github.com/yuin/goldmark v1.6.0 github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc github.com/yuin/goldmark-meta v1.1.0 - golang.org/x/crypto v0.31.0 + golang.org/x/crypto v0.35.0 golang.org/x/image v0.18.0 golang.org/x/net v0.33.0 golang.org/x/oauth2 v0.16.0 - golang.org/x/sys v0.28.0 - golang.org/x/text v0.21.0 + golang.org/x/sys v0.30.0 + golang.org/x/text v0.22.0 golang.org/x/tools v0.23.0 google.golang.org/grpc v1.60.1 google.golang.org/protobuf v1.33.0 @@ -285,7 +287,7 @@ require ( go.uber.org/zap v1.26.0 // indirect golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect golang.org/x/mod v0.19.0 // indirect - golang.org/x/sync v0.10.0 // indirect + golang.org/x/sync v0.11.0 // indirect golang.org/x/time v0.5.0 // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac // indirect diff --git a/go.sum b/go.sum index da656d4de9..12273c7261 100644 --- a/go.sum +++ b/go.sum @@ -892,8 +892,8 @@ golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= -golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= -golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= +golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs= +golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -995,8 +995,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= -golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= +golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1051,8 +1051,8 @@ golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= +golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1062,8 +1062,8 @@ golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= -golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= -golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= +golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU= +golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1077,8 +1077,8 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= -golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= +golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= +golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/models/activities/user_heatmap_test.go b/models/activities/user_heatmap_test.go index 7063da8bd1..68451224e8 100644 --- a/models/activities/user_heatmap_test.go +++ b/models/activities/user_heatmap_test.go @@ -4,7 +4,6 @@ package activities_test import ( - "fmt" "testing" "time" @@ -92,11 +91,11 @@ func TestGetUserHeatmapDataByUser(t *testing.T) { require.NoError(t, err) assert.Len(t, actions, contributions, "invalid action count: did the test data became too old?") assert.Equal(t, count, int64(contributions)) - assert.Equal(t, tc.CountResult, contributions, fmt.Sprintf("testcase '%s'", tc.desc)) + assert.Equal(t, tc.CountResult, contributions, "testcase '%s'", tc.desc) // Test JSON rendering jsonData, err := json.Marshal(heatmap) require.NoError(t, err) - assert.Equal(t, tc.JSONResult, string(jsonData)) + assert.JSONEq(t, tc.JSONResult, string(jsonData)) } } diff --git a/models/asymkey/gpg_key_common.go b/models/asymkey/gpg_key_common.go index 9c015582f1..28cb8f4e76 100644 --- a/models/asymkey/gpg_key_common.go +++ b/models/asymkey/gpg_key_common.go @@ -114,7 +114,7 @@ func readArmoredSign(r io.Reader) (body io.Reader, err error) { return nil, err } if block.Type != openpgp.SignatureType { - return nil, fmt.Errorf("expected '" + openpgp.SignatureType + "', got: " + block.Type) + return nil, fmt.Errorf("expected '%s', got: %s", openpgp.SignatureType, block.Type) } return block.Body, nil } @@ -139,7 +139,7 @@ func tryGetKeyIDFromSignature(sig *packet.Signature) string { if sig.IssuerKeyId != nil && (*sig.IssuerKeyId) != 0 { return fmt.Sprintf("%016X", *sig.IssuerKeyId) } - if sig.IssuerFingerprint != nil && len(sig.IssuerFingerprint) > 0 { + if len(sig.IssuerFingerprint) > 0 { return fmt.Sprintf("%016X", sig.IssuerFingerprint[12:20]) } return "" diff --git a/models/auth/oauth2_test.go b/models/auth/oauth2_test.go index 3ed78ae36d..acea9c1c6f 100644 --- a/models/auth/oauth2_test.go +++ b/models/auth/oauth2_test.go @@ -22,7 +22,7 @@ func TestOAuth2Application_GenerateClientSecret(t *testing.T) { app := unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{ID: 1}) secret, err := app.GenerateClientSecret(db.DefaultContext) require.NoError(t, err) - assert.Positive(t, len(secret)) + assert.NotEmpty(t, secret) unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{ID: 1, ClientSecret: app.ClientSecret}) } diff --git a/models/git/protected_branch_test.go b/models/git/protected_branch_test.go index 1962859a8c..4e6ac9f29b 100644 --- a/models/git/protected_branch_test.go +++ b/models/git/protected_branch_test.go @@ -4,7 +4,6 @@ package git import ( - "fmt" "testing" "github.com/stretchr/testify/assert" @@ -72,7 +71,7 @@ func TestBranchRuleMatch(t *testing.T) { infact = " not" } assert.EqualValues(t, kase.ExpectedMatch, pb.Match(kase.BranchName), - fmt.Sprintf("%s should%s match %s but it is%s", kase.BranchName, should, kase.Rule, infact), + "%s should%s match %s but it is%s", kase.BranchName, should, kase.Rule, infact, ) } } diff --git a/models/migrations/v1_16/v189.go b/models/migrations/v1_16/v189.go index afd93b0eac..5649645051 100644 --- a/models/migrations/v1_16/v189.go +++ b/models/migrations/v1_16/v189.go @@ -83,7 +83,7 @@ func UnwrapLDAPSourceCfg(x *xorm.Engine) error { if err != nil { return fmt.Errorf("failed to unmarshal %s: %w", source.Cfg, err) } - if wrapped.Source != nil && len(wrapped.Source) > 0 { + if len(wrapped.Source) > 0 { bs, err := json.Marshal(wrapped.Source) if err != nil { return err diff --git a/models/migrations/v1_16/v193_test.go b/models/migrations/v1_16/v193_test.go index 1cfa7fbaeb..4905e5f543 100644 --- a/models/migrations/v1_16/v193_test.go +++ b/models/migrations/v1_16/v193_test.go @@ -57,8 +57,8 @@ func Test_AddRepoIDForAttachment(t *testing.T) { err := x.Table("attachment").Where("issue_id > 0").Find(&issueAttachments) require.NoError(t, err) for _, attach := range issueAttachments { - assert.Greater(t, attach.RepoID, int64(0)) - assert.Greater(t, attach.IssueID, int64(0)) + assert.Positive(t, attach.RepoID) + assert.Positive(t, attach.IssueID) var issue Issue has, err := x.ID(attach.IssueID).Get(&issue) require.NoError(t, err) @@ -70,8 +70,8 @@ func Test_AddRepoIDForAttachment(t *testing.T) { err = x.Table("attachment").Where("release_id > 0").Find(&releaseAttachments) require.NoError(t, err) for _, attach := range releaseAttachments { - assert.Greater(t, attach.RepoID, int64(0)) - assert.Greater(t, attach.ReleaseID, int64(0)) + assert.Positive(t, attach.RepoID) + assert.Positive(t, attach.ReleaseID) var release Release has, err := x.ID(attach.ReleaseID).Get(&release) require.NoError(t, err) diff --git a/models/project/board_test.go b/models/project/board_test.go index f2a2ae8c9f..d2e5bb97a5 100644 --- a/models/project/board_test.go +++ b/models/project/board_test.go @@ -5,7 +5,6 @@ package project import ( "fmt" - "strings" "testing" "code.gitea.io/gitea/models/db" @@ -124,5 +123,5 @@ func Test_NewBoard(t *testing.T) { ProjectID: project1.ID, }) require.Error(t, err) - assert.True(t, strings.Contains(err.Error(), "maximum number of columns reached")) + assert.ErrorContains(t, err, "maximum number of columns reached") } diff --git a/models/repo/repo_list.go b/models/repo/repo_list.go index 9644cbd70c..b88e219edd 100644 --- a/models/repo/repo_list.go +++ b/models/repo/repo_list.go @@ -764,7 +764,7 @@ func GetUserRepositories(ctx context.Context, opts *SearchRepoOptions) (Reposito cond = cond.And(builder.Eq{"is_private": false}) } - if opts.LowerNames != nil && len(opts.LowerNames) > 0 { + if len(opts.LowerNames) > 0 { cond = cond.And(builder.In("lower_name", opts.LowerNames)) } diff --git a/models/user/user_test.go b/models/user/user_test.go index 1359e9e218..535e930654 100644 --- a/models/user/user_test.go +++ b/models/user/user_test.go @@ -510,7 +510,7 @@ func Test_ValidateUser(t *testing.T) { {ID: 2, Visibility: structs.VisibleTypePrivate}: true, } for kase, expected := range kases { - assert.EqualValues(t, expected, nil == user_model.ValidateUser(kase), fmt.Sprintf("case: %+v", kase)) + assert.EqualValues(t, expected, nil == user_model.ValidateUser(kase), "case: %+v", kase) } } diff --git a/modules/activitypub/client_test.go b/modules/activitypub/client_test.go index e7b4a5d095..0ea7b4d2d6 100644 --- a/modules/activitypub/client_test.go +++ b/modules/activitypub/client_test.go @@ -8,7 +8,6 @@ import ( "io" "net/http" "net/http/httptest" - "regexp" "testing" "code.gitea.io/gitea/models/db" @@ -29,7 +28,7 @@ func TestActivityPubSignedPost(t *testing.T) { expected := "BODY" srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - assert.Regexp(t, regexp.MustCompile("^"+setting.Federation.DigestAlgorithm), r.Header.Get("Digest")) + assert.Regexp(t, "^"+setting.Federation.DigestAlgorithm, r.Header.Get("Digest")) assert.Contains(t, r.Header.Get("Signature"), pubID) assert.Equal(t, ActivityStreamsContentType, r.Header.Get("Content-Type")) body, err := io.ReadAll(r.Body) diff --git a/modules/cache/context.go b/modules/cache/context.go index 62bbf5dcba..5f0ca81e8d 100644 --- a/modules/cache/context.go +++ b/modules/cache/context.go @@ -73,7 +73,9 @@ func (cc *cacheContext) Expired() bool { return timeNow().Sub(cc.created) > cacheContextLifetime } -var cacheContextKey = struct{}{} +type cacheContextType = struct{ useless struct{} } + +var cacheContextKey = cacheContextType{useless: struct{}{}} /* Since there are both WithCacheContext and WithNoCacheContext, diff --git a/modules/git/log_name_status.go b/modules/git/log_name_status.go index 9e345f3ee0..1fd58abfcd 100644 --- a/modules/git/log_name_status.go +++ b/modules/git/log_name_status.go @@ -114,7 +114,7 @@ type LogNameStatusCommitData struct { // Next returns the next LogStatusCommitData func (g *LogNameStatusRepoParser) Next(treepath string, paths2ids map[string]int, changed []bool, maxpathlen int) (*LogNameStatusCommitData, error) { var err error - if g.next == nil || len(g.next) == 0 { + if len(g.next) == 0 { g.buffull = false g.next, err = g.rd.ReadSlice('\x00') if err != nil { diff --git a/modules/issue/template/template.go b/modules/issue/template/template.go index 3be48b9edc..773d1bcf18 100644 --- a/modules/issue/template/template.go +++ b/modules/issue/template/template.go @@ -367,7 +367,7 @@ func (f *valuedField) Render() string { } func (f *valuedField) Value() string { - return strings.TrimSpace(f.Get(fmt.Sprintf("form-field-" + f.ID))) + return strings.TrimSpace(f.Get("form-field-" + f.ID)) } func (f *valuedField) Options() []*valuedOption { diff --git a/modules/lfs/http_client_test.go b/modules/lfs/http_client_test.go index 4cdbef3fca..9ead5955ae 100644 --- a/modules/lfs/http_client_test.go +++ b/modules/lfs/http_client_test.go @@ -251,7 +251,7 @@ func TestHTTPClientDownload(t *testing.T) { return nil }) if len(c.expectederror) > 0 { - assert.True(t, strings.Contains(err.Error(), c.expectederror), "case %d: '%s' should contain '%s'", n, err.Error(), c.expectederror) + assert.ErrorContains(t, err, c.expectederror) } else { require.NoError(t, err, "case %d", n) } @@ -353,7 +353,7 @@ func TestHTTPClientUpload(t *testing.T) { return io.NopCloser(new(bytes.Buffer)), objectError }) if len(c.expectederror) > 0 { - assert.True(t, strings.Contains(err.Error(), c.expectederror), "case %d: '%s' should contain '%s'", n, err.Error(), c.expectederror) + assert.ErrorContains(t, err, c.expectederror) } else { require.NoError(t, err, "case %d", n) } diff --git a/modules/lfs/transferadapter_test.go b/modules/lfs/transferadapter_test.go index 0766e4a0a9..447d9a8ebf 100644 --- a/modules/lfs/transferadapter_test.go +++ b/modules/lfs/transferadapter_test.go @@ -97,7 +97,7 @@ func TestBasicTransferAdapter(t *testing.T) { for n, c := range cases { _, err := a.Download(context.Background(), c.link) if len(c.expectederror) > 0 { - assert.True(t, strings.Contains(err.Error(), c.expectederror), "case %d: '%s' should contain '%s'", n, err.Error(), c.expectederror) + assert.ErrorContains(t, err, c.expectederror) } else { require.NoError(t, err, "case %d", n) } @@ -130,7 +130,7 @@ func TestBasicTransferAdapter(t *testing.T) { for n, c := range cases { err := a.Upload(context.Background(), c.link, p, bytes.NewBufferString("dummy")) if len(c.expectederror) > 0 { - assert.True(t, strings.Contains(err.Error(), c.expectederror), "case %d: '%s' should contain '%s'", n, err.Error(), c.expectederror) + assert.ErrorContains(t, err, c.expectederror) } else { require.NoError(t, err, "case %d", n) } @@ -163,7 +163,7 @@ func TestBasicTransferAdapter(t *testing.T) { for n, c := range cases { err := a.Verify(context.Background(), c.link, p) if len(c.expectederror) > 0 { - assert.True(t, strings.Contains(err.Error(), c.expectederror), "case %d: '%s' should contain '%s'", n, err.Error(), c.expectederror) + assert.ErrorContains(t, err, c.expectederror) } else { require.NoError(t, err, "case %d", n) } diff --git a/modules/queue/base_channel.go b/modules/queue/base_channel.go index d03c72bdae..dd8ccb15f4 100644 --- a/modules/queue/base_channel.go +++ b/modules/queue/base_channel.go @@ -120,7 +120,7 @@ func (q *baseChannel) RemoveAll(ctx context.Context) error { q.mu.Lock() defer q.mu.Unlock() - for q.c != nil && len(q.c) > 0 { + for len(q.c) > 0 { <-q.c } diff --git a/modules/queue/workerqueue_test.go b/modules/queue/workerqueue_test.go index 112a16c8e3..4cfe8ede97 100644 --- a/modules/queue/workerqueue_test.go +++ b/modules/queue/workerqueue_test.go @@ -173,8 +173,8 @@ func testWorkerPoolQueuePersistence(t *testing.T, queueSetting setting.QueueSett q2() // restart the queue to continue to execute the tasks in it - assert.NotZero(t, len(tasksQ1)) - assert.NotZero(t, len(tasksQ2)) + assert.NotEmpty(t, tasksQ1) + assert.NotEmpty(t, tasksQ2) assert.EqualValues(t, testCount, len(tasksQ1)+len(tasksQ2)) } diff --git a/modules/setting/storage_test.go b/modules/setting/storage_test.go index 271607914c..59135b5911 100644 --- a/modules/setting/storage_test.go +++ b/modules/setting/storage_test.go @@ -445,7 +445,7 @@ MINIO_BASE_PATH = /lfs require.NoError(t, loadLFSFrom(cfg)) assert.EqualValues(t, "my_access_key", LFS.Storage.MinioConfig.AccessKeyID) assert.EqualValues(t, "my_secret_key", LFS.Storage.MinioConfig.SecretAccessKey) - assert.True(t, true, LFS.Storage.MinioConfig.UseSSL) + assert.True(t, LFS.Storage.MinioConfig.UseSSL) assert.EqualValues(t, "/lfs", LFS.Storage.MinioConfig.BasePath) cfg, err = NewConfigProviderFromData(` diff --git a/modules/util/keypair_test.go b/modules/util/keypair_test.go index ec9bca7efa..6c05db779a 100644 --- a/modules/util/keypair_test.go +++ b/modules/util/keypair_test.go @@ -10,7 +10,6 @@ import ( "crypto/sha256" "crypto/x509" "encoding/pem" - "regexp" "testing" "github.com/stretchr/testify/assert" @@ -24,8 +23,8 @@ func TestKeygen(t *testing.T) { assert.NotEmpty(t, priv) assert.NotEmpty(t, pub) - assert.Regexp(t, regexp.MustCompile("^-----BEGIN RSA PRIVATE KEY-----.*"), priv) - assert.Regexp(t, regexp.MustCompile("^-----BEGIN PUBLIC KEY-----.*"), pub) + assert.Regexp(t, "^-----BEGIN RSA PRIVATE KEY-----.*", priv) + assert.Regexp(t, "^-----BEGIN PUBLIC KEY-----.*", pub) } func TestSignUsingKeys(t *testing.T) { diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index ba5ee9617e..c027250038 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -730,7 +730,7 @@ func EditPullRequest(ctx *context.APIContext) { // update allow edits if form.AllowMaintainerEdit != nil { if err := pull_service.SetAllowEdits(ctx, ctx.Doer, pr, *form.AllowMaintainerEdit); err != nil { - if errors.Is(pull_service.ErrUserHasNoPermissionForAction, err) { + if errors.Is(err, pull_service.ErrUserHasNoPermissionForAction) { ctx.Error(http.StatusForbidden, "SetAllowEdits", fmt.Sprintf("SetAllowEdits: %s", err)) return } diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index 8f025ad90d..aa3cbe0ed7 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -1813,7 +1813,7 @@ func SetAllowEdits(ctx *context.Context) { } if err := pull_service.SetAllowEdits(ctx, ctx.Doer, pr, form.AllowMaintainerEdit); err != nil { - if errors.Is(pull_service.ErrUserHasNoPermissionForAction, err) { + if errors.Is(err, pull_service.ErrUserHasNoPermissionForAction) { ctx.Error(http.StatusForbidden) return } diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index 48a84bf432..e74c922530 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -8,6 +8,7 @@ import ( "bytes" gocontext "context" "encoding/base64" + "errors" "fmt" "html/template" "image" @@ -748,7 +749,7 @@ func checkHomeCodeViewable(ctx *context.Context) { } } - ctx.NotFound("Home", fmt.Errorf(ctx.Locale.TrString("units.error.no_unit_allowed_repo"))) + ctx.NotFound("Home", errors.New(ctx.Locale.TrString("units.error.no_unit_allowed_repo"))) } func checkCitationFile(ctx *context.Context, entry *git.TreeEntry) { diff --git a/routers/web/user/home.go b/routers/web/user/home.go index 52aca1825a..d55ac3c09f 100644 --- a/routers/web/user/home.go +++ b/routers/web/user/home.go @@ -6,6 +6,7 @@ package user import ( "bytes" + "errors" "fmt" "net/http" "regexp" @@ -747,7 +748,7 @@ func UsernameSubRoute(ctx *context.Context) { } // check view permissions if !user_model.IsUserVisibleToViewer(ctx, ctx.ContextUser, ctx.Doer) { - ctx.NotFound("user", fmt.Errorf(ctx.ContextUser.Name)) + ctx.NotFound("user", errors.New(ctx.ContextUser.Name)) return false } return true diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go index 2e4b9dae65..c2c5b59247 100644 --- a/routers/web/user/profile.go +++ b/routers/web/user/profile.go @@ -56,7 +56,7 @@ func OwnerProfile(ctx *context.Context) { func userProfile(ctx *context.Context) { // check view permissions if !user_model.IsUserVisibleToViewer(ctx, ctx.ContextUser, ctx.Doer) { - ctx.NotFound("user", fmt.Errorf(ctx.ContextUser.Name)) + ctx.NotFound("user", errors.New(ctx.ContextUser.Name)) return } diff --git a/services/actions/notifier_helper.go b/services/actions/notifier_helper.go index 365212d9c2..10de78e85b 100644 --- a/services/actions/notifier_helper.go +++ b/services/actions/notifier_helper.go @@ -34,7 +34,9 @@ import ( "github.com/nektos/act/pkg/model" ) -var methodCtxKey struct{} +type methodCtx struct{} + +var methodCtxKey = methodCtx{} // withMethod sets the notification method that this context currently executes. // Used for debugging/ troubleshooting purposes. diff --git a/services/automerge/automerge.go b/services/automerge/automerge.go index bd427bef9f..4347e42d2b 100644 --- a/services/automerge/automerge.go +++ b/services/automerge/automerge.go @@ -230,7 +230,7 @@ func handlePull(pullID int64, sha string) { } if err := pull_service.CheckPullMergable(ctx, doer, &perm, pr, pull_service.MergeCheckTypeGeneral, false); err != nil { - if errors.Is(pull_service.ErrUserNotAllowedToMerge, err) { + if errors.Is(err, pull_service.ErrUserNotAllowedToMerge) { log.Info("%-v was scheduled to automerge by an unauthorized user", pr) return } diff --git a/services/gitdiff/gitdiff.go b/services/gitdiff/gitdiff.go index 0c89839edf..a3dbc2d545 100644 --- a/services/gitdiff/gitdiff.go +++ b/services/gitdiff/gitdiff.go @@ -1058,7 +1058,7 @@ func readFileName(rd *strings.Reader) (string, bool) { char, _ := rd.ReadByte() _ = rd.UnreadByte() if char == '"' { - fmt.Fscanf(rd, "%q ", &name) + _, _ = fmt.Fscanf(rd, "%q ", &name) if len(name) == 0 { log.Error("Reader has no file name: reader=%+v", rd) return "", true @@ -1070,12 +1070,12 @@ func readFileName(rd *strings.Reader) (string, bool) { } else { // This technique is potentially ambiguous it may not be possible to uniquely identify the filenames from the diff line alone ambiguity = true - fmt.Fscanf(rd, "%s ", &name) + _, _ = fmt.Fscanf(rd, "%s ", &name) char, _ := rd.ReadByte() _ = rd.UnreadByte() for !(char == 0 || char == '"' || char == 'b') { var suffix string - fmt.Fscanf(rd, "%s ", &suffix) + _, _ = fmt.Fscanf(rd, "%s ", &suffix) name += " " + suffix char, _ = rd.ReadByte() _ = rd.UnreadByte() diff --git a/services/gitdiff/gitdiff_test.go b/services/gitdiff/gitdiff_test.go index 40285f8119..f2c099d554 100644 --- a/services/gitdiff/gitdiff_test.go +++ b/services/gitdiff/gitdiff_test.go @@ -5,7 +5,6 @@ package gitdiff import ( - "fmt" "strconv" "strings" "testing" @@ -645,9 +644,9 @@ func TestGetDiffRangeWithWhitespaceBehavior(t *testing.T) { MaxFiles: setting.Git.MaxGitDiffFiles, WhitespaceBehavior: behavior, }) - require.NoError(t, err, fmt.Sprintf("Error when diff with %s", behavior)) + require.NoError(t, err, "Error when diff with %s", behavior) for _, f := range diffs.Files { - assert.Positive(t, len(f.Sections), fmt.Sprintf("%s should have sections", f.Name)) + assert.NotEmpty(t, f.Sections, "%s should have sections", f.Name) } } } diff --git a/services/release/release_test.go b/services/release/release_test.go index aa22cbbd7b..c96fd62a04 100644 --- a/services/release/release_test.go +++ b/services/release/release_test.go @@ -229,7 +229,7 @@ func TestRelease_Update(t *testing.T) { IsTag: false, } require.NoError(t, CreateRelease(gitRepo, release, nil, "")) - assert.Greater(t, release.ID, int64(0)) + assert.Positive(t, release.ID) release.IsDraft = false tagName := release.TagName diff --git a/services/repository/contributors_graph_test.go b/services/repository/contributors_graph_test.go index 72b267b015..d20a3e0e37 100644 --- a/services/repository/contributors_graph_test.go +++ b/services/repository/contributors_graph_test.go @@ -37,7 +37,7 @@ func TestRepository_ContributorsGraph(t *testing.T) { dataString, isData := mockCache.Get("key2").(string) assert.True(t, isData) // Verify that JSON is actually stored in the cache. - assert.EqualValues(t, `{"ethantkoenig@gmail.com":{"name":"Ethan Koenig","login":"","avatar_link":"https://secure.gravatar.com/avatar/b42fb195faa8c61b8d88abfefe30e9e3?d=identicon","home_link":"","total_commits":1,"weeks":{"1511654400000":{"week":1511654400000,"additions":3,"deletions":0,"commits":1}}},"jimmy.praet@telenet.be":{"name":"Jimmy Praet","login":"","avatar_link":"https://secure.gravatar.com/avatar/93c49b7c89eb156971d11161c9b52795?d=identicon","home_link":"","total_commits":1,"weeks":{"1624752000000":{"week":1624752000000,"additions":2,"deletions":0,"commits":1}}},"jon@allspice.io":{"name":"Jon","login":"","avatar_link":"https://secure.gravatar.com/avatar/00388ce725e6886f3e07c3733007289b?d=identicon","home_link":"","total_commits":1,"weeks":{"1607817600000":{"week":1607817600000,"additions":10,"deletions":0,"commits":1}}},"total":{"name":"Total","login":"","avatar_link":"","home_link":"","total_commits":3,"weeks":{"1511654400000":{"week":1511654400000,"additions":3,"deletions":0,"commits":1},"1607817600000":{"week":1607817600000,"additions":10,"deletions":0,"commits":1},"1624752000000":{"week":1624752000000,"additions":2,"deletions":0,"commits":1}}}}`, dataString) + assert.JSONEq(t, `{"ethantkoenig@gmail.com":{"name":"Ethan Koenig","login":"","avatar_link":"https://secure.gravatar.com/avatar/b42fb195faa8c61b8d88abfefe30e9e3?d=identicon","home_link":"","total_commits":1,"weeks":{"1511654400000":{"week":1511654400000,"additions":3,"deletions":0,"commits":1}}},"jimmy.praet@telenet.be":{"name":"Jimmy Praet","login":"","avatar_link":"https://secure.gravatar.com/avatar/93c49b7c89eb156971d11161c9b52795?d=identicon","home_link":"","total_commits":1,"weeks":{"1624752000000":{"week":1624752000000,"additions":2,"deletions":0,"commits":1}}},"jon@allspice.io":{"name":"Jon","login":"","avatar_link":"https://secure.gravatar.com/avatar/00388ce725e6886f3e07c3733007289b?d=identicon","home_link":"","total_commits":1,"weeks":{"1607817600000":{"week":1607817600000,"additions":10,"deletions":0,"commits":1}}},"total":{"name":"Total","login":"","avatar_link":"","home_link":"","total_commits":3,"weeks":{"1511654400000":{"week":1511654400000,"additions":3,"deletions":0,"commits":1},"1607817600000":{"week":1607817600000,"additions":10,"deletions":0,"commits":1},"1624752000000":{"week":1624752000000,"additions":2,"deletions":0,"commits":1}}}}`, dataString) var data map[string]*ContributorData require.NoError(t, json.Unmarshal([]byte(dataString), &data)) diff --git a/tests/integration/api_issue_stopwatch_test.go b/tests/integration/api_issue_stopwatch_test.go index 2306678217..4765787e6f 100644 --- a/tests/integration/api_issue_stopwatch_test.go +++ b/tests/integration/api_issue_stopwatch_test.go @@ -40,7 +40,7 @@ func TestAPIListStopWatches(t *testing.T) { assert.EqualValues(t, issue.Title, apiWatches[0].IssueTitle) assert.EqualValues(t, repo.Name, apiWatches[0].RepoName) assert.EqualValues(t, repo.OwnerName, apiWatches[0].RepoOwnerName) - assert.Greater(t, apiWatches[0].Seconds, int64(0)) + assert.Positive(t, apiWatches[0].Seconds) } } diff --git a/tests/integration/api_notification_test.go b/tests/integration/api_notification_test.go index 53a15c848b..a24635ea73 100644 --- a/tests/integration/api_notification_test.go +++ b/tests/integration/api_notification_test.go @@ -121,7 +121,7 @@ func TestAPINotification(t *testing.T) { AddTokenAuth(token) resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &new) - assert.Greater(t, new.New, int64(0)) + assert.Positive(t, new.New) // -- mark notifications as read -- req = NewRequest(t, "GET", "/api/v1/notifications?status-types=unread"). diff --git a/tests/integration/api_push_mirror_test.go b/tests/integration/api_push_mirror_test.go index f0ef670757..c4ed9e476e 100644 --- a/tests/integration/api_push_mirror_test.go +++ b/tests/integration/api_push_mirror_test.go @@ -5,6 +5,7 @@ package integration import ( "context" + "errors" "fmt" "net/http" "net/url" @@ -54,13 +55,13 @@ func testAPIPushMirror(t *testing.T, u *url.URL) { deletePushMirrors := repo_model.DeletePushMirrors deletePushMirrorsError := "deletePushMirrorsError" deletePushMirrorsFail := func(ctx context.Context, opts repo_model.PushMirrorOptions) error { - return fmt.Errorf(deletePushMirrorsError) + return errors.New(deletePushMirrorsError) } addPushMirrorRemote := mirror_service.AddPushMirrorRemote addPushMirrorRemoteError := "addPushMirrorRemoteError" addPushMirrorRemoteFail := func(ctx context.Context, m *repo_model.PushMirror, addr string) error { - return fmt.Errorf(addPushMirrorRemoteError) + return errors.New(addPushMirrorRemoteError) } for _, testCase := range []struct { diff --git a/tests/integration/api_releases_test.go b/tests/integration/api_releases_test.go index 4d550c8bee..985a849bda 100644 --- a/tests/integration/api_releases_test.go +++ b/tests/integration/api_releases_test.go @@ -236,17 +236,17 @@ func TestAPIDeleteReleaseByTagName(t *testing.T) { createNewReleaseUsingAPI(t, session, token, owner, repo, "release-tag", "", "Release Tag", "test") // delete release - req := NewRequestf(t, http.MethodDelete, fmt.Sprintf("/api/v1/repos/%s/%s/releases/tags/release-tag", owner.Name, repo.Name)). + req := NewRequestf(t, http.MethodDelete, "/api/v1/repos/%s/%s/releases/tags/release-tag", owner.Name, repo.Name). AddTokenAuth(token) _ = MakeRequest(t, req, http.StatusNoContent) // make sure release is deleted - req = NewRequestf(t, http.MethodDelete, fmt.Sprintf("/api/v1/repos/%s/%s/releases/tags/release-tag", owner.Name, repo.Name)). + req = NewRequestf(t, http.MethodDelete, "/api/v1/repos/%s/%s/releases/tags/release-tag", owner.Name, repo.Name). AddTokenAuth(token) _ = MakeRequest(t, req, http.StatusNotFound) // delete release tag too - req = NewRequestf(t, http.MethodDelete, fmt.Sprintf("/api/v1/repos/%s/%s/tags/release-tag", owner.Name, repo.Name)). + req = NewRequestf(t, http.MethodDelete, "/api/v1/repos/%s/%s/tags/release-tag", owner.Name, repo.Name). AddTokenAuth(token) _ = MakeRequest(t, req, http.StatusNoContent) } diff --git a/tests/integration/api_repo_teams_test.go b/tests/integration/api_repo_teams_test.go index 558bac8150..91bfd66b3a 100644 --- a/tests/integration/api_repo_teams_test.go +++ b/tests/integration/api_repo_teams_test.go @@ -39,7 +39,7 @@ func TestAPIRepoTeams(t *testing.T) { if assert.Len(t, teams, 2) { assert.EqualValues(t, "Owners", teams[0].Name) assert.True(t, teams[0].CanCreateOrgRepo) - assert.True(t, util.SliceSortedEqual(unit.AllUnitKeyNames(), teams[0].Units), fmt.Sprintf("%v == %v", unit.AllUnitKeyNames(), teams[0].Units)) + assert.True(t, util.SliceSortedEqual(unit.AllUnitKeyNames(), teams[0].Units)) assert.EqualValues(t, "owner", teams[0].Permission) assert.EqualValues(t, "test_team", teams[1].Name) diff --git a/tests/integration/compare_test.go b/tests/integration/compare_test.go index 2a454fab71..d74df271d9 100644 --- a/tests/integration/compare_test.go +++ b/tests/integration/compare_test.go @@ -40,7 +40,7 @@ func TestCompareTag(t *testing.T) { req = NewRequest(t, "GET", "/user2/repo1/compare/invalid") resp = session.MakeRequest(t, req, http.StatusNotFound) - assert.False(t, strings.Contains(resp.Body.String(), ">500<"), "expect 404 page not 500") + assert.NotContains(t, resp.Body.String(), ">500<", "expect 404 page not 500") } // Compare with inferred default branch (master) diff --git a/tests/integration/migrate_test.go b/tests/integration/migrate_test.go index 949bcd47bb..ce98259d36 100644 --- a/tests/integration/migrate_test.go +++ b/tests/integration/migrate_test.go @@ -81,7 +81,7 @@ func TestMigrate(t *testing.T) { {svc: structs.ForgejoService}, } { // Step 0: verify the repo is available - req := NewRequestf(t, "GET", fmt.Sprintf("/%s/%s", ownerName, repoName)) + req := NewRequestf(t, "GET", "/%s/%s", ownerName, repoName) _ = session.MakeRequest(t, req, http.StatusOK) // Step 1: get the Gitea migration form req = NewRequestf(t, "GET", "/repo/migrate/?service_type=%d", s.svc) diff --git a/tests/integration/repo_fork_test.go b/tests/integration/repo_fork_test.go index c6984a12fb..0829b7a861 100644 --- a/tests/integration/repo_fork_test.go +++ b/tests/integration/repo_fork_test.go @@ -46,7 +46,7 @@ func testRepoFork(t *testing.T, session *TestSession, ownerName, repoName, forkO link, exists := htmlDoc.doc.Find(fmt.Sprintf("form.ui.form[action=\"%s\"]", forkURL)).Attr("action") assert.True(t, exists, "The template has changed") _, exists = htmlDoc.doc.Find(fmt.Sprintf(".owner.dropdown .item[data-value=\"%d\"]", forkOwner.ID)).Attr("data-value") - assert.True(t, exists, fmt.Sprintf("Fork owner '%s' is not present in select box", forkOwnerName)) + assert.True(t, exists, "Fork owner '%s' is not present in select box", forkOwnerName) req = NewRequestWithValues(t, "POST", link, map[string]string{ "_csrf": htmlDoc.GetCSRF(), "uid": fmt.Sprintf("%d", forkOwner.ID), diff --git a/tests/integration/repo_generate_test.go b/tests/integration/repo_generate_test.go index 961255cedf..ff2aa220d3 100644 --- a/tests/integration/repo_generate_test.go +++ b/tests/integration/repo_generate_test.go @@ -41,7 +41,7 @@ func testRepoGenerate(t *testing.T, session *TestSession, templateID, templateOw link, exists = htmlDoc.doc.Find("form.ui.form[action^=\"/repo/create\"]").Attr("action") assert.True(t, exists, "The template has changed") _, exists = htmlDoc.doc.Find(fmt.Sprintf(".owner.dropdown .item[data-value=\"%d\"]", generateOwner.ID)).Attr("data-value") - assert.True(t, exists, fmt.Sprintf("Generate owner '%s' is not present in select box", generateOwnerName)) + assert.True(t, exists, "Generate owner '%s' is not present in select box", generateOwnerName) req = NewRequestWithValues(t, "POST", link, map[string]string{ "_csrf": htmlDoc.GetCSRF(), "uid": fmt.Sprintf("%d", generateOwner.ID), diff --git a/tests/integration/repo_test.go b/tests/integration/repo_test.go index b38b6811d6..0af0afc07c 100644 --- a/tests/integration/repo_test.go +++ b/tests/integration/repo_test.go @@ -447,7 +447,7 @@ func TestViewRepoDirectory(t *testing.T) { repoSummary := htmlDoc.doc.Find(".repository-summary") repoFilesTable := htmlDoc.doc.Find("#repo-files-table") - assert.NotZero(t, len(repoFilesTable.Nodes)) + assert.NotEmpty(t, repoFilesTable.Nodes) assert.Zero(t, description.Length()) assert.Zero(t, repoTopics.Length()) diff --git a/tests/integration/user_test.go b/tests/integration/user_test.go index 9009f7cf0b..24501ad1ee 100644 --- a/tests/integration/user_test.go +++ b/tests/integration/user_test.go @@ -294,7 +294,7 @@ func TestListStopWatches(t *testing.T) { assert.EqualValues(t, issue.Title, apiWatches[0].IssueTitle) assert.EqualValues(t, repo.Name, apiWatches[0].RepoName) assert.EqualValues(t, repo.OwnerName, apiWatches[0].RepoOwnerName) - assert.Greater(t, apiWatches[0].Seconds, int64(0)) + assert.Positive(t, apiWatches[0].Seconds) } }