Prefer testutil.InitRepo in trivial git test setup#979
Merged
Conversation
Entire-Checkpoint: 4c046cef95cf
Entire-Checkpoint: 2d1b3c1467ae
Entire-Checkpoint: 25428292449e
Contributor
There was a problem hiding this comment.
Pull request overview
This PR standardizes trivial git test setup across the CLI by preferring testutil.InitRepo(t, dir) over direct git.PlainInit() calls, aligning tests with the repo’s documented guidance for consistent repo-local config in CI.
Changes:
- Replaced trivial
git.PlainInit()usage withtestutil.InitRepo()in several test files. - Added a small helper in
git_operations_test.goto reduce repetition when initializing and opening a repo. - Updated
CLAUDE.mdto explicitly document the preference fortestutil.InitRepo()in tests.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| cmd/entire/cli/session/state_test.go | Uses testutil.InitRepo() for temp repo setup in git-common-dir cache tests. |
| cmd/entire/cli/phase_wiring_test.go | Switches phase wiring test repo setup to testutil.InitRepo(). |
| cmd/entire/cli/git_operations_test.go | Introduces initOpenedTestRepo helper and replaces direct PlainInit in several tests. |
| cmd/entire/cli/explain_test.go | Converts multiple tests to initialize repos via testutil.InitRepo() (opening the repo where needed). |
| CLAUDE.md | Documents the repo convention to prefer testutil.InitRepo() over git.PlainInit() in tests. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
testutil.InitRepo()over directgit.PlainInit()in trivial test setupexplain_test.go,git_operations_test.go,phase_wiring_test.go, andsession/state_test.gogit.PlainInit()cases unchangedTest Plan
go test ./cmd/entire/cli ./cmd/entire/cli/sessiongo build ./...go vet ./...Note
Low Risk
Test-only refactor and documentation update; behavior changes are limited to how temporary repos are configured (user identity/GPG signing), which may only affect tests that implicitly relied on missing config.
Overview
Standardizes unit-test git repository setup by replacing many direct
git.PlainInit()calls withtestutil.InitRepo(t, dir)(andgit.PlainOpenwhen a*git.Repositoryis still needed), reducing dependence on global git config and avoiding GPG/user config pitfalls in CI.Adds explicit documentation in
CLAUDE.mddirecting contributors to prefertestutil.InitRepo()for test repos, and introduces a small helper (initOpenedTestRepo) to de-duplicate this pattern ingit_operations_test.go.Reviewed by Cursor Bugbot for commit 58ce965. Configure here.