Files
archived-orca/src/main/git/fork-sync.ts
T

32 lines
1.0 KiB
TypeScript

import { normalizeGitErrorMessage } from '../../shared/git/remotes/git-remote-error'
import {
syncForkDefaultBranch,
type GitForkSyncExpectedUpstream,
type GitForkSyncResult
} from '../../shared/git/remotes/git-fork-sync'
import type { GitRuntimeOptions } from './git-runtime-options'
import { gitOptionsForWorktree } from './git-runtime-options'
import { gitExecFileAsync } from './runner'
import { abortSignalWithTimeout } from '../lib/abort-signal-with-timeout'
export async function gitSyncForkDefaultBranch(
worktreePath: string,
expectedUpstream: GitForkSyncExpectedUpstream,
options: GitRuntimeOptions = {}
): Promise<GitForkSyncResult> {
const signal = abortSignalWithTimeout(options.signal, 60_000)
try {
return await syncForkDefaultBranch(
(args) =>
gitExecFileAsync(args, {
...gitOptionsForWorktree(worktreePath, options),
timeout: 60_000,
signal
}),
{ expectedUpstream }
)
} catch (error) {
throw new Error(normalizeGitErrorMessage(error, 'push'))
}
}