From 6857ab7a71d118b6ed85087e0977b9037c1540a2 Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Sat, 11 Dec 2021 22:03:25 +0100 Subject: [PATCH] build: add check for code formatting Let's avoid pushing unformatted code. Signed-off-by: Robin Jarry --- .build.yml | 3 +++ Makefile | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/.build.yml b/.build.yml index 49fb917..fa9a49f 100644 --- a/.build.yml +++ b/.build.yml @@ -5,6 +5,9 @@ packages: sources: - https://git.sr.ht/~rjarry/aerc tasks: +- checkfmt: | + cd aerc + make checkfmt - build: | cd aerc make diff --git a/Makefile b/Makefile index c481976..d352fbe 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,18 @@ aerc: $(GOSRC) -X main.Version=$(VERSION)" \ -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 sed -e 's:@SHAREDIR@:$(SHAREDIR):g' > $@ < config/aerc.conf.in