From 2d40ec3a03f4684f6fabba7dee2981c992a13785 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Mon, 1 Apr 2024 15:19:49 -0400 Subject: Rename .bash files to .sh I was already using .sh to refer to shell scripts. When I added .bash, I didn't realize that the linter was set to act on .sh files and not .bash files, so all of these bash scripts escaped the linter. This commit renames them to .sh, removes the .bash extension support from Biz.Namespace, and fixes all the reported shellcheck errors. --- Biz/Ide/hooks/commit-msg.bash | 2 -- Biz/Ide/hooks/commit-msg.sh | 2 ++ Biz/Ide/hooks/post-applypatch.bash | 6 ---- Biz/Ide/hooks/post-applypatch.sh | 6 ++++ Biz/Ide/hooks/post-checkout.bash | 19 ----------- Biz/Ide/hooks/post-checkout.sh | 19 +++++++++++ Biz/Ide/hooks/post-commit.bash | 6 ---- Biz/Ide/hooks/post-commit.sh | 6 ++++ Biz/Ide/hooks/post-merge.bash | 6 ---- Biz/Ide/hooks/post-merge.sh | 6 ++++ Biz/Ide/hooks/post-rewrite.bash | 6 ---- Biz/Ide/hooks/post-rewrite.sh | 6 ++++ Biz/Ide/hooks/pre-auto-gc.bash | 6 ---- Biz/Ide/hooks/pre-auto-gc.sh | 6 ++++ Biz/Ide/hooks/pre-commit.bash | 21 ------------ Biz/Ide/hooks/pre-commit.sh | 21 ++++++++++++ Biz/Ide/hooks/pre-push.bash | 55 -------------------------------- Biz/Ide/hooks/pre-push.sh | 54 +++++++++++++++++++++++++++++++ Biz/Ide/hooks/reference-transaction.bash | 12 ------- Biz/Ide/hooks/reference-transaction.sh | 12 +++++++ 20 files changed, 138 insertions(+), 139 deletions(-) delete mode 100755 Biz/Ide/hooks/commit-msg.bash create mode 100755 Biz/Ide/hooks/commit-msg.sh delete mode 100755 Biz/Ide/hooks/post-applypatch.bash create mode 100755 Biz/Ide/hooks/post-applypatch.sh delete mode 100755 Biz/Ide/hooks/post-checkout.bash create mode 100755 Biz/Ide/hooks/post-checkout.sh delete mode 100755 Biz/Ide/hooks/post-commit.bash create mode 100755 Biz/Ide/hooks/post-commit.sh delete mode 100755 Biz/Ide/hooks/post-merge.bash create mode 100755 Biz/Ide/hooks/post-merge.sh delete mode 100755 Biz/Ide/hooks/post-rewrite.bash create mode 100755 Biz/Ide/hooks/post-rewrite.sh delete mode 100755 Biz/Ide/hooks/pre-auto-gc.bash create mode 100755 Biz/Ide/hooks/pre-auto-gc.sh delete mode 100755 Biz/Ide/hooks/pre-commit.bash create mode 100755 Biz/Ide/hooks/pre-commit.sh delete mode 100755 Biz/Ide/hooks/pre-push.bash create mode 100755 Biz/Ide/hooks/pre-push.sh delete mode 100755 Biz/Ide/hooks/reference-transaction.bash create mode 100755 Biz/Ide/hooks/reference-transaction.sh (limited to 'Biz/Ide/hooks') diff --git a/Biz/Ide/hooks/commit-msg.bash b/Biz/Ide/hooks/commit-msg.bash deleted file mode 100755 index 64e400d..0000000 --- a/Biz/Ide/hooks/commit-msg.bash +++ /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/commit-msg.sh b/Biz/Ide/hooks/commit-msg.sh new file mode 100755 index 0000000..64e400d --- /dev/null +++ b/Biz/Ide/hooks/commit-msg.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +gitlint --ignore-stdin --staged --msg-filename "$1" run-hook diff --git a/Biz/Ide/hooks/post-applypatch.bash b/Biz/Ide/hooks/post-applypatch.bash deleted file mode 100755 index 5071dc5..0000000 --- a/Biz/Ide/hooks/post-applypatch.bash +++ /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-applypatch.sh b/Biz/Ide/hooks/post-applypatch.sh new file mode 100755 index 0000000..5071dc5 --- /dev/null +++ b/Biz/Ide/hooks/post-applypatch.sh @@ -0,0 +1,6 @@ +#!/bin/sh +## START BRANCHLESS CONFIG + +git branchless hook post-applypatch "$@" + +## END BRANCHLESS CONFIG diff --git a/Biz/Ide/hooks/post-checkout.bash b/Biz/Ide/hooks/post-checkout.bash deleted file mode 100755 index 982cb4b..0000000 --- a/Biz/Ide/hooks/post-checkout.bash +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -set -e -mktags=${CODEROOT:?}/Biz/Ide/mktags -old=$1 -new=$2 -# filter out only the changed haskell files -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 new file mode 100755 index 0000000..e4a0d67 --- /dev/null +++ b/Biz/Ide/hooks/post-checkout.sh @@ -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-commit.bash b/Biz/Ide/hooks/post-commit.bash deleted file mode 100755 index cd1f195..0000000 --- a/Biz/Ide/hooks/post-commit.bash +++ /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-commit.sh b/Biz/Ide/hooks/post-commit.sh new file mode 100755 index 0000000..cd1f195 --- /dev/null +++ b/Biz/Ide/hooks/post-commit.sh @@ -0,0 +1,6 @@ +#!/bin/sh +## START BRANCHLESS CONFIG + +git branchless hook post-commit "$@" + +## END BRANCHLESS CONFIG diff --git a/Biz/Ide/hooks/post-merge.bash b/Biz/Ide/hooks/post-merge.bash deleted file mode 100755 index 94f0f60..0000000 --- a/Biz/Ide/hooks/post-merge.bash +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -exec ${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 new file mode 100755 index 0000000..d2cfa63 --- /dev/null +++ b/Biz/Ide/hooks/post-merge.sh @@ -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-rewrite.bash b/Biz/Ide/hooks/post-rewrite.bash deleted file mode 100755 index 8b3237a..0000000 --- a/Biz/Ide/hooks/post-rewrite.bash +++ /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/post-rewrite.sh b/Biz/Ide/hooks/post-rewrite.sh new file mode 100755 index 0000000..8b3237a --- /dev/null +++ b/Biz/Ide/hooks/post-rewrite.sh @@ -0,0 +1,6 @@ +#!/bin/sh +## START BRANCHLESS CONFIG + +git branchless hook post-rewrite "$@" + +## END BRANCHLESS CONFIG diff --git a/Biz/Ide/hooks/pre-auto-gc.bash b/Biz/Ide/hooks/pre-auto-gc.bash deleted file mode 100755 index c92a844..0000000 --- a/Biz/Ide/hooks/pre-auto-gc.bash +++ /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-auto-gc.sh b/Biz/Ide/hooks/pre-auto-gc.sh new file mode 100755 index 0000000..c92a844 --- /dev/null +++ b/Biz/Ide/hooks/pre-auto-gc.sh @@ -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-commit.bash b/Biz/Ide/hooks/pre-commit.bash deleted file mode 100755 index 560eee7..0000000 --- a/Biz/Ide/hooks/pre-commit.bash +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash -# -# - prevent frozen code from being checked in -# - guard against lint errors -## - set -e - 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-commit.sh b/Biz/Ide/hooks/pre-commit.sh new file mode 100755 index 0000000..e7c34ab --- /dev/null +++ b/Biz/Ide/hooks/pre-commit.sh @@ -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 "$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.bash b/Biz/Ide/hooks/pre-push.bash deleted file mode 100755 index 5abd3ee..0000000 --- a/Biz/Ide/hooks/pre-push.bash +++ /dev/null @@ -1,55 +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 - 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 ${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 new file mode 100755 index 0000000..16f11d1 --- /dev/null +++ b/Biz/Ide/hooks/pre-push.sh @@ -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/reference-transaction.bash b/Biz/Ide/hooks/reference-transaction.bash deleted file mode 100755 index ea0cce6..0000000 --- a/Biz/Ide/hooks/reference-transaction.bash +++ /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 diff --git a/Biz/Ide/hooks/reference-transaction.sh b/Biz/Ide/hooks/reference-transaction.sh new file mode 100755 index 0000000..ea0cce6 --- /dev/null +++ b/Biz/Ide/hooks/reference-transaction.sh @@ -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 -- cgit v1.2.3