loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add `interface{}` to `any` replacement to `make fmt`, exclude `*.pb.go` (#30461)

Since https://github.com/go-gitea/gitea/pull/25686, a few `interface{}`
have sneaked into the codebase. Add this replacement to `make fmt` to
prevent this from happening again.

Ideally a linter would do this, but I haven't found any suitable.

(cherry picked from commit c77e8140bc2ac6521dbebfb77613dce2648bfcb8)

Conflicts:
- .gitattributes
Trivial conflict resolved by picking our choice of language
for `*.tmpl` files.

authored by

silverwind and committed by
Gergely Nagy
bf933f5c 9987b756

+7 -15
+1
.gitattributes
··· 1 1 * text=auto eol=lf 2 2 *.tmpl linguist-language=go-html-template 3 + *.pb.go linguist-generated 3 4 /assets/*.json linguist-generated 4 5 /public/assets/img/svg/*.svg linguist-generated 5 6 /templates/swagger/v1_json.tmpl linguist-generated
+1 -1
Makefile
··· 312 312 313 313 .PHONY: fmt 314 314 fmt: 315 - GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE) $(GO) run build/code-batch-process.go gitea-fmt -w '{file-list}' 315 + @GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE) $(GO) run build/code-batch-process.go gitea-fmt -w '{file-list}' 316 316 $(eval TEMPLATES := $(shell find templates -type f -name '*.tmpl')) 317 317 @# strip whitespace after '{{' or '(' and before '}}' or ')' unless there is only 318 318 @# whitespace before it
+3 -12
build/code-batch-process.go
··· 69 69 co.includePatterns = append(co.includePatterns, regexp.MustCompile(`.*\.go$`)) 70 70 71 71 co.excludePatterns = append(co.excludePatterns, regexp.MustCompile(`.*\bbindata\.go$`)) 72 + co.excludePatterns = append(co.excludePatterns, regexp.MustCompile(`\.pb\.go$`)) 72 73 co.excludePatterns = append(co.excludePatterns, regexp.MustCompile(`tests/gitea-repositories-meta`)) 73 74 co.excludePatterns = append(co.excludePatterns, regexp.MustCompile(`tests/integration/migration-test`)) 74 75 co.excludePatterns = append(co.excludePatterns, regexp.MustCompile(`modules/git/tests`)) ··· 203 204 `, "file-batch-exec") 204 205 } 205 206 206 - func getGoVersion() string { 207 - goModFile, err := os.ReadFile("go.mod") 208 - if err != nil { 209 - log.Fatalf(`Faild to read "go.mod": %v`, err) 210 - os.Exit(1) 211 - } 212 - goModVersionRegex := regexp.MustCompile(`go \d+\.\d+`) 213 - goModVersionLine := goModVersionRegex.Find(goModFile) 214 - return string(goModVersionLine[3:]) 215 - } 216 - 217 207 func newFileCollectorFromMainOptions(mainOptions map[string]string) (fc *fileCollector, err error) { 218 208 fileFilter := mainOptions["file-filter"] 219 209 if fileFilter == "" { ··· 278 268 log.Print("the -d option is not supported by gitea-fmt") 279 269 } 280 270 cmdErrors = append(cmdErrors, giteaFormatGoImports(files, containsString(subArgs, "-w"))) 281 - cmdErrors = append(cmdErrors, passThroughCmd("go", append([]string{"run", os.Getenv("GOFUMPT_PACKAGE"), "-extra", "-lang", getGoVersion()}, substArgs...))) 271 + cmdErrors = append(cmdErrors, passThroughCmd("gofmt", append([]string{"-w", "-r", "interface{} -> any"}, substArgs...))) 272 + cmdErrors = append(cmdErrors, passThroughCmd("go", append([]string{"run", os.Getenv("GOFUMPT_PACKAGE"), "-extra"}, substArgs...))) 282 273 default: 283 274 log.Fatalf("unknown cmd: %s %v", subCmd, subArgs) 284 275 }
+1 -1
modules/optional/serialization.go
··· 35 35 return nil 36 36 } 37 37 38 - func (o Option[T]) MarshalYAML() (interface{}, error) { 38 + func (o Option[T]) MarshalYAML() (any, error) { 39 39 if !o.Has() { 40 40 return nil, nil 41 41 }
+1 -1
services/actions/auth_test.go
··· 20 20 assert.Nil(t, err) 21 21 assert.NotEqual(t, "", token) 22 22 claims := jwt.MapClaims{} 23 - _, err = jwt.ParseWithClaims(token, claims, func(t *jwt.Token) (interface{}, error) { 23 + _, err = jwt.ParseWithClaims(token, claims, func(t *jwt.Token) (any, error) { 24 24 return setting.GetGeneralTokenSigningSecret(), nil 25 25 }) 26 26 assert.Nil(t, err)