From 27935510402a89f1033e99c6789c453723f6052a Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Sat, 2 Nov 2019 11:59:04 +0100 Subject: [PATCH] add dockerfile for checking formatting --- .docker/Dockerfile.check-format | 10 ++++++++++ tools/check-format.sh | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 .docker/Dockerfile.check-format create mode 100755 tools/check-format.sh diff --git a/.docker/Dockerfile.check-format b/.docker/Dockerfile.check-format new file mode 100644 index 000000000..7716ec220 --- /dev/null +++ b/.docker/Dockerfile.check-format @@ -0,0 +1,10 @@ +FROM ubuntu:19.10 + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get -y install clang-format + +WORKDIR /build + +CMD ["/bin/sh"] +ENTRYPOINT ["./tools/docker/build.sh"] diff --git a/tools/check-format.sh b/tools/check-format.sh new file mode 100755 index 000000000..1af2b596a --- /dev/null +++ b/tools/check-format.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -eu + +fail="0" + +while read -r file; do + if ! diff -u <(cat "$file") <(clang-format "$file"); then + echo "$file differs!!!!!!!" + fail="1" + fi +done < <(find src/ \( -iname "*.hpp" -o -iname "*.cpp" \)) + +if [ "$fail" = "1" ]; then + echo "At least one file is poorly formatted - check the output above" + exit 1 +fi + +echo "Everything seems to be formatted properly! Good job"