@@ -36,7 +36,8 @@ XGO_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
@@ -120,7 +121,7 @@ WEBPACK_CONFIGS := webpack.config.js tailwind.config.js
120121WEBPACK_DEST := public/assets/js/index.js public/assets/css/index.css
121122WEBPACK_DEST_ENTRIES := public/assets/js public/assets/css public/assets/fonts
122123
123- BINDATA_DEST := modules/public/bindata.dat modules/options/bindata.dat modules/templates/bindata.dat
124+ BINDATA_DEST_WILDCARD := modules/migration/bindata.* modules/ public/bindata.* modules/options/bindata.* modules/templates/bindata.*
124125
125126GENERATED_GO_DEST := modules/charset/invisible_gen.go modules/charset/ambiguous_gen.go
126127
@@ -219,7 +220,7 @@ clean-all: clean ## delete backend, frontend and integration files
219220
220221.PHONY : clean
221222clean : # # delete backend and integration files
222- rm -rf $(EXECUTABLE ) $(DIST ) $(BINDATA_DEST ) \
223+ rm -rf $(EXECUTABLE ) $(DIST ) $(BINDATA_DEST_WILDCARD ) \
223224 integrations* .test \
224225 e2e* .test \
225226 tests/integration/gitea-integration-* \
@@ -230,7 +231,7 @@ clean: ## delete backend and integration files
230231 tests/e2e/reports/ tests/e2e/test-artifacts/ tests/e2e/test-snapshots/
231232
232233.PHONY : fmt
233- fmt : # # format the Go code
234+ fmt : # # format the Go and template code
234235 @GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE ) $(GO ) run build/code-batch-process.go gitea-fmt -w ' {file-list}'
235236 $(eval TEMPLATES := $(shell find templates -type f -name '* .tmpl') )
236237 @# strip whitespace after '{{' or '(' and before '}}' or ')' unless there is only
@@ -249,6 +250,19 @@ fmt-check: fmt
249250 exit 1; \
250251 fi
251252
253+ .PHONY : fix
254+ fix : # # apply automated fixes to Go code
255+ $(GO ) run $(GOPLS_MODERNIZE_PACKAGE ) -fix ./...
256+
257+ .PHONY : fix-check
258+ fix-check : fix
259+ @diff=$$(git diff --color=always $(GO_SOURCES ) ) ; \
260+ if [ -n " $$ diff" ]; then \
261+ echo " Please run 'make fix' and commit the result:" ; \
262+ printf " %s" " $$ {diff}" ; \
263+ exit 1; \
264+ fi
265+
252266.PHONY : $(TAGS_EVIDENCE )
253267$(TAGS_EVIDENCE ) :
254268 @mkdir -p $(MAKE_EVIDENCE_DIR )
@@ -288,7 +302,7 @@ checks: checks-frontend checks-backend ## run various consistency checks
288302checks-frontend : lockfile-check svg-check # # check frontend files
289303
290304.PHONY : checks-backend
291- checks-backend : tidy-check swagger-check fmt-check swagger-validate security-check # # check backend files
305+ checks-backend : tidy-check swagger-check fmt-check fix-check swagger-validate security-check # # check backend files
292306
293307.PHONY : lint
294308lint : lint-frontend lint-backend lint-spell # # lint everything
@@ -809,6 +823,7 @@ deps-tools: ## install tool dependencies
809823 $(GO ) install $(GOVULNCHECK_PACKAGE ) & \
810824 $(GO ) install $(ACTIONLINT_PACKAGE ) & \
811825 $(GO ) install $(GOPLS_PACKAGE ) & \
826+ $(GO ) install $(GOPLS_MODERNIZE_PACKAGE ) & \
812827 wait
813828
814829node_modules : package-lock.json
0 commit comments