Test git client with real repositories by williammartin · Pull Request #14348 · cli/cli · GitHub
Skip to content

Test git client with real repositories - #14348

Draft
williammartin wants to merge 2 commits into
trunkfrom
williammartin-git-real-repo-test-harness
Draft

williammartin wants to merge 2 commits into
trunkfrom
williammartin-git-real-repo-test-harness

Conversation

@williammartin

Copy link
Copy Markdown
Member

N/A

Description

Several git.Client tests emulate Git by re-executing the test binary with hand-authored output. This makes the tests describe the mock protocol rather than repository behavior, slows race runs, and breaks coverage instrumentation when helper subprocesses discard Go's coverage environment.

This adds a small hermetic temporary-repository harness and converts a pilot cluster covering current branches, config, working-tree changes, remote URLs, ignore rules, and remote resolution. Narrow fakes remain for non-portable failures and exact -- argument-safety contracts. Helper subprocesses now inherit the parent environment so package coverage works.

How did you test this change?

Not tested manually because this refactors test implementation only and does not change production behavior.

Key points

The temporary repositories are sequential because Git configuration isolation currently uses t.Setenv. Synthetic tests remain only where real Git cannot portably produce a precise error or where exact command construction is the safety contract.

Notes for reviewers

Start with newTestRepo and its run helper, then review the converted scenarios. This is stack layer 1; stack metadata will be registered separately after the remaining layers exist.

Authorship and follow-up

Who wrote this:

  • A human wrote it.
  • An agent wrote it under close human direction.
  • An agent wrote it independently, and no human has guided the implementation beyond the initial prompt.

Who answers review comments:

  • @williammartin will read and reply directly. Name the account.
  • An agent will draft replies and @username will read them before they are posted.
  • Nobody has explicitly committed to replying.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 4, 2026 14:57
@williammartin
williammartin requested a review from a team as a code owner September 4, 2026 14:57
@williammartin
williammartin marked this pull request as draft September 4, 2026 14:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The push-revision test compares the actual Git error against itself instead of the expected fixture.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Balanced
Findings: 1 Medium severity

New issues introduced by this change (1)
Severity Finding
Medium severity git/​client_test.go — 🛑 Requirement: Inspect the expected error, not the actual error This branch currently extracts…
What changed in this PR

Refactors Git client tests to exercise real temporary repositories while retaining targeted command fakes.

Changes:

  • Adds an isolated temporary-repository test harness.
  • Converts branch, config, remote, ignore, and working-tree tests.
  • Preserves coverage environment variables in helper subprocesses.
File Description
git/​client_test.go Refactors Git client tests and subprocess helpers.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread git/client_test.go Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 6b88dd22-b2ac-412c-b339-c5c0bd03e5dc

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.

2 participants