Skip to content

fix(workspace): fetch PR refs from real remote, not local origin - #271

Merged
xytan0056 merged 1 commit into
mainfrom
fix/gitrequest-fetch-remote
Aug 6, 2026
Merged

fix(workspace): fetch PR refs from real remote, not local origin#271
xytan0056 merged 1 commit into
mainfrom
fix/gitrequest-fetch-remote

Conversation

@xytan0056

@xytan0056 xytan0056 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Worker clones created by the repo manager use git clone --local, so their origin remote points to the local origin directory — which has no refs/pull/* refs. gitRequest.Apply() was fetching from "origin", causing couldn't find remote ref pull/NNN/head errors.
  • Thread the real remote URL (build.Remote) through NewRequest and NewGitRequest so the fetch targets the actual GitHub remote.
  • Also fix path parsing to properly extract the PR number from both legacy (github://org/repo/pull/123) and canonical (github://host/org/repo/pull/123/head_sha) URI formats.

Test plan

CI

Local test

make run-server

➜  tango bazel run //example/client -- \
  -method get-changed-targets \
  -remote https://github.com/uber/tango.git \
  -base-sha 6eaa518b66f0fa7e6822cef021df9618ff8fb10e \
  -new-base-sha 6eaa518b66f0fa7e6822cef021df9618ff8fb10e \
  -new-request-urls 'github://github.com/uber/tango/pull/191/2224a38ca1d3cd01b38e1102e6ec6a2baed1becb'

@xytan0056
xytan0056 requested review from a team as code owners August 6, 2026 01:26
@xytan0056
xytan0056 force-pushed the fix/gitrequest-fetch-remote branch 3 times, most recently from c6da594 to a1ccd9b Compare August 6, 2026 01:42
Comment thread core/workspace/request.go Outdated
case "github":
prNumber, headSHA := parseGitHubPath(u.Path)
if prNumber == "" {
return nil, fmt.Errorf("could not extract PR number from path %q", u.Path)

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.

nit: we should probably classify these as UserError on the orchestrator.

Comment thread core/workspace/request.go Outdated
}
return NewGitRequest(g, pr.Number, baseRef, pr.HeadSHA, logger), nil
if headSHA == "" {
return nil, fmt.Errorf("change URI must include a head SHA: %q", rawURL)

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.

same here

Worker clones created by the repo manager use git clone --local, so
their 'origin' remote points to the local origin directory — which
has no refs/pull/* refs. gitRequest.Apply() was fetching from 'origin',
causing 'couldn't find remote ref pull/NNN/head' errors.

Add a remote field to gitRequest and reconstruct the HTTPS URL from
the parsed change URI (host/org/repo) so the fetch targets the actual
GitHub remote.
@xytan0056
xytan0056 force-pushed the fix/gitrequest-fetch-remote branch from a1ccd9b to 914788e Compare August 6, 2026 02:02
@xytan0056
xytan0056 merged commit 25e7320 into main Aug 6, 2026
10 checks passed
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