@@ -28,7 +28,7 @@ XGO_VERSION := go-1.24.x
2828AIR_PACKAGE  ?= github.com/air-verse/air@v1
2929EDITORCONFIG_CHECKER_PACKAGE  ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/
[email protected] 3030GOFUMPT_PACKAGE  ?= mvdan.cc/
[email protected] 31- GOLANGCI_LINT_PACKAGE  ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.63.4 
31+ GOLANGCI_LINT_PACKAGE  ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.5 
3232GXZ_PACKAGE  ?= github.com/ulikunitz/xz/cmd/
[email protected] 3333MISSPELL_PACKAGE  ?= github.com/golangci/misspell/cmd/
[email protected] 3434SWAGGER_PACKAGE  ?= github.com/go-swagger/go-swagger/cmd/
[email protected] @@ -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
@@ -255,7 +254,7 @@ fmt-check: fmt
255254	@diff=$$(git diff --color=always $(GO_SOURCES )  templates $(WEB_DIRS )  ) ;  \ 
256255	if  [ -n  " $$ diff" ;  then  \
257256	  echo  " Please run 'make fmt' and commit the result:" ;  \ 
258- 	  echo  " $$ {diff}" ;  \ 
257+ 	  printf   " %s " " $$ {diff}" ;  \ 
259258	  exit  1;  \ 
260259	fi 
261260
@@ -271,25 +270,25 @@ 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) " ' ./$(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) " " $( SWAGGER_SPEC_INPUT) " ' ./$(SWAGGER_SPEC)' 
278275
279276.PHONY : swagger-check
280277swagger-check : generate-swagger
281278	@diff=$$(git diff --color=always '$(SWAGGER_SPEC ) ' ) ;  \ 
282279	if  [ -n  " $$ diff" ;  then  \
283280		echo  " Please run 'make generate-swagger' and commit the result:" ;  \ 
284- 		echo  " $$ {diff}" ;  \ 
281+ 		printf   " %s " " $$ {diff}" ;  \ 
285282		exit  1;  \ 
286283	fi 
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
@@ -426,7 +426,7 @@ test-check:
426426	@diff=$$(git status -s ) ;  \ 
427427	if  [ -n  " $$ diff" ;  then  \
428428		echo  " make test-backend has changed files in the source tree:" ;  \ 
429- 		echo  " $$ {diff}" ;  \ 
429+ 		printf   " %s " " $$ {diff}" ;  \ 
430430		echo  " You should change the tests to create these files in a temporary directory." ;  \ 
431431		echo  " Do not simply add these files to .gitignore" ;  \ 
432432		exit  1;  \ 
@@ -463,15 +463,17 @@ tidy-check: tidy
463463	@diff=$$(git diff --color=always go.mod go.sum $(GO_LICENSE_FILE )  ) ;  \ 
464464	if  [ -n  " $$ diff" ;  then  \
465465		echo  " Please run 'make tidy' and commit the result:" ;  \ 
466- 		echo  " $$ {diff}" ;  \ 
466+ 		printf   " %s " " $$ {diff}" ;  \ 
467467		exit  1;  \ 
468468	fi 
469469
470470.PHONY : go-licenses
471471go-licenses : $(GO_LICENSE_FILE )  # # regenerate go licenses
472472
473473$(GO_LICENSE_FILE ) 
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
@@ -879,7 +881,7 @@ svg-check: svg
879881	@diff=$$(git diff --color=always --cached $(SVG_DEST_DIR )  ) ;  \ 
880882	if  [ -n  " $$ diff" ;  then  \
881883		echo  " Please run 'make svg' and 'git add $( SVG_DEST_DIR) " ;  \ 
882- 		echo  " $$ {diff}" ;  \ 
884+ 		printf   " %s " " $$ {diff}" ;  \ 
883885		exit  1;  \ 
884886	fi 
885887
@@ -890,7 +892,7 @@ lockfile-check:
890892	if  [ -n  " $$ diff" ;  then  \
891893		echo  " package-lock.json is inconsistent with package.json" ;  \ 
892894		echo  " Please run 'npm install --package-lock-only' and commit the result:" ;  \ 
893- 		echo  " $$ {diff}" ;  \ 
895+ 		printf   " %s " " $$ {diff}" ;  \ 
894896		exit  1;  \ 
895897	fi 
896898
0 commit comments