Files
termscp/.githooks/pre-commit
T
Christian Visintin afbc74113f
Deploy docs to GitHub Pages / deploy (push) Has been cancelled
Site / build-site (push) Has been cancelled
Install.sh / build (macos-latest) (push) Has been cancelled
Install.sh / build (ubuntu-latest) (push) Has been cancelled
CI / toolchain (push) Has been cancelled
CI / fmt (push) Has been cancelled
CI / install-scripts (push) Has been cancelled
CI / crates-ubuntu-latest (push) Has been cancelled
CI / crates-windows-latest (push) Has been cancelled
CI / doc (push) Has been cancelled
CI / deny (push) Has been cancelled
CI / crates-macos-latest (push) Has been cancelled
ci: migrate project automation to Just (#442)
* ci: migrate project automation to Just

Centralize build, test, release, dependency, hook, and website commands in Just recipes. Pin workflow tooling, use the repository toolchain, and run the complete validation set in CI.

* ci: codex being codex

* docs: update CLAUDE.md for just task runner migration

Reflect the switch to just recipes for build/test/clippy/fmt, note
dprint replacing raw rustfmt, and add a cross-platform code requirement.

* fix: resolve clippy warnings breaking CI on ubuntu and windows

Use clone() instead of implicit to_string() on already-owned String
values, gate the windows-only unused make_file_at import behind
cfg(posix), and fix unused mut / manual assign-op in the windows-only
localhost test.

* fix: fmt
2026-08-28 19:29:58 +02:00

54 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# termscp pre-commit hook.
#
# Runs three gates before a commit is recorded:
# 1. trufflehog -- scan the staged tree for verified/unknown secrets
# 2. dprint -- check formatting (Markdown, TOML, YAML, Rust)
# 3. cargo-deny -- advisories, licenses, bans, and sources
#
# Install with `just setup_githooks` (sets core.hooksPath to .githooks).
# Bypass in an emergency with `git commit --no-verify`.
set -euo pipefail
fail() {
echo "pre-commit: $1" >&2
exit 1
}
command -v just >/dev/null 2>&1 || fail "just not found; install it to run the pre-commit checks"
if ! git diff --cached --quiet --diff-filter=ACMR --; then
command -v trufflehog >/dev/null 2>&1 || fail "trufflehog not found; install it or commit with --no-verify"
# Check the exact tree that will be committed, not possibly different
# working-tree contents. The trailing slash is required by checkout-index.
index_tree="$(mktemp -d)"
cleanup() {
rm -rf -- "$index_tree"
}
trap cleanup EXIT
git checkout-index --all --prefix="$index_tree/"
echo "pre-commit: scanning staged tree for secrets"
(
cd "$index_tree"
just scan_secrets . --fail-on-scan-errors
)
echo "pre-commit: checking staged-tree formatting"
(
cd "$index_tree"
just fmt_check
)
echo "pre-commit: checking staged-tree dependencies"
(
cd "$index_tree"
just deny
)
fi
echo "pre-commit: all checks passed"