From 99e114f5c598ce6321c81bbe41e212877a3c375c Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Mon, 1 Apr 2024 16:35:15 -0400 Subject: Make bild exception for git hooks Apparently git hooks don't get called if they have a file extention, so these weren't getting called at all since commit 904de577261e7024373e7a42fd763184764238f9. So this renames them back to the extension-less versions, and adds an exception in bild for files in the core.hooksPath directory. Unfortunately this means Lint.hs will silently ignore these files, but I guess that's okay for now. --- Biz/Ide/hooks/commit-msg | 2 ++ Biz/Ide/hooks/commit-msg.sh | 2 -- Biz/Ide/hooks/post-applypatch | 6 ++++ Biz/Ide/hooks/post-applypatch.sh | 6 ---- Biz/Ide/hooks/post-checkout | 19 ++++++++++++ Biz/Ide/hooks/post-checkout.sh | 19 ------------ Biz/Ide/hooks/post-commit | 6 ++++ Biz/Ide/hooks/post-commit.sh | 6 ---- Biz/Ide/hooks/post-merge | 6 ++++ Biz/Ide/hooks/post-merge.sh | 6 ---- Biz/Ide/hooks/post-rewrite | 6 ++++ Biz/Ide/hooks/post-rewrite.sh | 6 ---- Biz/Ide/hooks/pre-auto-gc | 6 ++++ Biz/Ide/hooks/pre-auto-gc.sh | 6 ---- Biz/Ide/hooks/pre-commit | 21 +++++++++++++ Biz/Ide/hooks/pre-commit.sh | 21 ------------- Biz/Ide/hooks/pre-push | 54 ++++++++++++++++++++++++++++++++++ Biz/Ide/hooks/pre-push.sh | 54 ---------------------------------- Biz/Ide/hooks/reference-transaction | 12 ++++++++ Biz/Ide/hooks/reference-transaction.sh | 12 -------- 20 files changed, 138 insertions(+), 138 deletions(-) create mode 100755 Biz/Ide/hooks/commit-msg delete mode 100755 Biz/Ide/hooks/commit-msg.sh create mode 100755 Biz/Ide/hooks/post-applypatch delete mode 100755 Biz/Ide/hooks/post-applypatch.sh create mode 100755 Biz/Ide/hooks/post-checkout delete mode 100755 Biz/Ide/hooks/post-checkout.sh create mode 100755 Biz/Ide/hooks/post-commit delete mode 100755 Biz/Ide/hooks/post-commit.sh create mode 100755 Biz/Ide/hooks/post-merge delete mode 100755 Biz/Ide/hooks/post-merge.sh create mode 100755 Biz/Ide/hooks/post-rewrite delete mode 100755 Biz/Ide/hooks/post-rewrite.sh create mode 100755 Biz/Ide/hooks/pre-auto-gc delete mode 100755 Biz/Ide/hooks/pre-auto-gc.sh create mode 100755 Biz/Ide/hooks/pre-commit delete mode 100755 Biz/Ide/hooks/pre-commit.sh create mode 100755 Biz/Ide/hooks/pre-push delete mode 100755 Biz/Ide/hooks/pre-push.sh create mode 100755 Biz/Ide/hooks/reference-transaction delete mode 100755 Biz/Ide/hooks/reference-transaction.sh (limited to 'Biz/Ide') diff --git a/Biz/Ide/hooks/commit-msg b/Biz/Ide/hooks/commit-msg new file mode 100755 index 0000000..64e400d --- /dev/null +++ b/Biz/Ide/hooks/commit-msg @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +gitlint --ignore-stdin --staged --msg-filename "$1" run-hook diff --git a/Biz/Ide/hooks/commit-msg.sh b/Biz/Ide/hooks/commit-msg.sh deleted file mode 100755 index 64e400d..0000000 --- a/Biz/Ide/hooks/commit-msg.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -gitlint --ignore-stdin --staged --msg-filename "$1" run-hook diff --git a/Biz/Ide/hooks/post-applypatch b/Biz/Ide/hooks/post-applypatch new file mode 100755 index 0000000..5071dc5 --- /dev/null +++ b/Biz/Ide/hooks/post-applypatch @@ -0,0 +1,6 @@ +#!/bin/sh +## START BRANCHLESS CONFIG + +git branchless hook post-applypatch "$@" + +## END BRANCHLESS CONFIG diff --git a/Biz/Ide/hooks/post-applypatch.sh b/Biz/Ide/hooks/post-applypatch.sh deleted file mode 100755 index 5071dc5..0000000 --- a/Biz/Ide/hooks/post-applypatch.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -## START BRANCHLESS CONFIG - -git branchless hook post-applypatch "$@" - -## END BRANCHLESS CONFIG diff --git a/Biz/Ide/hooks/post-checkout b/Biz/Ide/hooks/post-checkout new file mode 100755 index 0000000..e4a0d67 --- /dev/null +++ b/Biz/Ide/hooks/post-checkout @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -e +mktags=${CODEROOT:?}/Biz/Ide/mktags.sh +old=$1 +new=$2 +# filter out only the changed haskell files +mapfile -t changed < <(git diff --diff-filter=d --name-only "$old" "$new" -- '*.hs') +if [[ ! -r tags ]] || [[ ! -r TAGS ]] +then + $mktags "$CODEROOT"/**/* +elif [[ ${#changed[@]} -gt 0 ]] +then + $mktags "${changed[@]}" +fi +direnv reload +## START BRANCHLESS CONFIG + +git branchless hook post-checkout "$@" +## END BRANCHLESS CONFIG diff --git a/Biz/Ide/hooks/post-checkout.sh b/Biz/Ide/hooks/post-checkout.sh deleted file mode 100755 index e4a0d67..0000000 --- a/Biz/Ide/hooks/post-checkout.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -set -e -mktags=${CODEROOT:?}/Biz/Ide/mktags.sh -old=$1 -new=$2 -# filter out only the changed haskell files -mapfile -t changed < <(git diff --diff-filter=d --name-only "$old" "$new" -- '*.hs') -if [[ ! -r tags ]] || [[ ! -r TAGS ]] -then - $mktags "$CODEROOT"/**/* -elif [[ ${#changed[@]} -gt 0 ]] -then - $mktags "${changed[@]}" -fi -direnv reload -## START BRANCHLESS CONFIG - -git branchless hook post-checkout "$@" -## END BRANCHLESS CONFIG diff --git a/Biz/Ide/hooks/post-commit b/Biz/Ide/hooks/post-commit new file mode 100755 index 0000000..cd1f195 --- /dev/null +++ b/Biz/Ide/hooks/post-commit @@ -0,0 +1,6 @@ +#!/bin/sh +## START BRANCHLESS CONFIG + +git branchless hook post-commit "$@" + +## END BRANCHLESS CONFIG diff --git a/Biz/Ide/hooks/post-commit.sh b/Biz/Ide/hooks/post-commit.sh deleted file mode 100755 index cd1f195..0000000 --- a/Biz/Ide/hooks/post-commit.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -## START BRANCHLESS CONFIG - -git branchless hook post-commit "$@" - -## END BRANCHLESS CONFIG diff --git a/Biz/Ide/hooks/post-merge b/Biz/Ide/hooks/post-merge new file mode 100755 index 0000000..d2cfa63 --- /dev/null +++ b/Biz/Ide/hooks/post-merge @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +"${CODEROOT:?}"/Biz/Ide/hooks/post-checkout 'HEAD@{1}' HEAD +## START BRANCHLESS CONFIG + +git branchless hook post-merge "$@" +## END BRANCHLESS CONFIG diff --git a/Biz/Ide/hooks/post-merge.sh b/Biz/Ide/hooks/post-merge.sh deleted file mode 100755 index d2cfa63..0000000 --- a/Biz/Ide/hooks/post-merge.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -"${CODEROOT:?}"/Biz/Ide/hooks/post-checkout 'HEAD@{1}' HEAD -## START BRANCHLESS CONFIG - -git branchless hook post-merge "$@" -## END BRANCHLESS CONFIG diff --git a/Biz/Ide/hooks/post-rewrite b/Biz/Ide/hooks/post-rewrite new file mode 100755 index 0000000..8b3237a --- /dev/null +++ b/Biz/Ide/hooks/post-rewrite @@ -0,0 +1,6 @@ +#!/bin/sh +## START BRANCHLESS CONFIG + +git branchless hook post-rewrite "$@" + +## END BRANCHLESS CONFIG diff --git a/Biz/Ide/hooks/post-rewrite.sh b/Biz/Ide/hooks/post-rewrite.sh deleted file mode 100755 index 8b3237a..0000000 --- a/Biz/Ide/hooks/post-rewrite.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -## START BRANCHLESS CONFIG - -git branchless hook post-rewrite "$@" - -## END BRANCHLESS CONFIG diff --git a/Biz/Ide/hooks/pre-auto-gc b/Biz/Ide/hooks/pre-auto-gc new file mode 100755 index 0000000..c92a844 --- /dev/null +++ b/Biz/Ide/hooks/pre-auto-gc @@ -0,0 +1,6 @@ +#!/bin/sh +## START BRANCHLESS CONFIG + +git branchless hook pre-auto-gc "$@" + +## END BRANCHLESS CONFIG diff --git a/Biz/Ide/hooks/pre-auto-gc.sh b/Biz/Ide/hooks/pre-auto-gc.sh deleted file mode 100755 index c92a844..0000000 --- a/Biz/Ide/hooks/pre-auto-gc.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -## START BRANCHLESS CONFIG - -git branchless hook pre-auto-gc "$@" - -## END BRANCHLESS CONFIG diff --git a/Biz/Ide/hooks/pre-commit b/Biz/Ide/hooks/pre-commit new file mode 100755 index 0000000..b0f204a --- /dev/null +++ b/Biz/Ide/hooks/pre-commit @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# +# - prevent frozen code from being checked in +# - guard against lint errors +## + set -e + mapfile -t changed < <(git diff-index --cached --name-only HEAD) + for ns in "${changed[@]}" + do + version=$("${CODEROOT:?}"/Biz/Ide/version.sh "$ns") + if [[ $version -eq -1 ]]; then + echo "info: version: $ns: deleted" + elif [[ $version -lt 1 ]]; then + echo "fail: version: $ns: $version" + exit 1 + else + echo "info: version: $ns: $version" + fi + done + lint "${changed[@]}" +## diff --git a/Biz/Ide/hooks/pre-commit.sh b/Biz/Ide/hooks/pre-commit.sh deleted file mode 100755 index e7c34ab..0000000 --- a/Biz/Ide/hooks/pre-commit.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash -# -# - prevent frozen code from being checked in -# - guard against lint errors -## - set -e - mapfile -t changed < <(git diff-index --cached --name-only HEAD) - for ns in "${changed[@]}" - do - version=$("${CODEROOT:?}"/Biz/Ide/version "$ns") - if [[ $version -eq -1 ]]; then - echo "info: version: $ns: deleted" - elif [[ $version -lt 1 ]]; then - echo "fail: version: $ns: $version" - exit 1 - else - echo "info: version: $ns: $version" - fi - done - lint "${changed[@]}" -## diff --git a/Biz/Ide/hooks/pre-push b/Biz/Ide/hooks/pre-push new file mode 100755 index 0000000..16f11d1 --- /dev/null +++ b/Biz/Ide/hooks/pre-push @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +# +# A simple ci that saves its results in a git note, formatted according to +# RFC-2822, more or less. +# +# To run this manually, exec the script. It will expect to read a line of +# inputs, you can just enter 'HEAD' and it will +# +## + 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) +## + commit=$(git notes --ref=ci show HEAD || true) + if [[ -n "$commit" ]] + then + 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 "${BILD_ARGS:-""}" --test "${CODEROOT:?}"/**/* + then + test_result="good" + else + test_result="fail" + exit 1 + fi +## + read -r -d '' note < +Test-at: $at +EOF +## + git notes --ref=ci append -m "$note" +## diff --git a/Biz/Ide/hooks/pre-push.sh b/Biz/Ide/hooks/pre-push.sh deleted file mode 100755 index 16f11d1..0000000 --- a/Biz/Ide/hooks/pre-push.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env bash -# -# A simple ci that saves its results in a git note, formatted according to -# RFC-2822, more or less. -# -# To run this manually, exec the script. It will expect to read a line of -# inputs, you can just enter 'HEAD' and it will -# -## - 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) -## - commit=$(git notes --ref=ci show HEAD || true) - if [[ -n "$commit" ]] - then - 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 "${BILD_ARGS:-""}" --test "${CODEROOT:?}"/**/* - then - test_result="good" - else - test_result="fail" - exit 1 - fi -## - read -r -d '' note < -Test-at: $at -EOF -## - git notes --ref=ci append -m "$note" -## diff --git a/Biz/Ide/hooks/reference-transaction b/Biz/Ide/hooks/reference-transaction new file mode 100755 index 0000000..ea0cce6 --- /dev/null +++ b/Biz/Ide/hooks/reference-transaction @@ -0,0 +1,12 @@ +#!/bin/sh +## START BRANCHLESS CONFIG + +# Avoid canceling the reference transaction in the case that `branchless` fails +# for whatever reason. +git branchless hook reference-transaction "$@" || ( +echo 'branchless: Failed to process reference transaction!' +echo 'branchless: Some events (e.g. branch updates) may have been lost.' +echo 'branchless: This is a bug. Please report it.' +) + +## END BRANCHLESS CONFIG diff --git a/Biz/Ide/hooks/reference-transaction.sh b/Biz/Ide/hooks/reference-transaction.sh deleted file mode 100755 index ea0cce6..0000000 --- a/Biz/Ide/hooks/reference-transaction.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -## START BRANCHLESS CONFIG - -# Avoid canceling the reference transaction in the case that `branchless` fails -# for whatever reason. -git branchless hook reference-transaction "$@" || ( -echo 'branchless: Failed to process reference transaction!' -echo 'branchless: Some events (e.g. branch updates) may have been lost.' -echo 'branchless: This is a bug. Please report it.' -) - -## END BRANCHLESS CONFIG -- cgit v1.2.3