1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-08-05 09:55:20 +02:00

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 <postmaster@gusted.xyz>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7081
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Renovate Bot <forgejo-renovate-action@forgejo.org>
Co-committed-by: Renovate Bot <forgejo-renovate-action@forgejo.org>
This commit is contained in:
Renovate Bot 2025-03-04 22:15:29 +00:00 committed by Gusted
parent 957774e5e7
commit 70ccec328d
53 changed files with 389 additions and 381 deletions

View file

@ -1,343 +1,346 @@
package "code.gitea.io/gitea/cmd" code.gitea.io/gitea/cmd
func NoMainListener NoMainListener
package "code.gitea.io/gitea/cmd/forgejo" code.gitea.io/gitea/cmd/forgejo
func ContextSetNoInit ContextSetNoInit
func ContextSetNoExit ContextSetNoExit
func ContextSetStderr ContextSetStderr
func ContextGetStderr ContextGetStderr
func ContextSetStdout ContextSetStdout
func ContextSetStdin ContextSetStdin
package "code.gitea.io/gitea/models" code.gitea.io/gitea/models
func IsErrUpdateTaskNotExist IsErrUpdateTaskNotExist
func (ErrUpdateTaskNotExist).Error ErrUpdateTaskNotExist.Error
func (ErrUpdateTaskNotExist).Unwrap ErrUpdateTaskNotExist.Unwrap
func IsErrSHANotFound IsErrSHANotFound
func IsErrMergeDivergingFastForwardOnly IsErrMergeDivergingFastForwardOnly
func GetYamlFixturesAccess GetYamlFixturesAccess
package "code.gitea.io/gitea/models/actions" code.gitea.io/gitea/models/actions
func (ScheduleList).GetUserIDs ScheduleList.GetUserIDs
func (ScheduleList).GetRepoIDs ScheduleList.GetRepoIDs
func (ScheduleList).LoadTriggerUser ScheduleList.LoadTriggerUser
func (ScheduleList).LoadRepos ScheduleList.LoadRepos
package "code.gitea.io/gitea/models/asymkey" code.gitea.io/gitea/models/asymkey
func (ErrGPGKeyAccessDenied).Error ErrGPGKeyAccessDenied.Error
func (ErrGPGKeyAccessDenied).Unwrap ErrGPGKeyAccessDenied.Unwrap
func HasDeployKey HasDeployKey
package "code.gitea.io/gitea/models/auth" code.gitea.io/gitea/models/auth
func GetSourceByName GetSourceByName
func GetWebAuthnCredentialByID GetWebAuthnCredentialByID
func WebAuthnCredentials WebAuthnCredentials
package "code.gitea.io/gitea/models/db" code.gitea.io/gitea/models/db
func TruncateBeans TruncateBeans
func InTransaction InTransaction
func DumpTables DumpTables
package "code.gitea.io/gitea/models/dbfs" code.gitea.io/gitea/models/dbfs
func (*file).renameTo file.renameTo
func Create Create
func Rename Rename
package "code.gitea.io/gitea/models/forgejo/semver" code.gitea.io/gitea/models/forgejo/semver
func GetVersion GetVersion
func SetVersionString SetVersionString
func SetVersion SetVersion
package "code.gitea.io/gitea/models/git" code.gitea.io/gitea/models/git
func RemoveDeletedBranchByID RemoveDeletedBranchByID
package "code.gitea.io/gitea/models/issues" code.gitea.io/gitea/models/issues
func IsErrUnknownDependencyType IsErrUnknownDependencyType
func (ErrNewIssueInsert).Error ErrNewIssueInsert.Error
func IsErrIssueWasClosed IsErrIssueWasClosed
func ChangeMilestoneStatus ChangeMilestoneStatus
package "code.gitea.io/gitea/models/migrations/base" code.gitea.io/gitea/models/migrations/base
func removeAllWithRetry removeAllWithRetry
func newXORMEngine newXORMEngine
func deleteDB deleteDB
func PrepareTestEnv PrepareTestEnv
func MainTest MainTest
package "code.gitea.io/gitea/models/organization" code.gitea.io/gitea/models/organization
func GetTeamNamesByID GetTeamNamesByID
func UpdateTeamUnits UpdateTeamUnits
func (SearchMembersOptions).ToConds SearchMembersOptions.ToConds
func UsersInTeamsCount UsersInTeamsCount
package "code.gitea.io/gitea/models/perm/access" code.gitea.io/gitea/models/perm/access
func GetRepoWriters GetRepoWriters
package "code.gitea.io/gitea/models/project" code.gitea.io/gitea/models/project
func UpdateBoardSorting UpdateBoardSorting
func ChangeProjectStatus ChangeProjectStatus
package "code.gitea.io/gitea/models/repo" code.gitea.io/gitea/models/repo
func DeleteAttachmentsByIssue DeleteAttachmentsByIssue
func (*releaseSorter).Len releaseSorter.Len
func (*releaseSorter).Less releaseSorter.Less
func (*releaseSorter).Swap releaseSorter.Swap
func SortReleases SortReleases
func FindReposMapByIDs FindReposMapByIDs
func (SearchOrderBy).String SearchOrderBy.String
func IsErrTopicNotExist IsErrTopicNotExist
func (ErrTopicNotExist).Error ErrTopicNotExist.Error
func (ErrTopicNotExist).Unwrap ErrTopicNotExist.Unwrap
func GetTopicByName GetTopicByName
func WatchRepoMode WatchRepoMode
package "code.gitea.io/gitea/models/unittest" code.gitea.io/gitea/models/unittest
func CheckConsistencyFor CheckConsistencyFor
func checkForConsistency checkForConsistency
func GetXORMEngine GetXORMEngine
func OverrideFixtures OverrideFixtures
func InitFixtures InitFixtures
func LoadFixtures LoadFixtures
func Copy Copy
func CopyDir CopyDir
func NewMockWebServer NewMockWebServer
func NormalizedFullPath NormalizedFullPath
func FixturesDir FixturesDir
func fatalTestError fatalTestError
func InitSettings InitSettings
func MainTest MainTest
func CreateTestEngine CreateTestEngine
func PrepareTestDatabase PrepareTestDatabase
func PrepareTestEnv PrepareTestEnv
func Cond Cond
func OrderBy OrderBy
func LoadBeanIfExists LoadBeanIfExists
func BeanExists BeanExists
func AssertExistsAndLoadBean AssertExistsAndLoadBean
func GetCount GetCount
func AssertNotExistsBean AssertNotExistsBean
func AssertExistsIf AssertExistsIf
func AssertSuccessfulInsert AssertSuccessfulInsert
func AssertCount AssertCount
func AssertInt64InRange AssertInt64InRange
package "code.gitea.io/gitea/models/user" code.gitea.io/gitea/models/user
func IsErrPrimaryEmailCannotDelete IsErrPrimaryEmailCannotDelete
func (ErrUserInactive).Error ErrUserInactive.Error
func (ErrUserInactive).Unwrap ErrUserInactive.Unwrap
func IsErrExternalLoginUserAlreadyExist IsErrExternalLoginUserAlreadyExist
func IsErrExternalLoginUserNotExist IsErrExternalLoginUserNotExist
func IsErrUserSettingIsNotExist IsErrUserSettingIsNotExist
func GetUserAllSettings GetUserAllSettings
func DeleteUserSetting DeleteUserSetting
func GetUserEmailsByNames GetUserEmailsByNames
func GetUserNamesByIDs GetUserNamesByIDs
package "code.gitea.io/gitea/modules/activitypub" code.gitea.io/gitea/modules/activitypub
func CurrentTime CurrentTime
func containsRequiredHTTPHeaders containsRequiredHTTPHeaders
func NewClient NewClient
func (*Client).NewRequest Client.NewRequest
func (*Client).Post Client.Post
func GetPrivateKey GetPrivateKey
package "code.gitea.io/gitea/modules/assetfs" code.gitea.io/gitea/modules/assetfs
func Bindata Bindata
package "code.gitea.io/gitea/modules/auth/password/hash" code.gitea.io/gitea/modules/auth/password/hash
func (*DummyHasher).HashWithSaltBytes DummyHasher.HashWithSaltBytes
func NewDummyHasher NewDummyHasher
package "code.gitea.io/gitea/modules/auth/password/pwn" code.gitea.io/gitea/modules/auth/password/pwn
func WithHTTP WithHTTP
package "code.gitea.io/gitea/modules/base" code.gitea.io/gitea/modules/base
func SetupGiteaRoot SetupGiteaRoot
package "code.gitea.io/gitea/modules/cache" code.gitea.io/gitea/modules/cache
func GetInt GetInt
func WithNoCacheContext WithNoCacheContext
func RemoveContextData RemoveContextData
package "code.gitea.io/gitea/modules/charset" code.gitea.io/gitea/modules/charset
func (*BreakWriter).Write BreakWriter.Write
package "code.gitea.io/gitea/modules/emoji" code.gitea.io/gitea/modules/emoji
func ReplaceCodes ReplaceCodes
package "code.gitea.io/gitea/modules/eventsource" code.gitea.io/gitea/modules/eventsource
func (*Event).String Event.String
package "code.gitea.io/gitea/modules/git" code.gitea.io/gitea/modules/git
func AllowLFSFiltersArgs AllowLFSFiltersArgs
func AddChanges AddChanges
func AddChangesWithArgs AddChangesWithArgs
func CommitChanges CommitChanges
func CommitChangesWithArgs CommitChangesWithArgs
func IsErrExecTimeout IsErrExecTimeout
func (ErrExecTimeout).Error ErrExecTimeout.Error
func (ErrUnsupportedVersion).Error ErrUnsupportedVersion.Error
func SetUpdateHook SetUpdateHook
func openRepositoryWithDefaultContext openRepositoryWithDefaultContext
func IsTagExist IsTagExist
func ToEntryMode ToEntryMode
func (*LimitedReaderCloser).Read LimitedReaderCloser.Read
func (*LimitedReaderCloser).Close LimitedReaderCloser.Close
package "code.gitea.io/gitea/modules/gitgraph" code.gitea.io/gitea/modules/gitgraph
func (*Parser).Reset Parser.Reset
package "code.gitea.io/gitea/modules/gitrepo" code.gitea.io/gitea/modules/gitrepo
func GetBranchCommitID GetBranchCommitID
func GetWikiDefaultBranch GetWikiDefaultBranch
package "code.gitea.io/gitea/modules/graceful" code.gitea.io/gitea/modules/graceful
func (*Manager).TerminateContext Manager.TerminateContext
func (*Manager).Err Manager.Err
func (*Manager).Value Manager.Value
func (*Manager).Deadline Manager.Deadline
package "code.gitea.io/gitea/modules/hcaptcha" code.gitea.io/gitea/modules/hcaptcha
func WithHTTP WithHTTP
package "code.gitea.io/gitea/modules/json" code.gitea.io/gitea/modules/json
func (StdJSON).Marshal StdJSON.Marshal
func (StdJSON).Unmarshal StdJSON.Unmarshal
func (StdJSON).NewEncoder StdJSON.NewEncoder
func (StdJSON).NewDecoder StdJSON.NewDecoder
func (StdJSON).Indent StdJSON.Indent
package "code.gitea.io/gitea/modules/markup" code.gitea.io/gitea/modules/markup
func IsSameDomain IsSameDomain
func GetRendererByType GetRendererByType
func RenderString RenderString
func IsMarkupFile IsMarkupFile
package "code.gitea.io/gitea/modules/markup/console" code.gitea.io/gitea/modules/markup/console
func Render Render
func RenderString RenderString
package "code.gitea.io/gitea/modules/markup/markdown" code.gitea.io/gitea/modules/markup/markdown
func IsDetails IsDetails
func IsSummary IsSummary
func IsTaskCheckBoxListItem IsTaskCheckBoxListItem
func IsIcon IsIcon
func RenderRawString RenderRawString
package "code.gitea.io/gitea/modules/markup/markdown/math" code.gitea.io/gitea/modules/markup/markdown/math
func WithInlineDollarParser WithInlineDollarParser
func WithBlockDollarParser WithBlockDollarParser
package "code.gitea.io/gitea/modules/markup/mdstripper" code.gitea.io/gitea/modules/markup/mdstripper
func StripMarkdown stripRenderer.AddOptions
StripMarkdown
package "code.gitea.io/gitea/modules/markup/orgmode" code.gitea.io/gitea/modules/markup/orgmode
func RenderString RenderString
package "code.gitea.io/gitea/modules/private" code.gitea.io/gitea/modules/private
func ActionsRunnerRegister ActionsRunnerRegister
package "code.gitea.io/gitea/modules/process" code.gitea.io/gitea/modules/process
func (*Manager).ExecTimeout Manager.ExecTimeout
package "code.gitea.io/gitea/modules/queue" code.gitea.io/gitea/modules/queue
func newBaseChannelSimple newBaseChannelSimple
func newBaseChannelUnique newBaseChannelUnique
func newBaseRedisSimple newBaseRedisSimple
func newBaseRedisUnique newBaseRedisUnique
func newWorkerPoolQueueForTest testStateRecorder.Records
testStateRecorder.Reset
newWorkerPoolQueueForTest
package "code.gitea.io/gitea/modules/queue/lqinternal" code.gitea.io/gitea/modules/queue/lqinternal
func QueueItemIDBytes QueueItemIDBytes
func QueueItemKeyBytes QueueItemKeyBytes
func ListLevelQueueKeys ListLevelQueueKeys
package "code.gitea.io/gitea/modules/setting" code.gitea.io/gitea/modules/setting
func NewConfigProviderFromData NewConfigProviderFromData
func (*GitConfigType).GetOption GitConfigType.GetOption
func InitLoggersForTest InitLoggersForTest
package "code.gitea.io/gitea/modules/storage" code.gitea.io/gitea/modules/storage
func (ErrInvalidConfiguration).Error ErrInvalidConfiguration.Error
func IsErrInvalidConfiguration IsErrInvalidConfiguration
package "code.gitea.io/gitea/modules/structs" code.gitea.io/gitea/modules/structs
func ParseCreateHook ParseCreateHook
func ParsePushHook ParsePushHook
package "code.gitea.io/gitea/modules/sync" code.gitea.io/gitea/modules/sync
func (*StatusTable).Start StatusTable.Start
func (*StatusTable).IsRunning StatusTable.IsRunning
package "code.gitea.io/gitea/modules/testlogger" code.gitea.io/gitea/modules/testlogger
func (*testLoggerWriterCloser).pushT testLoggerWriterCloser.pushT
func (*testLoggerWriterCloser).Log testLoggerWriterCloser.Log
func (*testLoggerWriterCloser).recordError testLoggerWriterCloser.recordError
func (*testLoggerWriterCloser).printMsg testLoggerWriterCloser.printMsg
func (*testLoggerWriterCloser).popT testLoggerWriterCloser.popT
func (*testLoggerWriterCloser).Reset testLoggerWriterCloser.Reset
func PrintCurrentTest PrintCurrentTest
func Printf Printf
func NewTestLoggerWriter NewTestLoggerWriter
func (*TestLogEventWriter).Base TestLogEventWriter.Base
func (*TestLogEventWriter).GetLevel TestLogEventWriter.GetLevel
func (*TestLogEventWriter).GetWriterName TestLogEventWriter.GetWriterName
func (*TestLogEventWriter).GetWriterType TestLogEventWriter.GetWriterType
func (*TestLogEventWriter).Run TestLogEventWriter.Run
package "code.gitea.io/gitea/modules/timeutil" code.gitea.io/gitea/modules/timeutil
func GetExecutableModTime GetExecutableModTime
func MockSet MockSet
func MockUnset MockUnset
package "code.gitea.io/gitea/modules/translation" code.gitea.io/gitea/modules/translation
func (MockLocale).Language MockLocale.Language
func (MockLocale).TrString MockLocale.TrString
func (MockLocale).Tr MockLocale.Tr
func (MockLocale).TrN MockLocale.TrN
func (MockLocale).TrSize MockLocale.TrSize
func (MockLocale).PrettyNumber MockLocale.PrettyNumber
package "code.gitea.io/gitea/modules/util/filebuffer" code.gitea.io/gitea/modules/util/filebuffer
func CreateFromReader CreateFromReader
package "code.gitea.io/gitea/modules/web" code.gitea.io/gitea/modules/web
func RouteMock RouteMock
func RouteMockReset RouteMockReset
package "code.gitea.io/gitea/modules/web/middleware" code.gitea.io/gitea/modules/web/middleware
func DeleteLocaleCookie DeleteLocaleCookie
package "code.gitea.io/gitea/routers/web" code.gitea.io/gitea/routers/web
func NotFound NotFound
package "code.gitea.io/gitea/routers/web/org" code.gitea.io/gitea/routers/web/org
func MustEnableProjects MustEnableProjects
package "code.gitea.io/gitea/services/context" code.gitea.io/gitea/services/context
func GetPrivateContext GetPrivateContext
package "code.gitea.io/gitea/services/convert" code.gitea.io/gitea/services/convert
func ToSecret ToSecret
package "code.gitea.io/gitea/services/forms" code.gitea.io/gitea/services/forms
func (*DeadlineForm).Validate DeadlineForm.Validate
package "code.gitea.io/gitea/services/pull" code.gitea.io/gitea/services/pull
func IsCommitStatusContextSuccess IsCommitStatusContextSuccess
package "code.gitea.io/gitea/services/repository" code.gitea.io/gitea/services/repository
func IsErrForkAlreadyExist IsErrForkAlreadyExist
package "code.gitea.io/gitea/services/repository/archiver" code.gitea.io/gitea/services/repository/archiver
func ArchiveRepository ArchiveRepository
package "code.gitea.io/gitea/services/repository/files" code.gitea.io/gitea/services/repository/files
func (*ContentType).String ContentType.String
func GetFileResponseFromCommit GetFileResponseFromCommit
func (*TemporaryUploadRepository).GetLastCommit TemporaryUploadRepository.GetLastCommit
func (*TemporaryUploadRepository).GetLastCommitByRef TemporaryUploadRepository.GetLastCommitByRef
package "code.gitea.io/gitea/services/webhook" code.gitea.io/gitea/services/webhook
func NewNotifier NewNotifier

