@@ -26,17 +26,18 @@ COMMA := ,
2626XGO_VERSION := go-1.24.x
2727
2828AIR_PACKAGE ?= github.com/air-verse/air@v1
29- EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3.2.1
30- GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.7 .0
31- GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.0.2
29+ EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3
30+ GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.8 .0
31+ GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6
3232GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/
[email protected] 33- MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.6 .0
34- SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.31.0
33+ MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.7 .0
34+ SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.32.3
3535XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
3636GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1
3737GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1
3838ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/actionlint@v1
39- GOPLS_PACKAGE ?= golang.org/x/tools/
[email protected] 39+ GOPLS_PACKAGE ?= golang.org/x/tools/
[email protected] 40+ GOPLS_MODERNIZE_PACKAGE ?= golang.org/x/tools/gopls/internal/analysis/modernize/cmd/
[email protected] 4041
4142DOCKER_IMAGE ?= gitea/gitea
4243DOCKER_TAG ?= latest
@@ -80,7 +81,6 @@ ifeq ($(RACE_ENABLED),true)
8081endif
8182
8283STORED_VERSION_FILE := VERSION
83- HUGO_VERSION ?= 0.111.3
8484
8585GITHUB_REF_TYPE ?= branch
8686GITHUB_REF_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
@@ -230,7 +230,7 @@ clean: ## delete backend and integration files
230230 tests/e2e/reports/ tests/e2e/test-artifacts/ tests/e2e/test-snapshots/
231231
232232.PHONY : fmt
233- fmt : # # format the Go code
233+ fmt : # # format the Go and template code
234234 @GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE ) $(GO ) run build/code-batch-process.go gitea-fmt -w ' {file-list}'
235235 $(eval TEMPLATES := $(shell find templates -type f -name '* .tmpl') )
236236 @# strip whitespace after '{{' or '(' and before '}}' or ')' unless there is only
@@ -249,6 +249,19 @@ fmt-check: fmt
249249 exit 1; \
250250 fi
251251
252+ .PHONY : fix
253+ fix : # # apply automated fixes to Go code
254+ $(GO ) run $(GOPLS_MODERNIZE_PACKAGE ) -fix ./...
255+
256+ .PHONY : fix-check
257+ fix-check : fix
258+ @diff=$$(git diff --color=always $(GO_SOURCES ) ) ; \
259+ if [ -n " $$ diff" ]; then \
260+ echo " Please run 'make fix' and commit the result:" ; \
261+ printf " %s" " $$ {diff}" ; \
262+ exit 1; \
263+ fi
264+
252265.PHONY : $(TAGS_EVIDENCE )
253266$(TAGS_EVIDENCE ) :
254267 @mkdir -p $(MAKE_EVIDENCE_DIR )
@@ -288,7 +301,7 @@ checks: checks-frontend checks-backend ## run various consistency checks
288301checks-frontend : lockfile-check svg-check # # check frontend files
289302
290303.PHONY : checks-backend
291- checks-backend : tidy-check swagger-check fmt-check swagger-validate security-check # # check backend files
304+ checks-backend : tidy-check swagger-check fmt-check fix-check swagger-validate security-check # # check backend files
292305
293306.PHONY : lint
294307lint : lint-frontend lint-backend lint-spell # # lint everything
@@ -809,6 +822,7 @@ deps-tools: ## install tool dependencies
809822 $(GO ) install $(GOVULNCHECK_PACKAGE ) & \
810823 $(GO ) install $(ACTIONLINT_PACKAGE ) & \
811824 $(GO ) install $(GOPLS_PACKAGE ) & \
825+ $(GO ) install $(GOPLS_MODERNIZE_PACKAGE ) & \
812826 wait
813827
814828node_modules : package-lock.json
0 commit comments