aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorsilverwind2022-08-25 23:55:52 +0200
committerGitHub2022-08-25 17:55:52 -0400
commit6c4688e1b1ddb68de192af7f83b06de27baae85e (patch)
tree554b4e7d97c843590031aab058ba1c66474c405f /Makefile
parent27ac65a124f34ec3ed5f34aeb576f918ae1c70b1 (diff)
Add whitespace removal inside template curly brackes (#20853)
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile12
1 files changed, 10 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 44e245d22..f7e91c05a 100644
--- a/Makefile
+++ b/Makefile
@@ -242,8 +242,10 @@ clean:
.PHONY: fmt
fmt:
- @echo "Running gitea-fmt (with gofumpt)..."
@MISSPELL_PACKAGE=$(MISSPELL_PACKAGE) GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE) $(GO) run build/code-batch-process.go gitea-fmt -w '{file-list}'
+ $(eval TEMPLATES := $(wildcard templates/**/*.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: vet
vet:
@@ -288,13 +290,19 @@ errcheck:
.PHONY: fmt-check
fmt-check:
- # get all go files and run gitea-fmt (with gofmt) on them
+ @# 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