summaryrefslogtreecommitdiff
path: root/Biz/Ide/hooks/pre-push.bash
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2023-10-10 13:15:59 -0400
committerBen Sima <ben@bsima.me>2023-10-10 13:15:59 -0400
commit904de577261e7024373e7a42fd763184764238f9 (patch)
tree563e4968eab568466ae3e7a1c747dd24a77986c0 /Biz/Ide/hooks/pre-push.bash
parent6107f8178e26ada67e5d5ec60501e24528b3db56 (diff)
Don't swallow namespace-parsing errors
Previously, if there was a problem with the inputs and bild failed to determine the namespace, 'fromPath' would return 'Nothing' and then 'catMaybes' would drop the error-causing input altogether. In the one time that I had a bad input, this made debugging incredibly difficult. It's always a bad idea to swallow errors silently, so instead lets just kill the program if we have bad inputs.
Diffstat (limited to 'Biz/Ide/hooks/pre-push.bash')
-rwxr-xr-xBiz/Ide/hooks/pre-push.bash58
1 files changed, 58 insertions, 0 deletions
diff --git a/Biz/Ide/hooks/pre-push.bash b/Biz/Ide/hooks/pre-push.bash
new file mode 100755
index 0000000..0c313cb
--- /dev/null
+++ b/Biz/Ide/hooks/pre-push.bash
@@ -0,0 +1,58 @@
+#!/usr/bin/env bash
+#
+# a simple ci that saves its results in a git note, formatted according to
+# RFC-2822, more or less.
+#
+##
+ set -uo pipefail
+ [[ -n $(git status -s) ]] && { echo fail: dirty worktree; exit 1; }
+##
+ at=$(date -R)
+ user=$(git config --get user.name)
+ mail=$(git config --get user.email)
+##
+ while read local_ref local_sha remote_ref remote_sha
+ do
+ if [[ $local_ref =~ notes ]]; then
+ exit 0
+ fi
+ commit=$(git notes --ref=ci show $local_ref || true)
+ if [[ -n "$commit" ]]
+ then
+ lint_ok=$()
+ if grep -q "Lint-is: good" <<< $commit
+ then
+ exit 0
+ fi
+ if grep -q "Test-is: good" <<< $commit
+ then
+ exit 0
+ fi
+ fi
+ ##
+ if lint "${CODEROOT:?}"/**/*
+ then
+ lint_result="good"
+ else
+ lint_result="fail"
+ exit 1
+ fi
+ ##
+ if bild --test "${CODEROOT:?}"/**/*
+ then
+ test_result="good"
+ else
+ test_result="fail"
+ exit 1
+ fi
+ ##
+ read -r -d '' note <<EOF
+Lint-is: $lint_result
+Test-is: $test_result
+Test-by: $user <$mail>
+Test-at: $at
+EOF
+ ##
+ git notes --ref=ci append -m "$note"
+ done
+##