diff options
author | silverwind | 2022-10-16 10:11:17 +0200 |
---|---|---|
committer | GitHub | 2022-10-16 16:11:17 +0800 |
commit | 0647df3e831c320436d42a5572a6ec6a9d23d8b1 (patch) | |
tree | fde6e41c5e353dc0fe535fa30875f00b4462a42c /Makefile | |
parent | 9fb251fb6fa2bb857bb8f5ae27f06c9d597bc1eb (diff) |
Simplify fmt-check (#21458)
`fmt-check` now simply does `fmt` before and relies on `git diff` like
other checks like 'tidy-check' already do, so we can remove the argument
in the tool that handles printing changed files.
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 34 |
1 files changed, 16 insertions, 18 deletions
@@ -130,6 +130,7 @@ TEST_TAGS ?= sqlite sqlite_unlock_notify TAR_EXCLUDES := .git data indexers queues log node_modules $(EXECUTABLE) $(FOMANTIC_WORK_DIR)/node_modules $(DIST) $(MAKE_EVIDENCE_DIR) $(AIR_TMP_DIR) $(GO_LICENSE_TMP_DIR) GO_DIRS := cmd tests models modules routers build services tools +WEB_DIRS := web_src/js web_src/less GO_SOURCES := $(wildcard *.go) GO_SOURCES += $(shell find $(GO_DIRS) -type f -name "*.go" -not -path modules/options/bindata.go -not -path modules/public/bindata.go -not -path modules/templates/bindata.go) @@ -263,11 +264,24 @@ clean: .PHONY: fmt fmt: - @MISSPELL_PACKAGE=$(MISSPELL_PACKAGE) GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE) $(GO) run build/code-batch-process.go gitea-fmt -w '{file-list}' + GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE) $(GO) run build/code-batch-process.go gitea-fmt -w '{file-list}' $(eval TEMPLATES := $(shell find templates -type f -name '*.tmpl')) @# strip whitespace after '{{' and before `}}` unless there is only whitespace before it @$(SED_INPLACE) -e 's/{{[ ]\{1,\}/{{/g' -e '/^[ ]\{1,\}}}/! s/[ ]\{1,\}}}/}}/g' $(TEMPLATES) +.PHONY: fmt-check +fmt-check: fmt + @diff=$$(git diff $(GO_SOURCES) templates $(WEB_DIRS)); \ + if [ -n "$$diff" ]; then \ + echo "Please run 'make fmt' and commit the result:"; \ + echo "$${diff}"; \ + exit 1; \ + fi + +.PHONY: misspell-check +misspell-check: + go run $(MISSPELL_PACKAGE) -error -i unknwon $(GO_DIRS) $(WEB_DIRS) + .PHONY: vet vet: @echo "Running go vet..." @@ -311,22 +325,6 @@ errcheck: @echo "Running errcheck..." $(GO) run $(ERRCHECK_PACKAGE) $(GO_PACKAGES) -.PHONY: fmt-check -fmt-check: - @# get all go files and run gitea-fmt (with gofmt) on them - @diff=$$(MISSPELL_PACKAGE=$(MISSPELL_PACKAGE) GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE) $(GO) run build/code-batch-process.go gitea-fmt -l '{file-list}'); \ - if [ -n "$$diff" ]; then \ - echo "Please run 'make fmt' and commit the result:"; \ - echo "$${diff}"; \ - exit 1; \ - fi - @diff2=$$(git diff templates); \ - if [ -n "$$diff2" ]; then \ - echo "Please run 'make fmt' and commit the result:"; \ - echo "$${diff2}"; \ - exit 1; \ - fi - .PHONY: checks checks: checks-frontend checks-backend @@ -334,7 +332,7 @@ checks: checks-frontend checks-backend checks-frontend: lockfile-check svg-check .PHONY: checks-backend -checks-backend: tidy-check swagger-check swagger-validate +checks-backend: tidy-check swagger-check fmt-check misspell-check swagger-validate .PHONY: lint lint: lint-frontend lint-backend |