Files
Tirth Kanani 89cbf1934d fix(eval): refuse to check out a target dir that is not its own repository
clone_or_update ran `git fetch` and `git checkout <pinned sha>` with
cwd=repo_path whenever that path merely existed. Because evaluate/test_repos/
sits inside this project's own checkout, a target directory that is not a git
repository in its own right -- an empty dir, a half-finished clone, or one
whose .git points elsewhere -- makes `git -C` walk up to the enclosing
repository. The checkout then rewrote the developer's working tree instead of
the test repo, resetting tracked files to the pinned commit and discarding
uncommitted work.

This is not hypothetical: a local evaluate/test_repos/code-review-graph whose
git dir resolved to the project root caused `code-review-graph eval` to reset
this repository to 84bde354, silently reverting CLAUDE.md, docs/schema.md and
docs/architecture.md to versions several releases old.

_assert_standalone_repo now compares `git rev-parse --show-toplevel` against
the target path and raises before any fetch or checkout, telling the user to
remove the directory for a clean clone. Regression test builds a two-commit
outer repo, plants a non-repo directory at evaluate/test_repos/victim, pins
the older commit, and asserts both that the call raises and that the outer
repo's HEAD and working tree are untouched.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JNv8JqBb46stATZYUinQtn
2026-08-02 13:40:22 +01:00
..