chore: remove stale setup scripts, skills, and evals
Remove artifacts from pre-commit migration and cleanup: - scripts/setup-gitleaks.sh, scripts/gitleaks.toml: legacy setup scripts - tests/test-setup-gitleaks.sh, tests/test-setup-hooks.sh: phantom test files - plugins/bin/skills/gitleaks/: skill for deprecated shell-based setup - plugins/bin/evals/cross-cutting/gitleaks/: eval for deleted skill - plugins/bin/evals/cross-cutting/neuledge-context/: out-of-scope eval - plugins/bin/evals/implement/write-docs/: incomplete eval - package.json, package-lock.json: markdownlint dependencies (unused) All validation now managed by .pre-commit-config.yaml. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,151 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
SCRIPT="$REPO_ROOT/scripts/setup-gitleaks.sh"
|
||||
PASS=0
|
||||
FAIL=0
|
||||
|
||||
pass() { echo " PASS: $1"; PASS=$((PASS + 1)); }
|
||||
fail() { echo " FAIL: $1"; FAIL=$((FAIL + 1)); }
|
||||
|
||||
# Fake gitleaks binary — prevents the install step from running during tests
|
||||
FAKE_BIN="$(mktemp -d)"
|
||||
trap 'rm -rf "$FAKE_BIN"' EXIT
|
||||
printf '#!/bin/sh\necho "gitleaks fake"\n' > "$FAKE_BIN/gitleaks"
|
||||
chmod +x "$FAKE_BIN/gitleaks"
|
||||
export PATH="$FAKE_BIN:$PATH"
|
||||
|
||||
# Helper: create an isolated git repo in a temp dir
|
||||
make_repo() {
|
||||
local dir
|
||||
dir="$(mktemp -d)"
|
||||
git -C "$dir" init -q
|
||||
echo "$dir"
|
||||
}
|
||||
|
||||
# Helper: run setup script against a target repo; capture output; always return exit code
|
||||
run_setup() {
|
||||
local target="$1"
|
||||
bash "$SCRIPT" "$target" 2>&1
|
||||
}
|
||||
|
||||
# --- 1. Rejects non-git directory ---
|
||||
echo ""
|
||||
echo "--- rejects non-git directory ---"
|
||||
NON_GIT="$(mktemp -d)"
|
||||
trap 'rm -rf "$NON_GIT"' EXIT
|
||||
if bash "$SCRIPT" "$NON_GIT" >/dev/null 2>&1; then
|
||||
fail "exited 0 for non-git directory — expected exit 1"
|
||||
else
|
||||
pass "exits non-zero for non-git directory"
|
||||
fi
|
||||
|
||||
# --- 2. Config deployed ---
|
||||
echo ""
|
||||
echo "--- config deployed to target repo ---"
|
||||
REPO="$(make_repo)"
|
||||
trap 'rm -rf "$REPO"' EXIT
|
||||
run_setup "$REPO" > /dev/null
|
||||
if [ -f "$REPO/.gitleaks.toml" ]; then
|
||||
pass ".gitleaks.toml created in target repo"
|
||||
else
|
||||
fail ".gitleaks.toml missing from target repo"
|
||||
fi
|
||||
if diff -q "$REPO_ROOT/scripts/gitleaks.toml" "$REPO/.gitleaks.toml" > /dev/null 2>&1; then
|
||||
pass ".gitleaks.toml matches the template"
|
||||
else
|
||||
fail ".gitleaks.toml content differs from template"
|
||||
fi
|
||||
|
||||
# --- 3. Hook created from scratch ---
|
||||
echo ""
|
||||
echo "--- hook created when none exists ---"
|
||||
REPO2="$(make_repo)"
|
||||
trap 'rm -rf "$REPO2"' EXIT
|
||||
run_setup "$REPO2" > /dev/null
|
||||
HOOK="$REPO2/.git/hooks/pre-commit"
|
||||
if [ -f "$HOOK" ]; then
|
||||
pass "pre-commit hook created"
|
||||
else
|
||||
fail "pre-commit hook not created"
|
||||
fi
|
||||
if [ -x "$HOOK" ]; then
|
||||
pass "pre-commit hook is executable"
|
||||
else
|
||||
fail "pre-commit hook is not executable"
|
||||
fi
|
||||
if head -1 "$HOOK" | grep -q "^#!"; then
|
||||
pass "pre-commit hook has a shebang"
|
||||
else
|
||||
fail "pre-commit hook missing shebang"
|
||||
fi
|
||||
if grep -q "gitleaks git --staged" "$HOOK"; then
|
||||
pass "pre-commit hook contains gitleaks command"
|
||||
else
|
||||
fail "pre-commit hook missing gitleaks command"
|
||||
fi
|
||||
if grep -q "# managed by setup-gitleaks.sh" "$HOOK"; then
|
||||
pass "pre-commit hook contains idempotency marker"
|
||||
else
|
||||
fail "pre-commit hook missing idempotency marker"
|
||||
fi
|
||||
|
||||
# --- 4. Appends to existing hook; existing content retained ---
|
||||
echo ""
|
||||
echo "--- appends to existing hook; prior content retained ---"
|
||||
REPO3="$(make_repo)"
|
||||
trap 'rm -rf "$REPO3"' EXIT
|
||||
HOOK3="$REPO3/.git/hooks/pre-commit"
|
||||
printf '#!/usr/bin/env bash\nnpm test\n' > "$HOOK3"
|
||||
chmod +x "$HOOK3"
|
||||
run_setup "$REPO3" > /dev/null
|
||||
if grep -q "npm test" "$HOOK3"; then
|
||||
pass "existing hook content retained after append"
|
||||
else
|
||||
fail "existing hook content lost after append"
|
||||
fi
|
||||
if grep -q "gitleaks git --staged" "$HOOK3"; then
|
||||
pass "gitleaks block appended to existing hook"
|
||||
else
|
||||
fail "gitleaks block missing after append"
|
||||
fi
|
||||
|
||||
# --- 5. Second run replaces stale block; existing content still retained ---
|
||||
echo ""
|
||||
echo "--- second run replaces stale block; existing content still retained ---"
|
||||
# Corrupt the gitleaks block to simulate stale content from an older version
|
||||
sed -i 's/gitleaks git --staged/gitleaks protect --staged/' "$HOOK3"
|
||||
run_setup "$REPO3" > /dev/null
|
||||
if grep -q "npm test" "$HOOK3"; then
|
||||
pass "existing content retained after block replacement"
|
||||
else
|
||||
fail "existing content lost after block replacement"
|
||||
fi
|
||||
marker_count="$(grep -c "# managed by setup-gitleaks.sh" "$HOOK3")"
|
||||
if [ "$marker_count" -eq 1 ]; then
|
||||
pass "gitleaks block appears exactly once after second run"
|
||||
else
|
||||
fail "gitleaks block duplicated — found $marker_count occurrences of marker"
|
||||
fi
|
||||
if grep -q "gitleaks git --staged" "$HOOK3"; then
|
||||
pass "stale gitleaks command replaced with current command"
|
||||
else
|
||||
fail "stale gitleaks command not replaced — block was skipped, not updated"
|
||||
fi
|
||||
|
||||
# --- 6. Third run still idempotent ---
|
||||
echo ""
|
||||
echo "--- repeated runs stay idempotent ---"
|
||||
run_setup "$REPO3" > /dev/null
|
||||
run_setup "$REPO3" > /dev/null
|
||||
marker_count="$(grep -c "# managed by setup-gitleaks.sh" "$HOOK3")"
|
||||
if [ "$marker_count" -eq 1 ]; then
|
||||
pass "gitleaks block still appears exactly once after four total runs"
|
||||
else
|
||||
fail "gitleaks block duplicated — found $marker_count occurrences after four runs"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Results: $PASS passed, $FAIL failed"
|
||||
[[ $FAIL -eq 0 ]]
|
||||
@@ -1,210 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
SCRIPT="$REPO_ROOT/scripts/setup-hooks.sh"
|
||||
PASS=0
|
||||
FAIL=0
|
||||
|
||||
pass() { echo " PASS: $1"; PASS=$((PASS + 1)); }
|
||||
fail() { echo " FAIL: $1"; FAIL=$((FAIL + 1)); }
|
||||
|
||||
# Helper: make a bare git repo with no hooks yet
|
||||
make_repo() {
|
||||
local dir
|
||||
dir="$(mktemp -d)"
|
||||
git -C "$dir" init -q
|
||||
echo "$dir"
|
||||
}
|
||||
|
||||
# Fake binaries for tools we don't want to install-check during tests
|
||||
FAKE_BIN="$(mktemp -d)"
|
||||
trap 'rm -rf "$FAKE_BIN"' EXIT
|
||||
for tool in shellcheck jq yq; do
|
||||
printf '#!/bin/sh\necho "fake %s"\n' "$tool" > "$FAKE_BIN/$tool"
|
||||
chmod +x "$FAKE_BIN/$tool"
|
||||
done
|
||||
export PATH="$FAKE_BIN:$PATH"
|
||||
|
||||
# --- 1. Rejects non-git directory ---
|
||||
echo ""
|
||||
echo "--- rejects non-git directory ---"
|
||||
NON_GIT="$(mktemp -d)"
|
||||
trap 'rm -rf "$NON_GIT"' EXIT
|
||||
if bash "$SCRIPT" "$NON_GIT" > /dev/null 2>&1; then
|
||||
fail "exited 0 for non-git directory — expected exit 1"
|
||||
else
|
||||
pass "exits non-zero for non-git directory"
|
||||
fi
|
||||
|
||||
# --- 2. Creates commit-msg hook ---
|
||||
echo ""
|
||||
echo "--- creates commit-msg hook ---"
|
||||
REPO="$(make_repo)"
|
||||
trap 'rm -rf "$REPO"' EXIT
|
||||
bash "$SCRIPT" "$REPO" > /dev/null 2>&1
|
||||
HOOK="$REPO/.git/hooks/commit-msg"
|
||||
if [[ -f "$HOOK" ]]; then
|
||||
pass "commit-msg hook file created"
|
||||
else
|
||||
fail "commit-msg hook not created"
|
||||
fi
|
||||
if [[ -x "$HOOK" ]]; then
|
||||
pass "commit-msg hook is executable"
|
||||
else
|
||||
fail "commit-msg hook is not executable"
|
||||
fi
|
||||
if grep -q "# managed by setup-hooks.sh" "$HOOK"; then
|
||||
pass "commit-msg hook contains idempotency marker"
|
||||
else
|
||||
fail "commit-msg hook missing idempotency marker"
|
||||
fi
|
||||
|
||||
# --- 3. commit-msg hook validates conventional commits ---
|
||||
echo ""
|
||||
echo "--- commit-msg hook: valid message passes ---"
|
||||
REPO2="$(make_repo)"
|
||||
trap 'rm -rf "$REPO2"' EXIT
|
||||
bash "$SCRIPT" "$REPO2" > /dev/null 2>&1
|
||||
HOOK2="$REPO2/.git/hooks/commit-msg"
|
||||
TMPFILE="$(mktemp)"
|
||||
trap 'rm -f "$TMPFILE"' EXIT
|
||||
|
||||
for valid_msg in "feat: add validation" "fix(core): correct path resolution" "chore!: drop python dep" "docs: update readme" "refactor(hooks): extract marker logic"; do
|
||||
echo "$valid_msg" > "$TMPFILE"
|
||||
if bash "$HOOK2" "$TMPFILE" > /dev/null 2>&1; then
|
||||
pass "commit-msg hook accepts: $valid_msg"
|
||||
else
|
||||
fail "commit-msg hook wrongly rejected: $valid_msg"
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "--- commit-msg hook: invalid message is rejected ---"
|
||||
for invalid_msg in "added some stuff" "WIP" "Fix the thing" "FEAT: bad case" "feat bad colon"; do
|
||||
echo "$invalid_msg" > "$TMPFILE"
|
||||
if bash "$HOOK2" "$TMPFILE" > /dev/null 2>&1; then
|
||||
fail "commit-msg hook wrongly accepted: $invalid_msg"
|
||||
else
|
||||
pass "commit-msg hook rejects: $invalid_msg"
|
||||
fi
|
||||
done
|
||||
|
||||
# --- 4. Appends pre-commit validation block ---
|
||||
echo ""
|
||||
echo "--- appends validation block to pre-commit hook ---"
|
||||
REPO3="$(make_repo)"
|
||||
trap 'rm -rf "$REPO3"' EXIT
|
||||
bash "$SCRIPT" "$REPO3" > /dev/null 2>&1
|
||||
PRE_COMMIT="$REPO3/.git/hooks/pre-commit"
|
||||
if [[ -f "$PRE_COMMIT" ]]; then
|
||||
pass "pre-commit hook created"
|
||||
else
|
||||
fail "pre-commit hook not created"
|
||||
fi
|
||||
if grep -q "shellcheck" "$PRE_COMMIT"; then
|
||||
pass "pre-commit hook contains shellcheck"
|
||||
else
|
||||
fail "pre-commit hook missing shellcheck"
|
||||
fi
|
||||
if grep -q "jq" "$PRE_COMMIT"; then
|
||||
pass "pre-commit hook contains jq"
|
||||
else
|
||||
fail "pre-commit hook missing jq"
|
||||
fi
|
||||
if grep -q "SKILL.md" "$PRE_COMMIT"; then
|
||||
pass "pre-commit hook contains SKILL.md frontmatter check"
|
||||
else
|
||||
fail "pre-commit hook missing SKILL.md frontmatter check"
|
||||
fi
|
||||
|
||||
# --- 5. Creates pre-push hook ---
|
||||
echo ""
|
||||
echo "--- creates pre-push hook ---"
|
||||
REPO4="$(make_repo)"
|
||||
trap 'rm -rf "$REPO4"' EXIT
|
||||
bash "$SCRIPT" "$REPO4" > /dev/null 2>&1
|
||||
PUSH_HOOK="$REPO4/.git/hooks/pre-push"
|
||||
if [[ -f "$PUSH_HOOK" ]]; then
|
||||
pass "pre-push hook created"
|
||||
else
|
||||
fail "pre-push hook not created"
|
||||
fi
|
||||
if [[ -x "$PUSH_HOOK" ]]; then
|
||||
pass "pre-push hook is executable"
|
||||
else
|
||||
fail "pre-push hook is not executable"
|
||||
fi
|
||||
if grep -q "check-manifests" "$PUSH_HOOK"; then
|
||||
pass "pre-push hook calls check-manifests.sh"
|
||||
else
|
||||
fail "pre-push hook missing check-manifests.sh call"
|
||||
fi
|
||||
if grep -q "run-tests.sh" "$PUSH_HOOK"; then
|
||||
pass "pre-push hook calls run-tests.sh"
|
||||
else
|
||||
fail "pre-push hook missing run-tests.sh call"
|
||||
fi
|
||||
|
||||
# --- 6. Idempotent: second run replaces each block exactly once ---
|
||||
echo ""
|
||||
echo "--- idempotent: second run does not duplicate blocks ---"
|
||||
REPO5="$(make_repo)"
|
||||
trap 'rm -rf "$REPO5"' EXIT
|
||||
bash "$SCRIPT" "$REPO5" > /dev/null 2>&1
|
||||
bash "$SCRIPT" "$REPO5" > /dev/null 2>&1
|
||||
bash "$SCRIPT" "$REPO5" > /dev/null 2>&1
|
||||
|
||||
for hook_file in "$REPO5/.git/hooks/commit-msg" "$REPO5/.git/hooks/pre-commit" "$REPO5/.git/hooks/pre-push"; do
|
||||
count=$(grep -c "# managed by setup-hooks.sh" "$hook_file" || true)
|
||||
hook_name="$(basename "$hook_file")"
|
||||
if [[ "$count" -eq 1 ]]; then
|
||||
pass "idempotent: $hook_name marker appears exactly once after 3 runs"
|
||||
else
|
||||
fail "idempotent: $hook_name marker appears $count times — block duplicated"
|
||||
fi
|
||||
if [[ -x "$hook_file" ]]; then
|
||||
pass "idempotent: $hook_name remains executable after 3 runs"
|
||||
else
|
||||
fail "idempotent: $hook_name lost executable bit after repeated runs"
|
||||
fi
|
||||
done
|
||||
|
||||
# --- 7. Setup installs tools; no "not installed" warnings when tools present ---
|
||||
echo ""
|
||||
echo "--- setup does not warn when tools are available ---"
|
||||
REPO6="$(make_repo)"
|
||||
trap 'rm -rf "$REPO6"' EXIT
|
||||
output6="$(bash "$SCRIPT" "$REPO6" 2>&1)"
|
||||
for tool in shellcheck jq yq; do
|
||||
if echo "$output6" | grep -qi "$tool not installed\|$tool.*not found"; then
|
||||
fail "setup warned about missing $tool — should install or already be present"
|
||||
else
|
||||
pass "setup emits no 'not installed' warning for: $tool (present or installed)"
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "--- pre-commit hook retains runtime fallback for missing tools ---"
|
||||
PRE_COMMIT6="$REPO6/.git/hooks/pre-commit"
|
||||
for tool in shellcheck jq yq; do
|
||||
if grep -q "Warning:.*$tool\|$tool.*not installed\|$tool.*skipped" "$PRE_COMMIT6"; then
|
||||
pass "pre-commit hook has runtime fallback for missing: $tool"
|
||||
else
|
||||
fail "pre-commit hook missing runtime fallback for: $tool"
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "--- setup exits 0 when tools are present ---"
|
||||
REPO7="$(make_repo)"
|
||||
trap 'rm -rf "$REPO7"' EXIT
|
||||
if bash "$SCRIPT" "$REPO7" > /dev/null 2>&1; then
|
||||
pass "setup exits 0 when tools are present"
|
||||
else
|
||||
fail "setup exited non-zero unexpectedly"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Results: $PASS passed, $FAIL failed"
|
||||
[[ $FAIL -eq 0 ]]
|
||||
Reference in New Issue
Block a user