mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-22 11:16:06 +08:00
Update go tool dependencies, restructure lint targets (#24239)
- Update all tool dependencies to latest tag - Remove unused errcheck, it is part of golangci-lint - Include main.go in air - Enable wastedassign again now that it's [generics-compatible](https://github.com/golangci/golangci-lint/pull/3689) - Restructured lint targets to new `lint-*` namespace
This commit is contained in:
parent
8820191476
commit
8dc6eabbc0
|
@ -5,6 +5,7 @@ tmp_dir = ".air"
|
||||||
cmd = "make backend"
|
cmd = "make backend"
|
||||||
bin = "gitea"
|
bin = "gitea"
|
||||||
include_ext = ["go", "tmpl"]
|
include_ext = ["go", "tmpl"]
|
||||||
exclude_dir = ["modules/git/tests", "services/gitdiff/testdata", "modules/avatar/testdata", "models/fixtures", "models/migrations/fixtures", "modules/migration/file_format_testdata", "modules/avatar/identicon/testdata"]
|
include_file = ["main.go"]
|
||||||
include_dir = ["cmd", "models", "modules", "options", "routers", "services"]
|
include_dir = ["cmd", "models", "modules", "options", "routers", "services"]
|
||||||
|
exclude_dir = ["modules/git/tests", "services/gitdiff/testdata", "modules/avatar/testdata", "models/fixtures", "models/migrations/fixtures", "modules/migration/file_format_testdata", "modules/avatar/identicon/testdata"]
|
||||||
exclude_regex = ["_test.go$", "_gen.go$"]
|
exclude_regex = ["_test.go$", "_gen.go$"]
|
||||||
|
|
|
@ -59,7 +59,7 @@ steps:
|
||||||
- name: lint-backend-windows
|
- name: lint-backend-windows
|
||||||
image: gitea/test_env:linux-1.20-amd64 # https://gitea.com/gitea/test-env
|
image: gitea/test_env:linux-1.20-amd64 # https://gitea.com/gitea/test-env
|
||||||
commands:
|
commands:
|
||||||
- make golangci-lint-windows vet
|
- make lint-go-windows lint-go-vet
|
||||||
environment:
|
environment:
|
||||||
GOPROXY: https://goproxy.io # proxy.golang.org is blocked in China, this proxy is not
|
GOPROXY: https://goproxy.io # proxy.golang.org is blocked in China, this proxy is not
|
||||||
GOSUMDB: sum.golang.org
|
GOSUMDB: sum.golang.org
|
||||||
|
|
|
@ -22,7 +22,7 @@ linters:
|
||||||
- unconvert
|
- unconvert
|
||||||
- unused
|
- unused
|
||||||
# - varcheck # deprecated - https://github.com/golangci/golangci-lint/issues/1841
|
# - varcheck # deprecated - https://github.com/golangci/golangci-lint/issues/1841
|
||||||
# - wastedassign # disabled - https://github.com/golangci/golangci-lint/issues/2649
|
- wastedassign
|
||||||
enable-all: false
|
enable-all: false
|
||||||
disable-all: true
|
disable-all: true
|
||||||
fast: false
|
fast: false
|
||||||
|
|
110
Makefile
110
Makefile
|
@ -25,16 +25,15 @@ COMMA := ,
|
||||||
|
|
||||||
XGO_VERSION := go-1.20.x
|
XGO_VERSION := go-1.20.x
|
||||||
|
|
||||||
AIR_PACKAGE ?= github.com/cosmtrek/air@v1.40.4
|
AIR_PACKAGE ?= github.com/cosmtrek/air@v1.43.0
|
||||||
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@2.6.0
|
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@2.7.0
|
||||||
ERRCHECK_PACKAGE ?= github.com/kisielk/errcheck@v1.6.2
|
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.5.0
|
||||||
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.4.0
|
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2
|
||||||
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.2
|
GXZ_PAGAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.11
|
||||||
GXZ_PAGAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.10
|
|
||||||
MISSPELL_PACKAGE ?= github.com/client9/misspell/cmd/misspell@v0.3.4
|
MISSPELL_PACKAGE ?= github.com/client9/misspell/cmd/misspell@v0.3.4
|
||||||
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.30.4
|
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.30.4
|
||||||
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
|
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
|
||||||
GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1.5.0
|
GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1.6.0
|
||||||
GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@latest
|
GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@latest
|
||||||
|
|
||||||
DOCKER_IMAGE ?= gitea/gitea
|
DOCKER_IMAGE ?= gitea/gitea
|
||||||
|
@ -194,9 +193,20 @@ help:
|
||||||
@echo " - deps-backend install backend dependencies"
|
@echo " - deps-backend install backend dependencies"
|
||||||
@echo " - deps-tools install tool dependencies"
|
@echo " - deps-tools install tool dependencies"
|
||||||
@echo " - lint lint everything"
|
@echo " - lint lint everything"
|
||||||
|
@echo " - lint-fix lint everything and fix issues"
|
||||||
@echo " - lint-frontend lint frontend files"
|
@echo " - lint-frontend lint frontend files"
|
||||||
|
@echo " - lint-frontend-fix lint frontend files and fix issues"
|
||||||
@echo " - lint-backend lint backend files"
|
@echo " - lint-backend lint backend files"
|
||||||
|
@echo " - lint-backend-fix lint backend files and fix issues"
|
||||||
|
@echo " - lint-go lint go files"
|
||||||
|
@echo " - lint-go-fix lint go files and fix issues"
|
||||||
|
@echo " - lint-go-vet lint go files with vet"
|
||||||
|
@echo " - lint-js lint js files"
|
||||||
|
@echo " - lint-js-fix lint js files and fix issues"
|
||||||
|
@echo " - lint-css lint css files"
|
||||||
|
@echo " - lint-css-fix lint css files and fix issues"
|
||||||
@echo " - lint-md lint markdown files"
|
@echo " - lint-md lint markdown files"
|
||||||
|
@echo " - lint-swagger lint swagger files"
|
||||||
@echo " - checks run various consistency checks"
|
@echo " - checks run various consistency checks"
|
||||||
@echo " - checks-frontend check frontend files"
|
@echo " - checks-frontend check frontend files"
|
||||||
@echo " - checks-backend check backend files"
|
@echo " - checks-backend check backend files"
|
||||||
|
@ -214,9 +224,7 @@ help:
|
||||||
@echo " - generate-manpage generate manpage"
|
@echo " - generate-manpage generate manpage"
|
||||||
@echo " - generate-swagger generate the swagger spec from code comments"
|
@echo " - generate-swagger generate the swagger spec from code comments"
|
||||||
@echo " - swagger-validate check if the swagger spec is valid"
|
@echo " - swagger-validate check if the swagger spec is valid"
|
||||||
@echo " - golangci-lint run golangci-lint linter"
|
|
||||||
@echo " - go-licenses regenerate go licenses"
|
@echo " - go-licenses regenerate go licenses"
|
||||||
@echo " - vet examines Go source code and reports suspicious constructs"
|
|
||||||
@echo " - tidy run go mod tidy"
|
@echo " - tidy run go mod tidy"
|
||||||
@echo " - test[\#TestSpecificName] run unit test"
|
@echo " - test[\#TestSpecificName] run unit test"
|
||||||
@echo " - test-sqlite[\#TestSpecificName] run integration test for sqlite"
|
@echo " - test-sqlite[\#TestSpecificName] run integration test for sqlite"
|
||||||
|
@ -286,12 +294,6 @@ fmt-check: fmt
|
||||||
misspell-check:
|
misspell-check:
|
||||||
go run $(MISSPELL_PACKAGE) -error $(GO_DIRS) $(WEB_DIRS)
|
go run $(MISSPELL_PACKAGE) -error $(GO_DIRS) $(WEB_DIRS)
|
||||||
|
|
||||||
.PHONY: vet
|
|
||||||
vet:
|
|
||||||
@echo "Running go vet..."
|
|
||||||
@GOOS= GOARCH= $(GO) build code.gitea.io/gitea-vet
|
|
||||||
@$(GO) vet -vettool=gitea-vet $(GO_PACKAGES)
|
|
||||||
|
|
||||||
.PHONY: $(TAGS_EVIDENCE)
|
.PHONY: $(TAGS_EVIDENCE)
|
||||||
$(TAGS_EVIDENCE):
|
$(TAGS_EVIDENCE):
|
||||||
@mkdir -p $(MAKE_EVIDENCE_DIR)
|
@mkdir -p $(MAKE_EVIDENCE_DIR)
|
||||||
|
@ -324,11 +326,6 @@ swagger-validate:
|
||||||
$(GO) run $(SWAGGER_PACKAGE) validate './$(SWAGGER_SPEC)'
|
$(GO) run $(SWAGGER_PACKAGE) validate './$(SWAGGER_SPEC)'
|
||||||
$(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)'
|
$(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)'
|
||||||
|
|
||||||
.PHONY: errcheck
|
|
||||||
errcheck:
|
|
||||||
@echo "Running errcheck..."
|
|
||||||
$(GO) run $(ERRCHECK_PACKAGE) $(GO_PACKAGES)
|
|
||||||
|
|
||||||
.PHONY: checks
|
.PHONY: checks
|
||||||
checks: checks-frontend checks-backend
|
checks: checks-frontend checks-backend
|
||||||
|
|
||||||
|
@ -341,18 +338,69 @@ checks-backend: tidy-check swagger-check fmt-check misspell-check swagger-valida
|
||||||
.PHONY: lint
|
.PHONY: lint
|
||||||
lint: lint-frontend lint-backend
|
lint: lint-frontend lint-backend
|
||||||
|
|
||||||
|
.PHONY: lint-fix
|
||||||
|
lint-fix: lint-frontend-fix lint-backend-fix
|
||||||
|
|
||||||
.PHONY: lint-frontend
|
.PHONY: lint-frontend
|
||||||
lint-frontend: node_modules lint-md
|
lint-frontend: lint-js lint-css lint-md lint-swagger
|
||||||
|
|
||||||
|
.PHONY: lint-frontend-fix
|
||||||
|
lint-frontend-fix: lint-js-fix lint-css-fix lint-md lint-swagger
|
||||||
|
|
||||||
|
.PHONY: lint-backend
|
||||||
|
lint-backend: lint-go lint-go-vet lint-editorconfig
|
||||||
|
|
||||||
|
.PHONY: lint-backend-fix
|
||||||
|
lint-backend-fix: lint-go-fix lint-go-vet lint-editorconfig
|
||||||
|
|
||||||
|
.PHONY: lint-js
|
||||||
|
lint-js: node_modules
|
||||||
npx eslint --color --max-warnings=0 --ext js,vue web_src/js build *.config.js docs/assets/js tests/e2e
|
npx eslint --color --max-warnings=0 --ext js,vue web_src/js build *.config.js docs/assets/js tests/e2e
|
||||||
|
|
||||||
|
.PHONY: lint-js-fix
|
||||||
|
lint-js-fix: node_modules
|
||||||
|
npx eslint --color --max-warnings=0 --ext js,vue web_src/js build *.config.js docs/assets/js tests/e2e --fix
|
||||||
|
|
||||||
|
.PHONY: lint-css
|
||||||
|
lint-css: node_modules
|
||||||
npx stylelint --color --max-warnings=0 web_src/css
|
npx stylelint --color --max-warnings=0 web_src/css
|
||||||
|
|
||||||
|
.PHONY: lint-css-fix
|
||||||
|
lint-css-fix: node_modules
|
||||||
|
npx stylelint --color --max-warnings=0 web_src/css --fix
|
||||||
|
|
||||||
|
.PHONY: lint-swagger
|
||||||
|
lint-swagger: node_modules
|
||||||
npx spectral lint -q -F hint $(SWAGGER_SPEC)
|
npx spectral lint -q -F hint $(SWAGGER_SPEC)
|
||||||
|
|
||||||
.PHONY: lint-md
|
.PHONY: lint-md
|
||||||
lint-md: node_modules
|
lint-md: node_modules
|
||||||
npx markdownlint docs *.md
|
npx markdownlint docs *.md
|
||||||
|
|
||||||
.PHONY: lint-backend
|
.PHONY: lint-go
|
||||||
lint-backend: golangci-lint vet editorconfig-checker
|
lint-go:
|
||||||
|
$(GO) run $(GOLANGCI_LINT_PACKAGE) run
|
||||||
|
|
||||||
|
.PHONY: lint-go-fix
|
||||||
|
lint-go-fix:
|
||||||
|
$(GO) run $(GOLANGCI_LINT_PACKAGE) run --fix
|
||||||
|
|
||||||
|
# workaround step for the lint-backend-windows CI task because 'go run' can not
|
||||||
|
# have distinct GOOS/GOARCH for its build and run steps
|
||||||
|
.PHONY: lint-go-windows
|
||||||
|
lint-go-windows:
|
||||||
|
@GOOS= GOARCH= $(GO) install $(GOLANGCI_LINT_PACKAGE)
|
||||||
|
golangci-lint run
|
||||||
|
|
||||||
|
.PHONY: lint-go-vet
|
||||||
|
lint-go-vet:
|
||||||
|
@echo "Running go vet..."
|
||||||
|
@GOOS= GOARCH= $(GO) build code.gitea.io/gitea-vet
|
||||||
|
@$(GO) vet -vettool=gitea-vet $(GO_PACKAGES)
|
||||||
|
|
||||||
|
.PHONY: lint-editorconfig
|
||||||
|
lint-editorconfig:
|
||||||
|
$(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) templates
|
||||||
|
|
||||||
.PHONY: watch
|
.PHONY: watch
|
||||||
watch:
|
watch:
|
||||||
|
@ -843,7 +891,6 @@ deps-backend:
|
||||||
deps-tools:
|
deps-tools:
|
||||||
$(GO) install $(AIR_PACKAGE)
|
$(GO) install $(AIR_PACKAGE)
|
||||||
$(GO) install $(EDITORCONFIG_CHECKER_PACKAGE)
|
$(GO) install $(EDITORCONFIG_CHECKER_PACKAGE)
|
||||||
$(GO) install $(ERRCHECK_PACKAGE)
|
|
||||||
$(GO) install $(GOFUMPT_PACKAGE)
|
$(GO) install $(GOFUMPT_PACKAGE)
|
||||||
$(GO) install $(GOLANGCI_LINT_PACKAGE)
|
$(GO) install $(GOLANGCI_LINT_PACKAGE)
|
||||||
$(GO) install $(GXZ_PAGAGE)
|
$(GO) install $(GXZ_PAGAGE)
|
||||||
|
@ -942,21 +989,6 @@ generate-manpage:
|
||||||
@gzip -9 man/man1/gitea.1 && echo man/man1/gitea.1.gz created
|
@gzip -9 man/man1/gitea.1 && echo man/man1/gitea.1.gz created
|
||||||
@#TODO A small script that formats config-cheat-sheet.en-us.md nicely for use as a config man page
|
@#TODO A small script that formats config-cheat-sheet.en-us.md nicely for use as a config man page
|
||||||
|
|
||||||
.PHONY: golangci-lint
|
|
||||||
golangci-lint:
|
|
||||||
$(GO) run $(GOLANGCI_LINT_PACKAGE) run
|
|
||||||
|
|
||||||
# workaround step for the lint-backend-windows CI task because 'go run' can not
|
|
||||||
# have distinct GOOS/GOARCH for its build and run steps
|
|
||||||
.PHONY: golangci-lint-windows
|
|
||||||
golangci-lint-windows:
|
|
||||||
@GOOS= GOARCH= $(GO) install $(GOLANGCI_LINT_PACKAGE)
|
|
||||||
golangci-lint run
|
|
||||||
|
|
||||||
.PHONY: editorconfig-checker
|
|
||||||
editorconfig-checker:
|
|
||||||
$(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) templates
|
|
||||||
|
|
||||||
.PHONY: docker
|
.PHONY: docker
|
||||||
docker:
|
docker:
|
||||||
docker build --disable-content-trust=false -t $(DOCKER_REF) .
|
docker build --disable-content-trust=false -t $(DOCKER_REF) .
|
||||||
|
|
|
@ -47,7 +47,9 @@ func (e *escapeStreamer) EscapeStatus() *EscapeStatus {
|
||||||
// Text tells the next streamer there is a text
|
// Text tells the next streamer there is a text
|
||||||
func (e *escapeStreamer) Text(data string) error {
|
func (e *escapeStreamer) Text(data string) error {
|
||||||
sb := &strings.Builder{}
|
sb := &strings.Builder{}
|
||||||
pos, until, next := 0, 0, 0
|
var until int
|
||||||
|
var next int
|
||||||
|
pos := 0
|
||||||
if len(data) > len(UTF8BOM) && data[:len(UTF8BOM)] == string(UTF8BOM) {
|
if len(data) > len(UTF8BOM) && data[:len(UTF8BOM)] == string(UTF8BOM) {
|
||||||
_, _ = sb.WriteString(data[:len(UTF8BOM)])
|
_, _ = sb.WriteString(data[:len(UTF8BOM)])
|
||||||
pos = len(UTF8BOM)
|
pos = len(UTF8BOM)
|
||||||
|
|
|
@ -108,7 +108,7 @@ func dumpVar(v any) template.HTML {
|
||||||
return "<pre>dumpVar: only available in dev mode</pre>"
|
return "<pre>dumpVar: only available in dev mode</pre>"
|
||||||
}
|
}
|
||||||
m, ok := dumpVarMarshalable(v, map[uintptr]bool{})
|
m, ok := dumpVarMarshalable(v, map[uintptr]bool{})
|
||||||
dumpStr := ""
|
var dumpStr string
|
||||||
jsonBytes, err := json.MarshalIndent(m, "", " ")
|
jsonBytes, err := json.MarshalIndent(m, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
dumpStr = fmt.Sprintf("dumpVar: unable to marshal %T: %v", v, err)
|
dumpStr = fmt.Sprintf("dumpVar: unable to marshal %T: %v", v, err)
|
||||||
|
|
|
@ -23,7 +23,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
func computeTimeDiffFloor(diff int64, lang translation.Locale) (int64, string) {
|
func computeTimeDiffFloor(diff int64, lang translation.Locale) (int64, string) {
|
||||||
diffStr := ""
|
var diffStr string
|
||||||
switch {
|
switch {
|
||||||
case diff <= 0:
|
case diff <= 0:
|
||||||
diff = 0
|
diff = 0
|
||||||
|
|
|
@ -72,7 +72,6 @@ func (store *localeStore) AddLocaleByIni(langName, langDesc string, source, more
|
||||||
l.idxToMsgMap[idx] = key.Value()
|
l.idxToMsgMap[idx] = key.Value()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iniFile = nil
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
|
|
||||||
// RenderMarkup renders markup text for the /markup and /markdown endpoints
|
// RenderMarkup renders markup text for the /markup and /markdown endpoints
|
||||||
func RenderMarkup(ctx *context.Context, mode, text, urlPrefix, filePath string, wiki bool) {
|
func RenderMarkup(ctx *context.Context, mode, text, urlPrefix, filePath string, wiki bool) {
|
||||||
markupType := ""
|
var markupType string
|
||||||
relativePath := ""
|
relativePath := ""
|
||||||
|
|
||||||
if len(text) == 0 {
|
if len(text) == 0 {
|
||||||
|
|
|
@ -520,7 +520,7 @@ index 0000000..6bb8f39
|
||||||
Docker Pulls
|
Docker Pulls
|
||||||
+ cut off
|
+ cut off
|
||||||
+ cut off`
|
+ cut off`
|
||||||
result, err = ParsePatch(setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, strings.NewReader(diff), "")
|
_, err = ParsePatch(setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, strings.NewReader(diff), "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("ParsePatch failed: %s", err)
|
t.Errorf("ParsePatch failed: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -536,11 +536,10 @@ index 0000000..6bb8f39
|
||||||
Docker Pulls
|
Docker Pulls
|
||||||
+ cut off
|
+ cut off
|
||||||
+ cut off`
|
+ cut off`
|
||||||
result, err = ParsePatch(setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, strings.NewReader(diff2), "")
|
_, err = ParsePatch(setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, strings.NewReader(diff2), "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("ParsePatch failed: %s", err)
|
t.Errorf("ParsePatch failed: %s", err)
|
||||||
}
|
}
|
||||||
println(result)
|
|
||||||
|
|
||||||
diff2a := `diff --git "a/A \\ B" b/A/B
|
diff2a := `diff --git "a/A \\ B" b/A/B
|
||||||
--- "a/A \\ B"
|
--- "a/A \\ B"
|
||||||
|
@ -553,11 +552,10 @@ index 0000000..6bb8f39
|
||||||
Docker Pulls
|
Docker Pulls
|
||||||
+ cut off
|
+ cut off
|
||||||
+ cut off`
|
+ cut off`
|
||||||
result, err = ParsePatch(setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, strings.NewReader(diff2a), "")
|
_, err = ParsePatch(setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, strings.NewReader(diff2a), "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("ParsePatch failed: %s", err)
|
t.Errorf("ParsePatch failed: %s", err)
|
||||||
}
|
}
|
||||||
println(result)
|
|
||||||
|
|
||||||
diff3 := `diff --git a/README.md b/README.md
|
diff3 := `diff --git a/README.md b/README.md
|
||||||
--- a/README.md
|
--- a/README.md
|
||||||
|
@ -570,11 +568,10 @@ index 0000000..6bb8f39
|
||||||
Docker Pulls
|
Docker Pulls
|
||||||
+ cut off
|
+ cut off
|
||||||
+ cut off`
|
+ cut off`
|
||||||
result, err = ParsePatch(setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, strings.NewReader(diff3), "")
|
_, err = ParsePatch(setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, strings.NewReader(diff3), "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("ParsePatch failed: %s", err)
|
t.Errorf("ParsePatch failed: %s", err)
|
||||||
}
|
}
|
||||||
println(result)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupDefaultDiff() *Diff {
|
func setupDefaultDiff() *Diff {
|
||||||
|
|
|
@ -120,7 +120,7 @@ description: ` + packageDescription
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, int64(len(content)), pb.Size)
|
assert.Equal(t, int64(len(content)), pb.Size)
|
||||||
|
|
||||||
resp = uploadFile(t, result.URL, content, http.StatusBadRequest)
|
_ = uploadFile(t, result.URL, content, http.StatusBadRequest)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Download", func(t *testing.T) {
|
t.Run("Download", func(t *testing.T) {
|
||||||
|
|
|
@ -183,18 +183,17 @@ func TestAPISearchRepo(t *testing.T) {
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
t.Run(testCase.name, func(t *testing.T) {
|
t.Run(testCase.name, func(t *testing.T) {
|
||||||
for userToLogin, expected := range testCase.expectedResults {
|
for userToLogin, expected := range testCase.expectedResults {
|
||||||
var session *TestSession
|
|
||||||
var testName string
|
var testName string
|
||||||
var userID int64
|
var userID int64
|
||||||
var token string
|
var token string
|
||||||
if userToLogin != nil && userToLogin.ID > 0 {
|
if userToLogin != nil && userToLogin.ID > 0 {
|
||||||
testName = fmt.Sprintf("LoggedUser%d", userToLogin.ID)
|
testName = fmt.Sprintf("LoggedUser%d", userToLogin.ID)
|
||||||
session = loginUser(t, userToLogin.Name)
|
session := loginUser(t, userToLogin.Name)
|
||||||
token = getTokenForLoggedInUser(t, session)
|
token = getTokenForLoggedInUser(t, session)
|
||||||
userID = userToLogin.ID
|
userID = userToLogin.ID
|
||||||
} else {
|
} else {
|
||||||
testName = "AnonymousUser"
|
testName = "AnonymousUser"
|
||||||
session = emptyTestSession(t)
|
_ = emptyTestSession(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Run(testName, func(t *testing.T) {
|
t.Run(testName, func(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user