Files
orca/src/main/github/pr-head-tracking-ref.ts
T
0ec3882cb8 Add project Windows runtime selection (#5519)
* Add project Windows runtime selection

* Fix project Windows runtime selection

Co-authored-by: Orca <help@stably.ai>

* fix: preserve WSL shell variables

---------

Co-authored-by: Jinwoo-H <jinwoo0825@gmail.com>
Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Neil <neil@stably.ai>
2026-06-17 16:08:14 -07:00

31 lines
1.0 KiB
TypeScript

import { gitExecFileAsync } from '../git/runner'
import type { SshGitProvider } from '../providers/ssh-git-provider'
type LocalGitExecOptions = {
cwd: string
wslDistro?: string
}
// Why: the relay's read-only git.exec channel rejects `fetch`, so SSH repos
// must use the dedicated git.fetchRemoteTrackingRef RPC.
export async function fetchPrHeadTrackingRef(
repo: { path: string; connectionId?: string | null },
sshGitProvider: SshGitProvider | null | undefined,
remote: string,
branch: string,
options: { localGitExecOptions?: LocalGitExecOptions } = {}
): Promise<void> {
const ref = `refs/remotes/${remote}/${branch}`
if (!repo.connectionId) {
await gitExecFileAsync(
['fetch', remote, `+refs/heads/${branch}:${ref}`],
options.localGitExecOptions ?? { cwd: repo.path }
)
return
}
if (!sshGitProvider) {
throw new Error('SSH Git provider is not available. Reconnect to this target and try again.')
}
await sshGitProvider.fetchRemoteTrackingRef(repo.path, remote, branch, ref)
}