From 6e67f38408c9ec61d4fee5dbcf5f1fde37e9ae60 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Wed, 12 May 2021 07:36:00 -0400 Subject: [PATCH 1/2] add format verification to contrib/format.sh run with ./contrib/format.sh verify exits with 0 if we are good, exits non-zero if we are not formatted right --- contrib/format.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/contrib/format.sh b/contrib/format.sh index d6fa22389..f83c27436 100755 --- a/contrib/format.sh +++ b/contrib/format.sh @@ -16,6 +16,9 @@ if [ $? -ne 0 ]; then fi fi -# TODO: readlink -e is a GNU-ism -cd "$(readlink -e $(dirname $0)/../)" -$binary -i $(find jni daemon llarp include pybind | grep -E '\.[hc](pp)?$') &> /dev/null +cd "$(dirname $0)/../" +if [ "$1" = "verify" ] ; then + exit $($binary --output-replacements-xml $(find jni daemon llarp include pybind | grep -E '\.[hc](pp)?$' | grep -v '\#') | grep '' | wc -l) +else + $binary -i $(find jni daemon llarp include pybind | grep -E '\.[hc](pp)?$' | grep -v '\#') &> /dev/null +fi From d066bf8576d7f120bdee7ead95e5bd0d1b60e5b4 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Wed, 12 May 2021 08:03:35 -0400 Subject: [PATCH 2/2] check in pre-push git hook so I don't lose it --- contrib/git-hook-pre-push.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 contrib/git-hook-pre-push.sh diff --git a/contrib/git-hook-pre-push.sh b/contrib/git-hook-pre-push.sh new file mode 100755 index 000000000..b4bdf8f79 --- /dev/null +++ b/contrib/git-hook-pre-push.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# +# pre-push hook for git +# this script is probably overkill for most contributors +# +# "i use this to prevent foot cannons caused by commiting broken code" +# +# ~ jeff (lokinet author and crazy person) +# +# +# to use this as a git hook do this in the root of the repo: +# +# cp contrib/git-hook-pre-push.sh .git/hooks/pre-push +# + + +set -e + +cd "$(dirname $0)/../.." +echo "check format..." +./contrib/format.sh verify +echo "format is gucci af fam" + +echo "remove old test build directory..." +rm -rf build-git-hook +mkdir build-git-hook +echo "configuring test build jizz..." +cmake -S . -B build-git-hook -DWITH_LTO=OFF -DWITH_HIVE=ON -G Ninja +echo "ensure this shit compiles..." +ninja -C build-git-hook all +echo "ensure unit tests aren't fucked..." +ninja -C build-git-hook check + +echo "we gud UmU" +echo ""