View file

@ -1,6 +1,6 @@
{ {
"name": "Gitea DevContainer", "name": "Gitea DevContainer",
"image": "mcr.microsoft.com/devcontainers/go:1.21-bullseye", "image": "mcr.microsoft.com/devcontainers/go:1.23-bullseye",
"features": { "features": {
// installs nodejs into container // installs nodejs into container
"ghcr.io/devcontainers/features/node:1": { "ghcr.io/devcontainers/features/node:1": {

View file

@ -43,7 +43,7 @@ jobs:
- uses: https://code.forgejo.org/actions/setup-go@v4 - uses: https://code.forgejo.org/actions/setup-go@v4
with: with:
go-version: "1.22" go-version: "1.23"
check-latest: true check-latest: true
- name: version from ref - name: version from ref

View file

@ -19,7 +19,7 @@ jobs:
- uses: https://code.forgejo.org/actions/checkout@v4 - uses: https://code.forgejo.org/actions/checkout@v4
- uses: https://code.forgejo.org/actions/setup-go@v4 - uses: https://code.forgejo.org/actions/setup-go@v4
with: with:
go-version: "1.22" go-version: "1.23"
check-latest: true check-latest: true
- run: | - run: |
apt-get -qq update apt-get -qq update

View file

@ -22,7 +22,7 @@ jobs:
- uses: https://code.forgejo.org/actions/checkout@v3 - uses: https://code.forgejo.org/actions/checkout@v3
- uses: https://code.forgejo.org/actions/setup-go@v4 - uses: https://code.forgejo.org/actions/setup-go@v4
with: with:
go-version: "1.22" go-version: "1.23"
check-latest: true check-latest: true
- run: make deps-backend deps-tools - run: make deps-backend deps-tools
- run: make --always-make -j$(nproc) lint-backend checks-backend # ensure the "go-licenses" make target runs - 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/checkout@v3
- uses: https://code.forgejo.org/actions/setup-go@v4 - uses: https://code.forgejo.org/actions/setup-go@v4
with: with:
go-version: "1.22" go-version: "1.23"
- run: | - run: |
git config --add safe.directory '*' git config --add safe.directory '*'
adduser --quiet --comment forgejo --disabled-password forgejo 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/checkout@v3
- uses: https://code.forgejo.org/actions/setup-go@v4 - uses: https://code.forgejo.org/actions/setup-go@v4
with: with:
go-version: "1.22" go-version: "1.23"
- name: install dependencies & git >= 2.42 - name: install dependencies & git >= 2.42
run: | run: |
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
@ -149,7 +149,7 @@ jobs:
- uses: https://code.forgejo.org/actions/checkout@v3 - uses: https://code.forgejo.org/actions/checkout@v3
- uses: https://code.forgejo.org/actions/setup-go@v4 - uses: https://code.forgejo.org/actions/setup-go@v4
with: with:
go-version: "1.22" go-version: "1.23"
- name: install dependencies & git >= 2.42 - name: install dependencies & git >= 2.42
run: | run: |
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
@ -186,7 +186,7 @@ jobs:
- uses: https://code.forgejo.org/actions/checkout@v3 - uses: https://code.forgejo.org/actions/checkout@v3
- uses: https://code.forgejo.org/actions/setup-go@v4 - uses: https://code.forgejo.org/actions/setup-go@v4
with: with:
go-version: "1.22" go-version: "1.23"
- name: install dependencies & git >= 2.42 - name: install dependencies & git >= 2.42
run: | run: |
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive

View file

@ -1,6 +1,6 @@
FROM --platform=$BUILDPLATFORM docker.io/tonistiigi/xx AS xx 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 ARG GOPROXY
ENV GOPROXY ${GOPROXY:-direct} ENV GOPROXY ${GOPROXY:-direct}

View file

@ -1,6 +1,6 @@
FROM --platform=$BUILDPLATFORM docker.io/tonistiigi/xx AS xx 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 ARG GOPROXY
ENV GOPROXY ${GOPROXY:-direct} ENV GOPROXY ${GOPROXY:-direct}

View file

@ -29,15 +29,15 @@ XGO_VERSION := go-1.21.x
AIR_PACKAGE ?= github.com/cosmtrek/air@v1.49.0 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 EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v2/cmd/editorconfig-checker@2.8.0
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.6.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 GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.11
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.4.1 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 SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.30.6-0.20240201115257-bcc7c78b7786
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1.6.0 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 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_IMAGE ?= gitea/gitea
DOCKER_TAG ?= latest DOCKER_TAG ?= latest
@ -434,17 +434,19 @@ lint-spell:
lint-spell-fix: lint-spell-fix:
@go run $(MISSPELL_PACKAGE) -w $(SPELLCHECK_FILES) @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 .PHONY: lint-go
lint-go: lint-go:
$(GO) run $(GOLANGCI_LINT_PACKAGE) run $(GOLANGCI_LINT_ARGS) $(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 \ @$(DIFF) .deadcode-out .cur-deadcode-out \
|| (code=$$?; echo "Please run 'make lint-go-fix' and commit the result"; exit $${code}) || (code=$$?; echo "Please run 'make lint-go-fix' and commit the result"; exit $${code})
.PHONY: lint-go-fix .PHONY: lint-go-fix
lint-go-fix: lint-go-fix:
$(GO) run $(GOLANGCI_LINT_PACKAGE) run $(GOLANGCI_LINT_ARGS) --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 # workaround step for the lint-go-windows CI task because 'go run' can not
# have distinct GOOS/GOARCH for its build and run steps # have distinct GOOS/GOARCH for its build and run steps

View file

@ -549,14 +549,14 @@ Forgejo or set your environment appropriately.`, "")
index := bytes.IndexByte(rs.Data, byte(0)) index := bytes.IndexByte(rs.Data, byte(0))
if index >= len(rs.Data) { 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 index < 0 {
if len(rs.Data) == 10 && rs.Data[9] == '\n' { if len(rs.Data) == 10 && rs.Data[9] == '\n' {
index = 9 index = 9
} else { } 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)
} }
} }

View file

@ -118,7 +118,7 @@ func TestDelayWriter(t *testing.T) {
defer test.MockVariableValue(&setting.InternalToken, "Random")() defer test.MockVariableValue(&setting.InternalToken, "Random")()
defer test.MockVariableValue(&setting.InstallLock, true)() defer test.MockVariableValue(&setting.InstallLock, true)()
defer test.MockVariableValue(&setting.Git.VerbosePush, 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. // Setup the Stdin.
f, err := os.OpenFile(t.TempDir()+"/stdin", os.O_RDWR|os.O_CREATE|os.O_EXCL, 0o666) 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) { func TestPushOptions(t *testing.T) {
require.NoError(t, os.Setenv(private.GitPushOptionCount, "3")) t.Setenv(private.GitPushOptionCount, "3")
require.NoError(t, os.Setenv("GIT_PUSH_OPTION_0", "force-push")) t.Setenv("GIT_PUSH_OPTION_0", "force-push")
require.NoError(t, os.Setenv("GIT_PUSH_OPTION_1", "option=value")) t.Setenv("GIT_PUSH_OPTION_1", "option=value")
require.NoError(t, os.Setenv("GIT_PUSH_OPTION_2", "option-double=another=value")) t.Setenv("GIT_PUSH_OPTION_2", "option-double=another=value")
require.NoError(t, os.Setenv("GIT_PUSH_OPTION_3", "not=valid")) t.Setenv("GIT_PUSH_OPTION_3", "not=valid")
assert.Equal(t, map[string]string{ assert.Equal(t, map[string]string{
"force-push": "true", "force-push": "true",

12
go.mod
View file

@ -1,6 +1,8 @@
module code.gitea.io/gitea module code.gitea.io/gitea
go 1.22.7 go 1.23.0
toolchain go1.23.6
require ( require (
code.forgejo.org/forgejo/reply v1.0.1 code.forgejo.org/forgejo/reply v1.0.1
@ -100,12 +102,12 @@ require (
github.com/yuin/goldmark v1.6.0 github.com/yuin/goldmark v1.6.0
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc
github.com/yuin/goldmark-meta v1.1.0 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/image v0.18.0
golang.org/x/net v0.33.0 golang.org/x/net v0.33.0
golang.org/x/oauth2 v0.16.0 golang.org/x/oauth2 v0.16.0
golang.org/x/sys v0.28.0 golang.org/x/sys v0.30.0
golang.org/x/text v0.21.0 golang.org/x/text v0.22.0
golang.org/x/tools v0.23.0 golang.org/x/tools v0.23.0
google.golang.org/grpc v1.60.1 google.golang.org/grpc v1.60.1
google.golang.org/protobuf v1.33.0 google.golang.org/protobuf v1.33.0
@ -285,7 +287,7 @@ require (
go.uber.org/zap v1.26.0 // indirect go.uber.org/zap v1.26.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/mod v0.19.0 // 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 golang.org/x/time v0.5.0 // indirect
google.golang.org/appengine v1.6.8 // indirect google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac // indirect

20
go.sum
View file

@ -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.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.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= 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.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= 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-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-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= 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-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.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.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= 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-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-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/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.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.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.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 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-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-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= 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.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= 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.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=
golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU=
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= 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.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.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/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.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.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.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= 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-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-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=

View file

@ -4,7 +4,6 @@
package activities_test package activities_test
import ( import (
"fmt"
"testing" "testing"
"time" "time"
@ -92,11 +91,11 @@ func TestGetUserHeatmapDataByUser(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
assert.Len(t, actions, contributions, "invalid action count: did the test data became too old?") assert.Len(t, actions, contributions, "invalid action count: did the test data became too old?")
assert.Equal(t, count, int64(contributions)) 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 // Test JSON rendering
jsonData, err := json.Marshal(heatmap) jsonData, err := json.Marshal(heatmap)
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, tc.JSONResult, string(jsonData)) assert.JSONEq(t, tc.JSONResult, string(jsonData))
} }
} }

View file

@ -114,7 +114,7 @@ func readArmoredSign(r io.Reader) (body io.Reader, err error) {
return nil, err return nil, err
} }
if block.Type != openpgp.SignatureType { 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 return block.Body, nil
} }
@ -139,7 +139,7 @@ func tryGetKeyIDFromSignature(sig *packet.Signature) string {
if sig.IssuerKeyId != nil && (*sig.IssuerKeyId) != 0 { if sig.IssuerKeyId != nil && (*sig.IssuerKeyId) != 0 {
return fmt.Sprintf("%016X", *sig.IssuerKeyId) 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 fmt.Sprintf("%016X", sig.IssuerFingerprint[12:20])
} }
return "" return ""

View file

@ -22,7 +22,7 @@ func TestOAuth2Application_GenerateClientSecret(t *testing.T) {
app := unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{ID: 1}) app := unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{ID: 1})
secret, err := app.GenerateClientSecret(db.DefaultContext) secret, err := app.GenerateClientSecret(db.DefaultContext)
require.NoError(t, err) require.NoError(t, err)
assert.Positive(t, len(secret)) assert.NotEmpty(t, secret)
unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{ID: 1, ClientSecret: app.ClientSecret}) unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{ID: 1, ClientSecret: app.ClientSecret})
} }

View file

@ -4,7 +4,6 @@
package git package git
import ( import (
"fmt"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@ -72,7 +71,7 @@ func TestBranchRuleMatch(t *testing.T) {
infact = " not" infact = " not"
} }
assert.EqualValues(t, kase.ExpectedMatch, pb.Match(kase.BranchName), 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,
) )
} }
} }

View file

@ -83,7 +83,7 @@ func UnwrapLDAPSourceCfg(x *xorm.Engine) error {
if err != nil { if err != nil {
return fmt.Errorf("failed to unmarshal %s: %w", source.Cfg, err) 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) bs, err := json.Marshal(wrapped.Source)
if err != nil { if err != nil {
return err return err

View file

@ -57,8 +57,8 @@ func Test_AddRepoIDForAttachment(t *testing.T) {
err := x.Table("attachment").Where("issue_id > 0").Find(&issueAttachments) err := x.Table("attachment").Where("issue_id > 0").Find(&issueAttachments)
require.NoError(t, err) require.NoError(t, err)
for _, attach := range issueAttachments { for _, attach := range issueAttachments {
assert.Greater(t, attach.RepoID, int64(0)) assert.Positive(t, attach.RepoID)
assert.Greater(t, attach.IssueID, int64(0)) assert.Positive(t, attach.IssueID)
var issue Issue var issue Issue
has, err := x.ID(attach.IssueID).Get(&issue) has, err := x.ID(attach.IssueID).Get(&issue)
require.NoError(t, err) require.NoError(t, err)
@ -70,8 +70,8 @@ func Test_AddRepoIDForAttachment(t *testing.T) {
err = x.Table("attachment").Where("release_id > 0").Find(&releaseAttachments) err = x.Table("attachment").Where("release_id > 0").Find(&releaseAttachments)
require.NoError(t, err) require.NoError(t, err)
for _, attach := range releaseAttachments { for _, attach := range releaseAttachments {
assert.Greater(t, attach.RepoID, int64(0)) assert.Positive(t, attach.RepoID)
assert.Greater(t, attach.ReleaseID, int64(0)) assert.Positive(t, attach.ReleaseID)
var release Release var release Release
has, err := x.ID(attach.ReleaseID).Get(&release) has, err := x.ID(attach.ReleaseID).Get(&release)
require.NoError(t, err) require.NoError(t, err)

View file

@ -5,7 +5,6 @@ package project
import ( import (
"fmt" "fmt"
"strings"
"testing" "testing"
"code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/db"
@ -124,5 +123,5 @@ func Test_NewBoard(t *testing.T) {
ProjectID: project1.ID, ProjectID: project1.ID,
}) })
require.Error(t, err) 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")
} }

View file

@ -764,7 +764,7 @@ func GetUserRepositories(ctx context.Context, opts *SearchRepoOptions) (Reposito
cond = cond.And(builder.Eq{"is_private": false}) 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)) cond = cond.And(builder.In("lower_name", opts.LowerNames))
} }

View file

@ -510,7 +510,7 @@ func Test_ValidateUser(t *testing.T) {
{ID: 2, Visibility: structs.VisibleTypePrivate}: true, {ID: 2, Visibility: structs.VisibleTypePrivate}: true,
} }
for kase, expected := range kases { 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)
} }
} }

View file

@ -8,7 +8,6 @@ import (
"io" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"regexp"
"testing" "testing"
"code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/db"
@ -29,7 +28,7 @@ func TestActivityPubSignedPost(t *testing.T) {
expected := "BODY" expected := "BODY"
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 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.Contains(t, r.Header.Get("Signature"), pubID)
assert.Equal(t, ActivityStreamsContentType, r.Header.Get("Content-Type")) assert.Equal(t, ActivityStreamsContentType, r.Header.Get("Content-Type"))
body, err := io.ReadAll(r.Body) body, err := io.ReadAll(r.Body)

View file

@ -73,7 +73,9 @@ func (cc *cacheContext) Expired() bool {
return timeNow().Sub(cc.created) > cacheContextLifetime 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, Since there are both WithCacheContext and WithNoCacheContext,

View file

@ -114,7 +114,7 @@ type LogNameStatusCommitData struct {
// Next returns the next LogStatusCommitData // Next returns the next LogStatusCommitData
func (g *LogNameStatusRepoParser) Next(treepath string, paths2ids map[string]int, changed []bool, maxpathlen int) (*LogNameStatusCommitData, error) { func (g *LogNameStatusRepoParser) Next(treepath string, paths2ids map[string]int, changed []bool, maxpathlen int) (*LogNameStatusCommitData, error) {
var err error var err error
if g.next == nil || len(g.next) == 0 { if len(g.next) == 0 {
g.buffull = false g.buffull = false
g.next, err = g.rd.ReadSlice('\x00') g.next, err = g.rd.ReadSlice('\x00')
if err != nil { if err != nil {

View file

@ -367,7 +367,7 @@ func (f *valuedField) Render() string {
} }
func (f *valuedField) Value() 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 { func (f *valuedField) Options() []*valuedOption {

View file

@ -251,7 +251,7 @@ func TestHTTPClientDownload(t *testing.T) {
return nil return nil
}) })
if len(c.expectederror) > 0 { 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 { } else {
require.NoError(t, err, "case %d", n) require.NoError(t, err, "case %d", n)
} }
@ -353,7 +353,7 @@ func TestHTTPClientUpload(t *testing.T) {
return io.NopCloser(new(bytes.Buffer)), objectError return io.NopCloser(new(bytes.Buffer)), objectError
}) })
if len(c.expectederror) > 0 { 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 { } else {
require.NoError(t, err, "case %d", n) require.NoError(t, err, "case %d", n)
} }

View file

@ -97,7 +97,7 @@ func TestBasicTransferAdapter(t *testing.T) {
for n, c := range cases { for n, c := range cases {
_, err := a.Download(context.Background(), c.link) _, err := a.Download(context.Background(), c.link)
if len(c.expectederror) > 0 { 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 { } else {
require.NoError(t, err, "case %d", n) require.NoError(t, err, "case %d", n)
} }
@ -130,7 +130,7 @@ func TestBasicTransferAdapter(t *testing.T) {
for n, c := range cases { for n, c := range cases {
err := a.Upload(context.Background(), c.link, p, bytes.NewBufferString("dummy")) err := a.Upload(context.Background(), c.link, p, bytes.NewBufferString("dummy"))
if len(c.expectederror) > 0 { 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 { } else {
require.NoError(t, err, "case %d", n) require.NoError(t, err, "case %d", n)
} }
@ -163,7 +163,7 @@ func TestBasicTransferAdapter(t *testing.T) {
for n, c := range cases { for n, c := range cases {
err := a.Verify(context.Background(), c.link, p) err := a.Verify(context.Background(), c.link, p)
if len(c.expectederror) > 0 { 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 { } else {
require.NoError(t, err, "case %d", n) require.NoError(t, err, "case %d", n)
} }

View file

@ -120,7 +120,7 @@ func (q *baseChannel) RemoveAll(ctx context.Context) error {
q.mu.Lock() q.mu.Lock()
defer q.mu.Unlock() defer q.mu.Unlock()
for q.c != nil && len(q.c) > 0 { for len(q.c) > 0 {
<-q.c <-q.c
} }

View file

@ -173,8 +173,8 @@ func testWorkerPoolQueuePersistence(t *testing.T, queueSetting setting.QueueSett
q2() // restart the queue to continue to execute the tasks in it q2() // restart the queue to continue to execute the tasks in it
assert.NotZero(t, len(tasksQ1)) assert.NotEmpty(t, tasksQ1)
assert.NotZero(t, len(tasksQ2)) assert.NotEmpty(t, tasksQ2)
assert.EqualValues(t, testCount, len(tasksQ1)+len(tasksQ2)) assert.EqualValues(t, testCount, len(tasksQ1)+len(tasksQ2))
} }

View file

@ -445,7 +445,7 @@ MINIO_BASE_PATH = /lfs
require.NoError(t, loadLFSFrom(cfg)) require.NoError(t, loadLFSFrom(cfg))
assert.EqualValues(t, "my_access_key", LFS.Storage.MinioConfig.AccessKeyID) assert.EqualValues(t, "my_access_key", LFS.Storage.MinioConfig.AccessKeyID)
assert.EqualValues(t, "my_secret_key", LFS.Storage.MinioConfig.SecretAccessKey) 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) assert.EqualValues(t, "/lfs", LFS.Storage.MinioConfig.BasePath)
cfg, err = NewConfigProviderFromData(` cfg, err = NewConfigProviderFromData(`

View file

@ -10,7 +10,6 @@ import (
"crypto/sha256" "crypto/sha256"
"crypto/x509" "crypto/x509"
"encoding/pem" "encoding/pem"
"regexp"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@ -24,8 +23,8 @@ func TestKeygen(t *testing.T) {
assert.NotEmpty(t, priv) assert.NotEmpty(t, priv)
assert.NotEmpty(t, pub) assert.NotEmpty(t, pub)
assert.Regexp(t, regexp.MustCompile("^-----BEGIN RSA PRIVATE KEY-----.*"), priv) assert.Regexp(t, "^-----BEGIN RSA PRIVATE KEY-----.*", priv)
assert.Regexp(t, regexp.MustCompile("^-----BEGIN PUBLIC KEY-----.*"), pub) assert.Regexp(t, "^-----BEGIN PUBLIC KEY-----.*", pub)
} }
func TestSignUsingKeys(t *testing.T) { func TestSignUsingKeys(t *testing.T) {

View file

@ -730,7 +730,7 @@ func EditPullRequest(ctx *context.APIContext) {
// update allow edits // update allow edits
if form.AllowMaintainerEdit != nil { if form.AllowMaintainerEdit != nil {
if err := pull_service.SetAllowEdits(ctx, ctx.Doer, pr, *form.AllowMaintainerEdit); err != 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)) ctx.Error(http.StatusForbidden, "SetAllowEdits", fmt.Sprintf("SetAllowEdits: %s", err))
return return
} }

View file

@ -1813,7 +1813,7 @@ func SetAllowEdits(ctx *context.Context) {
} }
if err := pull_service.SetAllowEdits(ctx, ctx.Doer, pr, form.AllowMaintainerEdit); err != 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) ctx.Error(http.StatusForbidden)
return return
} }

View file

@ -8,6 +8,7 @@ import (
"bytes" "bytes"
gocontext "context" gocontext "context"
"encoding/base64" "encoding/base64"
"errors"
"fmt" "fmt"
"html/template" "html/template"
"image" "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) { func checkCitationFile(ctx *context.Context, entry *git.TreeEntry) {

View file

@ -6,6 +6,7 @@ package user
import ( import (
"bytes" "bytes"
"errors"
"fmt" "fmt"
"net/http" "net/http"
"regexp" "regexp"
@ -747,7 +748,7 @@ func UsernameSubRoute(ctx *context.Context) {
} }
// check view permissions // check view permissions
if !user_model.IsUserVisibleToViewer(ctx, ctx.ContextUser, ctx.Doer) { 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 false
} }
return true return true

View file

@ -56,7 +56,7 @@ func OwnerProfile(ctx *context.Context) {
func userProfile(ctx *context.Context) { func userProfile(ctx *context.Context) {
// check view permissions // check view permissions
if !user_model.IsUserVisibleToViewer(ctx, ctx.ContextUser, ctx.Doer) { 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 return
} }

View file

@ -34,7 +34,9 @@ import (
"github.com/nektos/act/pkg/model" "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. // withMethod sets the notification method that this context currently executes.
// Used for debugging/ troubleshooting purposes. // Used for debugging/ troubleshooting purposes.

View file

@ -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 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) log.Info("%-v was scheduled to automerge by an unauthorized user", pr)
return return
} }

View file

@ -1058,7 +1058,7 @@ func readFileName(rd *strings.Reader) (string, bool) {
char, _ := rd.ReadByte() char, _ := rd.ReadByte()
_ = rd.UnreadByte() _ = rd.UnreadByte()
if char == '"' { if char == '"' {
fmt.Fscanf(rd, "%q ", &name) _, _ = fmt.Fscanf(rd, "%q ", &name)
if len(name) == 0 { if len(name) == 0 {
log.Error("Reader has no file name: reader=%+v", rd) log.Error("Reader has no file name: reader=%+v", rd)
return "", true return "", true
@ -1070,12 +1070,12 @@ func readFileName(rd *strings.Reader) (string, bool) {
} else { } else {
// This technique is potentially ambiguous it may not be possible to uniquely identify the filenames from the diff line alone // This technique is potentially ambiguous it may not be possible to uniquely identify the filenames from the diff line alone
ambiguity = true ambiguity = true
fmt.Fscanf(rd, "%s ", &name) _, _ = fmt.Fscanf(rd, "%s ", &name)
char, _ := rd.ReadByte() char, _ := rd.ReadByte()
_ = rd.UnreadByte() _ = rd.UnreadByte()
for !(char == 0 || char == '"' || char == 'b') { for !(char == 0 || char == '"' || char == 'b') {
var suffix string var suffix string
fmt.Fscanf(rd, "%s ", &suffix) _, _ = fmt.Fscanf(rd, "%s ", &suffix)
name += " " + suffix name += " " + suffix
char, _ = rd.ReadByte() char, _ = rd.ReadByte()
_ = rd.UnreadByte() _ = rd.UnreadByte()

View file

@ -5,7 +5,6 @@
package gitdiff package gitdiff
import ( import (
"fmt"
"strconv" "strconv"
"strings" "strings"
"testing" "testing"
@ -645,9 +644,9 @@ func TestGetDiffRangeWithWhitespaceBehavior(t *testing.T) {
MaxFiles: setting.Git.MaxGitDiffFiles, MaxFiles: setting.Git.MaxGitDiffFiles,
WhitespaceBehavior: behavior, 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 { 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)
} }
} }
} }

View file

@ -229,7 +229,7 @@ func TestRelease_Update(t *testing.T) {
IsTag: false, IsTag: false,
} }
require.NoError(t, CreateRelease(gitRepo, release, nil, "")) require.NoError(t, CreateRelease(gitRepo, release, nil, ""))
assert.Greater(t, release.ID, int64(0)) assert.Positive(t, release.ID)
release.IsDraft = false release.IsDraft = false
tagName := release.TagName tagName := release.TagName

View file

@ -37,7 +37,7 @@ func TestRepository_ContributorsGraph(t *testing.T) {
dataString, isData := mockCache.Get("key2").(string) dataString, isData := mockCache.Get("key2").(string)
assert.True(t, isData) assert.True(t, isData)
// Verify that JSON is actually stored in the cache. // 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 var data map[string]*ContributorData
require.NoError(t, json.Unmarshal([]byte(dataString), &data)) require.NoError(t, json.Unmarshal([]byte(dataString), &data))

View file

@ -40,7 +40,7 @@ func TestAPIListStopWatches(t *testing.T) {
assert.EqualValues(t, issue.Title, apiWatches[0].IssueTitle) assert.EqualValues(t, issue.Title, apiWatches[0].IssueTitle)
assert.EqualValues(t, repo.Name, apiWatches[0].RepoName) assert.EqualValues(t, repo.Name, apiWatches[0].RepoName)
assert.EqualValues(t, repo.OwnerName, apiWatches[0].RepoOwnerName) assert.EqualValues(t, repo.OwnerName, apiWatches[0].RepoOwnerName)
assert.Greater(t, apiWatches[0].Seconds, int64(0)) assert.Positive(t, apiWatches[0].Seconds)
} }
} }

View file

@ -121,7 +121,7 @@ func TestAPINotification(t *testing.T) {
AddTokenAuth(token) AddTokenAuth(token)
resp = MakeRequest(t, req, http.StatusOK) resp = MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &new) DecodeJSON(t, resp, &new)
assert.Greater(t, new.New, int64(0)) assert.Positive(t, new.New)
// -- mark notifications as read -- // -- mark notifications as read --
req = NewRequest(t, "GET", "/api/v1/notifications?status-types=unread"). req = NewRequest(t, "GET", "/api/v1/notifications?status-types=unread").

View file

@ -5,6 +5,7 @@ package integration
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"net/http" "net/http"
"net/url" "net/url"
@ -54,13 +55,13 @@ func testAPIPushMirror(t *testing.T, u *url.URL) {
deletePushMirrors := repo_model.DeletePushMirrors deletePushMirrors := repo_model.DeletePushMirrors
deletePushMirrorsError := "deletePushMirrorsError" deletePushMirrorsError := "deletePushMirrorsError"
deletePushMirrorsFail := func(ctx context.Context, opts repo_model.PushMirrorOptions) error { deletePushMirrorsFail := func(ctx context.Context, opts repo_model.PushMirrorOptions) error {
return fmt.Errorf(deletePushMirrorsError) return errors.New(deletePushMirrorsError)
} }
addPushMirrorRemote := mirror_service.AddPushMirrorRemote addPushMirrorRemote := mirror_service.AddPushMirrorRemote
addPushMirrorRemoteError := "addPushMirrorRemoteError" addPushMirrorRemoteError := "addPushMirrorRemoteError"
addPushMirrorRemoteFail := func(ctx context.Context, m *repo_model.PushMirror, addr string) error { addPushMirrorRemoteFail := func(ctx context.Context, m *repo_model.PushMirror, addr string) error {
return fmt.Errorf(addPushMirrorRemoteError) return errors.New(addPushMirrorRemoteError)
} }
for _, testCase := range []struct { for _, testCase := range []struct {

View file

@ -236,17 +236,17 @@ func TestAPIDeleteReleaseByTagName(t *testing.T) {
createNewReleaseUsingAPI(t, session, token, owner, repo, "release-tag", "", "Release Tag", "test") createNewReleaseUsingAPI(t, session, token, owner, repo, "release-tag", "", "Release Tag", "test")
// delete release // 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) AddTokenAuth(token)
_ = MakeRequest(t, req, http.StatusNoContent) _ = MakeRequest(t, req, http.StatusNoContent)
// make sure release is deleted // 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) AddTokenAuth(token)
_ = MakeRequest(t, req, http.StatusNotFound) _ = MakeRequest(t, req, http.StatusNotFound)
// delete release tag too // 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) AddTokenAuth(token)
_ = MakeRequest(t, req, http.StatusNoContent) _ = MakeRequest(t, req, http.StatusNoContent)
} }

View file

@ -39,7 +39,7 @@ func TestAPIRepoTeams(t *testing.T) {
if assert.Len(t, teams, 2) { if assert.Len(t, teams, 2) {
assert.EqualValues(t, "Owners", teams[0].Name) assert.EqualValues(t, "Owners", teams[0].Name)
assert.True(t, teams[0].CanCreateOrgRepo) 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, "owner", teams[0].Permission)
assert.EqualValues(t, "test_team", teams[1].Name) assert.EqualValues(t, "test_team", teams[1].Name)

View file

@ -40,7 +40,7 @@ func TestCompareTag(t *testing.T) {
req = NewRequest(t, "GET", "/user2/repo1/compare/invalid") req = NewRequest(t, "GET", "/user2/repo1/compare/invalid")
resp = session.MakeRequest(t, req, http.StatusNotFound) 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) // Compare with inferred default branch (master)

View file

@ -81,7 +81,7 @@ func TestMigrate(t *testing.T) {
{svc: structs.ForgejoService}, {svc: structs.ForgejoService},
} { } {
// Step 0: verify the repo is available // 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) _ = session.MakeRequest(t, req, http.StatusOK)
// Step 1: get the Gitea migration form // Step 1: get the Gitea migration form
req = NewRequestf(t, "GET", "/repo/migrate/?service_type=%d", s.svc) req = NewRequestf(t, "GET", "/repo/migrate/?service_type=%d", s.svc)

View file

@ -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") link, exists := htmlDoc.doc.Find(fmt.Sprintf("form.ui.form[action=\"%s\"]", forkURL)).Attr("action")
assert.True(t, exists, "The template has changed") 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") _, 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{ req = NewRequestWithValues(t, "POST", link, map[string]string{
"_csrf": htmlDoc.GetCSRF(), "_csrf": htmlDoc.GetCSRF(),
"uid": fmt.Sprintf("%d", forkOwner.ID), "uid": fmt.Sprintf("%d", forkOwner.ID),

View file

@ -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") link, exists = htmlDoc.doc.Find("form.ui.form[action^=\"/repo/create\"]").Attr("action")
assert.True(t, exists, "The template has changed") 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") _, 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{ req = NewRequestWithValues(t, "POST", link, map[string]string{
"_csrf": htmlDoc.GetCSRF(), "_csrf": htmlDoc.GetCSRF(),
"uid": fmt.Sprintf("%d", generateOwner.ID), "uid": fmt.Sprintf("%d", generateOwner.ID),

View file

@ -447,7 +447,7 @@ func TestViewRepoDirectory(t *testing.T) {
repoSummary := htmlDoc.doc.Find(".repository-summary") repoSummary := htmlDoc.doc.Find(".repository-summary")
repoFilesTable := htmlDoc.doc.Find("#repo-files-table") 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, description.Length())
assert.Zero(t, repoTopics.Length()) assert.Zero(t, repoTopics.Length())

View file

@ -294,7 +294,7 @@ func TestListStopWatches(t *testing.T) {
assert.EqualValues(t, issue.Title, apiWatches[0].IssueTitle) assert.EqualValues(t, issue.Title, apiWatches[0].IssueTitle)
assert.EqualValues(t, repo.Name, apiWatches[0].RepoName) assert.EqualValues(t, repo.Name, apiWatches[0].RepoName)
assert.EqualValues(t, repo.OwnerName, apiWatches[0].RepoOwnerName) assert.EqualValues(t, repo.OwnerName, apiWatches[0].RepoOwnerName)
assert.Greater(t, apiWatches[0].Seconds, int64(0)) assert.Positive(t, apiWatches[0].Seconds)
} }
} }