@@ -73,6 +73,7 @@ EXTRA_GOFLAGS ?=
7373MAKE_VERSION := $(shell "$(MAKE ) " -v | cat | head -n 1)
7474MAKE_EVIDENCE_DIR := .make_evidence
7575
76+ GOTESTFLAGS ?=
7677ifeq ($(RACE_ENABLED ) ,true)
7778 GOFLAGS += -race
7879 GOTESTFLAGS += -race
@@ -165,10 +166,8 @@ ifdef DEPS_PLAYWRIGHT
165166endif
166167
167168SWAGGER_SPEC := templates/swagger/v1_json.tmpl
168- SWAGGER_SPEC_S_TMPL := s|"basePath": *"/api/v1"|"basePath": "{{AppSubUrl \| JSEscape}}/api/v1"|g
169- SWAGGER_SPEC_S_JSON := s|"basePath": *"{{AppSubUrl \| JSEscape}}/api/v1"|"basePath": "/api/v1"|g
169+ SWAGGER_SPEC_INPUT := templates/swagger/v1_input.json
170170SWAGGER_EXCLUDE := code.gitea.io/sdk
171- SWAGGER_NEWLINE_COMMAND := -e '$$a\'
172171
173172TEST_MYSQL_HOST ?= mysql:3306
174173TEST_MYSQL_DBNAME ?= testgitea
@@ -271,10 +270,8 @@ endif
271270.PHONY : generate-swagger
272271generate-swagger : $(SWAGGER_SPEC ) # # generate the swagger spec from code comments
273272
274- $(SWAGGER_SPEC ) : $(GO_SOURCES_NO_BINDATA )
275- $(GO ) run $(SWAGGER_PACKAGE ) generate spec -x " $( SWAGGER_EXCLUDE) " -o ' ./$(SWAGGER_SPEC)'
276- $(SED_INPLACE ) ' $(SWAGGER_SPEC_S_TMPL)' ' ./$(SWAGGER_SPEC)'
277- $(SED_INPLACE ) $(SWAGGER_NEWLINE_COMMAND ) ' ./$(SWAGGER_SPEC)'
273+ $(SWAGGER_SPEC ) : $(GO_SOURCES_NO_BINDATA ) $(SWAGGER_SPEC_INPUT )
274+ $(GO ) run $(SWAGGER_PACKAGE ) generate spec --exclude " $( SWAGGER_EXCLUDE) " --input " $( SWAGGER_SPEC_INPUT) " --output ' ./$(SWAGGER_SPEC)'
278275
279276.PHONY : swagger-check
280277swagger-check : generate-swagger
@@ -287,9 +284,11 @@ swagger-check: generate-swagger
287284
288285.PHONY : swagger-validate
289286swagger-validate : # # check if the swagger spec is valid
290- $(SED_INPLACE ) ' $(SWAGGER_SPEC_S_JSON)' ' ./$(SWAGGER_SPEC)'
287+ @# swagger "validate" requires that the "basePath" must start with a slash, but we are using Golang template "{{...}}"
288+ @$(SED_INPLACE ) -E -e ' s|"basePath":( *)"(.*)"|"basePath":\1"/\2"|g' ' ./$(SWAGGER_SPEC)' # add a prefix slash to basePath
289+ @# FIXME: there are some warnings
291290 $(GO ) run $(SWAGGER_PACKAGE ) validate ' ./$(SWAGGER_SPEC)'
292- $(SED_INPLACE ) ' $(SWAGGER_SPEC_S_TMPL) ' ' ./$(SWAGGER_SPEC)'
291+ @ $(SED_INPLACE ) -E -e ' s|"basePath":( *)"/(.*)"|"basePath":\1"\2"|g ' ' ./$(SWAGGER_SPEC)' # remove the prefix slash from basePath
293292
294293.PHONY : checks
295294checks : checks-frontend checks-backend # # run various consistency checks
@@ -313,10 +312,10 @@ lint-frontend: lint-js lint-css ## lint frontend files
313312lint-frontend-fix : lint-js-fix lint-css-fix # # lint frontend files and fix issues
314313
315314.PHONY : lint-backend
316- lint-backend : lint-go lint-go-vet lint-go-gopls lint-editorconfig # # lint backend files
315+ lint-backend : lint-go lint-go-gitea- vet lint-go-gopls lint-editorconfig # # lint backend files
317316
318317.PHONY : lint-backend-fix
319- lint-backend-fix : lint-go-fix lint-go-vet lint-editorconfig # # lint backend files and fix issues
318+ lint-backend-fix : lint-go-fix lint-go-gitea- vet lint-editorconfig # # lint backend files and fix issues
320319
321320.PHONY : lint-js
322321lint-js : node_modules # # lint js files
@@ -367,9 +366,9 @@ lint-go-windows:
367366 @GOOS= GOARCH= $(GO ) install $(GOLANGCI_LINT_PACKAGE )
368367 golangci-lint run
369368
370- .PHONY : lint-go-vet
371- lint-go-vet : # # lint go files with vet
372- @echo " Running go vet..."
369+ .PHONY : lint-go-gitea- vet
370+ lint-go-gitea- vet : # # lint go files with gitea- vet
371+ @echo " Running gitea- vet..."
373372 @GOOS= GOARCH= $(GO ) build code.gitea.io/gitea-vet
374373 @$(GO ) vet -vettool=gitea-vet ./...
375374
@@ -380,6 +379,7 @@ lint-go-gopls: ## lint go files with gopls
380379
381380.PHONY : lint-editorconfig
382381lint-editorconfig :
382+ @echo " Running editorconfig check..."
383383 @$(GO ) run $(EDITORCONFIG_CHECKER_PACKAGE ) $(EDITORCONFIG_FILES )
384384
385385.PHONY : lint-actions
@@ -471,7 +471,9 @@ tidy-check: tidy
471471go-licenses : $(GO_LICENSE_FILE ) # # regenerate go licenses
472472
473473$(GO_LICENSE_FILE ) : go.mod go.sum
474- -$(GO ) run $(GO_LICENSES_PACKAGE ) save . --force --save_path=$(GO_LICENSE_TMP_DIR ) 2> /dev/null
474+ @rm -rf $(GO_LICENSE_FILE )
475+ $(GO ) install $(GO_LICENSES_PACKAGE )
476+ -GOOS=linux CGO_ENABLED=1 go-licenses save . --force --save_path=$(GO_LICENSE_TMP_DIR ) 2> /dev/null
475477 $(GO ) run build/generate-go-licenses.go $(GO_LICENSE_TMP_DIR ) $(GO_LICENSE_FILE )
476478 @rm -rf $(GO_LICENSE_TMP_DIR )
477479
@@ -904,10 +906,6 @@ update-translations:
904906 mv ./translations/* .ini ./options/locale/
905907 rmdir ./translations
906908
907- .PHONY : generate-license
908- generate-license : # # update license files
909- $(GO ) run build/generate-licenses.go
910-
911909.PHONY : generate-gitignore
912910generate-gitignore : # # update gitignore files
913911 $(GO ) run build/generate-gitignores.go
0 commit comments