Skip to content

Commit 0db1de0

Browse files
committed
split out into make fix
1 parent 9991d63 commit 0db1de0

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

Makefile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,7 @@ clean: ## delete backend and integration files
231231
tests/e2e/reports/ tests/e2e/test-artifacts/ tests/e2e/test-snapshots/
232232

233233
.PHONY: fmt
234-
fmt: ## format and fix the Go code
235-
@$(GO) run $(GOPLS_MODERNIZE_PACKAGE) -fix ./...
234+
fmt: ## format the Go and template code
236235
@GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE) $(GO) run build/code-batch-process.go gitea-fmt -w '{file-list}'
237236
$(eval TEMPLATES := $(shell find templates -type f -name '*.tmpl'))
238237
@# strip whitespace after '{{' or '(' and before '}}' or ')' unless there is only
@@ -251,6 +250,19 @@ fmt-check: fmt
251250
exit 1; \
252251
fi
253252

253+
.PHONY: fix
254+
fix: ## apply code 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+
254266
.PHONY: $(TAGS_EVIDENCE)
255267
$(TAGS_EVIDENCE):
256268
@mkdir -p $(MAKE_EVIDENCE_DIR)
@@ -290,7 +302,7 @@ checks: checks-frontend checks-backend ## run various consistency checks
290302
checks-frontend: lockfile-check svg-check ## check frontend files
291303

292304
.PHONY: checks-backend
293-
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
294306

295307
.PHONY: lint
296308
lint: lint-frontend lint-backend lint-spell ## lint everything

0 commit comments

Comments
 (0)