Skip to content

test(autoreview): isolate review-scope-test's git from host config - #1176

Draft
sbalabanov wants to merge 1 commit into
mainfrom
sergeyb/test-review-scope-host-git-isolation
Draft

sbalabanov wants to merge 1 commit into
mainfrom
sergeyb/test-review-scope-host-git-isolation

Conversation

@sbalabanov

Copy link
Copy Markdown
Collaborator

TLDR: review-scope-test now ignores system and global git config, so it passes on hosts that enable commit signing.

Summary

  • run_git in review_scope_test.py ran host git with the inherited environment. On a host whose system git config enables commit signing, git commit in test_branch_mode_uses_the_net_worktree_diff exited 128 on every run.
  • run_git now sets GIT_CONFIG_NOSYSTEM=1 and GIT_CONFIG_GLOBAL=/dev/null. The test's own repo-level user.email and user.name still apply, and the script invocations are unchanged.
  • Only the test file changes. The .claude/skills alias is a symlink, so both targets are covered.

Test Plan

On a host with system commit.gpgsign=true and a system hooks path:

  • Before the fix, ./tool/bazel test //.agents/skills/autoreview/scripts:review-scope-test //.claude/skills/autoreview/scripts:review-scope-test --nocache_test_results: both FAILED.
  • After the fix, the same command: both PASSED.
  • After the fix, the same two targets with --runs_per_test=20 --runs_per_test_detects_flakes --nocache_test_results: 20/20 pass on each.
  • make lint check-gazelle check-tidy: pass.

🤖 Generated with Claude Code

On hosts whose system git config enables commit signing,
test_branch_mode_uses_the_net_worktree_diff failed every run: its
`git commit` exited 128 because the signing helper was unavailable in the
test sandbox.

The test's run_git helper ran host git with the inherited environment, so
system and global config (signing, hooks) leaked into the temporary
repository.

run_git now sets GIT_CONFIG_NOSYSTEM=1 and GIT_CONFIG_GLOBAL=/dev/null, so
only the repository's own config (the test's user.email and user.name)
applies. The script invocations are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@sbalabanov sbalabanov left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[flaky-1-d4-reviewer] satisfied: the run_git env now keeps system, global and XDG git config out of every git call the test makes (checked against a host with system signing and hooks); the script it runs only reads and keeps the caller's config, as the spec intends; scope, comments, commit message and PR body all pass.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant