Skip to content

Prefer testutil.InitRepo in trivial git test setup#979

Merged
pfleidi merged 3 commits intomainfrom
fix/git-init-instructions
Apr 17, 2026
Merged

Prefer testutil.InitRepo in trivial git test setup#979
pfleidi merged 3 commits intomainfrom
fix/git-init-instructions

Conversation

@pfleidi
Copy link
Copy Markdown
Contributor

@pfleidi pfleidi commented Apr 17, 2026

Summary

  • clarify repo guidance to prefer testutil.InitRepo() over direct git.PlainInit() in trivial test setup
  • convert verified-trivial normal-repo tests in explain_test.go, git_operations_test.go, phase_wiring_test.go, and session/state_test.go
  • leave merge-heavy, no-config, and other non-trivial git.PlainInit() cases unchanged

Test Plan

  • go test ./cmd/entire/cli ./cmd/entire/cli/session
  • go 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 with testutil.InitRepo(t, dir) (and git.PlainOpen when a *git.Repository is still needed), reducing dependence on global git config and avoiding GPG/user config pitfalls in CI.

Adds explicit documentation in CLAUDE.md directing contributors to prefer testutil.InitRepo() for test repos, and introduces a small helper (initOpenedTestRepo) to de-duplicate this pattern in git_operations_test.go.

Reviewed by Cursor Bugbot for commit 58ce965. Configure here.

pfleidi added 3 commits April 17, 2026 13:58
Entire-Checkpoint: 4c046cef95cf
Entire-Checkpoint: 2d1b3c1467ae
Entire-Checkpoint: 25428292449e
@pfleidi pfleidi requested a review from a team as a code owner April 17, 2026 21:33
Copilot AI review requested due to automatic review settings April 17, 2026 21:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 with testutil.InitRepo() in several test files.
  • Added a small helper in git_operations_test.go to reduce repetition when initializing and opening a repo.
  • Updated CLAUDE.md to explicitly document the preference for testutil.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.

Comment thread cmd/entire/cli/explain_test.go
Copy link
Copy Markdown
Contributor

@alishakawaguchi alishakawaguchi left a comment

Choose a reason for hiding this comment

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

🥇

@pfleidi pfleidi merged commit 68a4cbb into main Apr 17, 2026
14 checks passed
@pfleidi pfleidi deleted the fix/git-init-instructions branch April 17, 2026 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants