Skip to content

feat(analysis): honor Git lazy fetching in partial clones - #2158

Merged
lizhengfeng101 merged 7 commits into
mainfrom
feat/analysis-lazy-fetch
Dec 2, 2026
Merged

lizhengfeng101 merged 7 commits into
mainfrom
feat/analysis-lazy-fetch

Conversation

@lizhengfeng101

Copy link
Copy Markdown
Contributor

Description

ocr review --analysis used to stop when a partial clone lacked a required blob, even if ordinary Review could read it from the configured promisor remote. Let Git fetch objects on demand while preparing the patch and reading authorized files at the selected revisions. This covers unchanged dependencies without checking out files or prefetching the full history.

Analysis honors GIT_NO_LAZY_FETCH and Git protocol restrictions, and reports recognized promisor failures without copying their raw transport messages. No new CLI flag or configuration is required, and ordinary Review keeps its comments and exit status if Analysis fails.

Open Review Items

The pre-commit review flagged transport environment settings that Analysis currently drops (including custom CA and SSH settings), raw stderr in some error paths, and cancellation of descendant fetch processes. These need resolution before merge. The diagnostics for missing objects also need more coverage outside the tested promisor failure paths.

Type of Change

  • New feature
  • Documentation update

How Has This Been Tested?

  • make check, make build, and make test passed locally. make coverage reported 91.7% (90% required).
  • Tested fresh blob:none clones with a local remote on Git 2.43.0 and 2.54.0. Verified cold patch preparation, authorized reads of unchanged files, excluded paths, explicit no-fetch and protocol restrictions, and an unavailable remote. The worktree stayed empty and an unrelated historical blob stayed missing.
  • A stub-model CLI test submitted an Analysis report; a separate failure case compared the ordinary Review comment and exit outcome with and without Analysis.

Checklist

  • Code style, tests, and CLI documentation are up to date.
  • Contributor has personally reviewed the changes and the AI-assisted content.
  • Contributor has signed the CLA.

AI assistance: OpenAI Codex CLI (gpt-6.2-astra) assisted with implementation, testing, and drafting this PR. OpenCodeReview (gpt-6.2-astra) was used for the pre-commit review.

Related Issues

Closes #2156.

@lizhengfeng101
lizhengfeng101 marked this pull request as ready for review December 1, 2026 14:21
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

OpenCodeReview · Complete review: 3 of 3 selected files covered

1 finding.

  • Successfully posted inline: 1 comment(s)
Review info

Reviewed commits: af97d1e87dc3ce119891b7dfa2a08cee31795efb → d936a1f422b64b4415ab5f5e8f55b5e38ff8ee0b

File Result
internal/behaviortask/runner.go Reviewed
internal/behaviortask/code.go Reviewed
internal/gitcmd/runner.go Reviewed

Comment thread internal/behaviortask/runner.go Outdated
Comment on lines +295 to +298
case errors.Is(err, gitcmd.ErrFetchProhibited):
return "analysis preparation: " + gitcmd.ErrFetchProhibited.Error()
case errors.Is(err, gitcmd.ErrFetchFailed):
return "analysis preparation: " + gitcmd.ErrFetchFailed.Error()

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.

bug · medium
The "analysis preparation:" prefix is misleading. These fetch errors can occur during tool execution mid-analysis (via codeTools.execute() → provider.Execute()), not only during the initial ForAnalysis setup. A user seeing "analysis preparation: required Git object unavailable: fetch from the promisor remote failed" would incorrectly assume the failure happened before analysis started, when it actually occurred while reading code during the LLM loop.

Consider removing the prefix or using a more accurate one like "git object access:".

@css521 css521 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@lizhengfeng101
lizhengfeng101 merged commit c445fb4 into main Dec 2, 2026
15 checks passed
@lizhengfeng101
lizhengfeng101 deleted the feat/analysis-lazy-fetch branch December 2, 2026 08:38
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.

feat(analysis): honor Git lazy fetching in partial clones by default

2 participants