build: add check for code formatting

Let's avoid pushing unformatted code.

Signed-off-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
Robin Jarry 2021-12-11 22:03:25 +01:00
parent 0ef72dd575
commit 6857ab7a71
2 changed files with 15 additions and 0 deletions

View file

@ -5,6 +5,9 @@ packages:
sources: sources:
- https://git.sr.ht/~rjarry/aerc - https://git.sr.ht/~rjarry/aerc
tasks: tasks:
- checkfmt: |
cd aerc
make checkfmt
- build: | - build: |
cd aerc cd aerc
make make

View file

@ -28,6 +28,18 @@ aerc: $(GOSRC)
-X main.Version=$(VERSION)" \ -X main.Version=$(VERSION)" \
-o $@ -o $@
.PHONY: fmt
fmt:
gofmt -w .
.PHONY: checkfmt
checkfmt:
@if [ `gofmt -l . | wc -l` -ne 0 ]; then \
gofmt -d .; \
echo "ERROR: source files need reformatting with gofmt"; \
exit 1; \
fi
aerc.conf: config/aerc.conf.in aerc.conf: config/aerc.conf.in
sed -e 's:@SHAREDIR@:$(SHAREDIR):g' > $@ < config/aerc.conf.in sed -e 's:@SHAREDIR@:$(SHAREDIR):g' > $@ < config/aerc.conf.in