Skip to content

[Bug] fix Invoke-Git exit code propagation when using Start-Job proxy #6470

@coderabbitai

Description

@coderabbitai

Problem

The Invoke-Git function in lib/core.ps1 does not properly propagate Git process exit codes when using the Start-Job proxy path. Callers that check $LASTEXITCODE after Invoke-Git operations see the job/cmdlet status instead of the underlying Git exit code.

Root Cause

In the proxy path (Start-Job … & $using:git), the job's exit code isn't marshaled back to the parent shell. The current implementation only returns the output but doesn't capture or set the Git process exit code.

Impact

This affects multiple parts of the codebase that rely on $LASTEXITCODE after Invoke-Git calls:

  • lib/buckets.ps1 (lines 149–153, 156–160) – checks on $LASTEXITCODE after Invoke-Git for ls-remote and clone
  • libexec/scoop-status.ps1 (lines 24–28) – sets $script:network_failure from $LASTEXITCODE after fetch
  • bin/auto-pr.ps1 (lines 108–112, 136–140, 158–162) – multiple if ($LASTEXITCODE -gt 0) guards

Expected Behavior

All callers should reliably observe Git's exit status under both proxy and non-proxy configurations.

Context

This issue was identified during code review of PR #6370 which adds historical manifest search functionality. The issue is separate from that PR's scope.

Related:

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions