fix(tests): unset hook-exported git env before running suites #175

Merged
Defame1297 merged 1 commits from fix/run-tests-git-env into main 2026-11-13 16:05:58 +00:00
Owner

Summary

Under the run-tests pre-push hook, git exports GIT_DIR to the hook, so the commit_as_base helper in plugins/kyberforge/.apm/skills/factory-audit/tests/validate-provenance-skill.bats ran git -C "$tmp" init/add/commit/update-ref against this repo instead of its temp dir. Every push: 84 failures, core.bare=true set on the checkout, index emptied.

  • tests/run-tests.sh now unsets GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_OBJECT_DIRECTORY GIT_COMMON_DIR before any suite runs, so no current or future suite inherits the caller's repo.
  • LESSONS.md: new entry; the 2026-07-05 "repo root is a bare checkout" lesson was likely this bug's symptom.

Verification

  • Reproduced with GIT_DIR pointed at a throwaway repo: 61 failures.
  • After the fix, same leaked env through run-tests.sh --bats-only: 463 tests, 0 failures.
  • This branch's own push ran the full pre-push hook set green; core.bare stayed false.

Merge order

Merge this before docs/delivery-team-adr (and any branch cut from main): until it lands, pushing a branch from a main-based checkout re-triggers the corruption.

SemVer impact: PATCH.

🤖 Generated with Claude Code

https://claude.ai/code/session_012CqgnwEGtmfsjcoG9QwByN

## Summary Under the `run-tests` pre-push hook, git exports `GIT_DIR` to the hook, so the `commit_as_base` helper in `plugins/kyberforge/.apm/skills/factory-audit/tests/validate-provenance-skill.bats` ran `git -C "$tmp" init/add/commit/update-ref` against **this repo** instead of its temp dir. Every push: 84 failures, `core.bare=true` set on the checkout, index emptied. - `tests/run-tests.sh` now unsets `GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_OBJECT_DIRECTORY GIT_COMMON_DIR` before any suite runs, so no current or future suite inherits the caller's repo. - `LESSONS.md`: new entry; the 2026-07-05 "repo root is a bare checkout" lesson was likely this bug's symptom. ## Verification - Reproduced with `GIT_DIR` pointed at a throwaway repo: 61 failures. - After the fix, same leaked env through `run-tests.sh --bats-only`: 463 tests, 0 failures. - This branch's own push ran the full pre-push hook set green; `core.bare` stayed `false`. ## Merge order Merge this before `docs/delivery-team-adr` (and any branch cut from `main`): until it lands, pushing a branch from a `main`-based checkout re-triggers the corruption. SemVer impact: PATCH. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_012CqgnwEGtmfsjcoG9QwByN
Claude added 1 commit 2026-11-13 16:04:30 +00:00
Git exports GIT_DIR to the hooks it runs, so under the run-tests pre-push
hook the validate-provenance-skill.bats fixtures' `git -C "$tmp"` calls
resolved to this repo: 84 failures, core.bare=true and an emptied index on
every push. run-tests.sh now unsets git's repo-locating variables before
any suite runs. Reproduced with GIT_DIR pointed at a throwaway repo (61
failures) and verified clean after the fix (463/463).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012CqgnwEGtmfsjcoG9QwByN
Defame1297 merged commit ff128df074 into main 2026-11-13 16:05:58 +00:00
Defame1297 deleted branch fix/run-tests-git-env 2026-11-13 16:05:58 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Holocron#175