mirror of
https://github.com/Heretek-Games/drop.git
synced 2026-10-12 10:29:54 +00:00
- Pin local toolchain versions in .mise.toml (node, pnpm, python, go, rust, shellcheck, shfmt, hadolint, actionlint, ruff, gitleaks, typos). - Route hook tools through scripts/run-tool.sh so a missing tool fails with an actionable 'mise install' message instead of silently skipping. - Add shellcheck, hadolint, actionlint, ruff (check+format), typos and mandatory gitleaks to pre-commit; commitlint to commit-msg; server lint and cargo fmt to pre-push. - Enable gocognit/gocyclo/misspell in golangci-lint. - Adopt ruff for server/dev-tools Python (formatting + lint).
47 lines
1.6 KiB
Bash
Executable File
47 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Run `cargo fmt --check` and `cargo clippy -D warnings` only over crates that
|
|
# contain changed .rs files. Called by lefthook pre-push. desktop/src-tauri is
|
|
# intentionally excluded: it needs Tauri system libraries that contributors on
|
|
# minimal setups won't have. CI covers it in droplet-ci.yml / torrential-ci.yml.
|
|
set -uo pipefail
|
|
|
|
# Resolve the repo root regardless of where the hook runs.
|
|
repo_root="$(git rev-parse --show-toplevel)"
|
|
cd "$repo_root" || exit 1
|
|
|
|
# :colon: curls are handled by set -e semantics below.
|
|
crates=(
|
|
cli
|
|
torrential
|
|
libraries/droplet
|
|
libraries/droplet_types
|
|
libraries/libarchive
|
|
libraries/native_model
|
|
)
|
|
|
|
# Accumulate changed .rs files relative to repo root.
|
|
changed_rs="$(git diff --name-only HEAD -- '*.rs' 2>/dev/null; git diff --cached --name-only -- '*.rs' 2>/dev/null)"
|
|
# Falls back to previous-branch commit when @{push} isn't resolvable.
|
|
if [[ -z "$changed_rs" ]]; then
|
|
upstream="$(git rev-parse --verify '@{push}' 2>/dev/null || git rev-parse --verify 'HEAD~1' 2>/dev/null || echo "")"
|
|
if [[ -n "$upstream" ]]; then
|
|
changed_rs="$(git diff --name-only "$upstream..HEAD" -- '*.rs' 2>/dev/null)"
|
|
fi
|
|
fi
|
|
|
|
if [[ -z "$changed_rs" ]]; then
|
|
echo "clippy-changed: no .rs changes; skipping"
|
|
exit 0
|
|
fi
|
|
|
|
status=0
|
|
for dir in "${crates[@]}"; do
|
|
if printf '%s\n' "$changed_rs" | grep -q "^${dir}/"; then
|
|
echo "==> cargo fmt (${dir})"
|
|
(cd "$dir" && cargo fmt --all -- --check) || status=1
|
|
echo "==> cargo clippy (${dir})"
|
|
(cd "$dir" && cargo clippy --all-targets --all-features -- -D warnings) || status=1
|
|
fi
|
|
done
|
|
|
|
exit "$status" |