Files
orca/src/preload/api/git-bridge.ts
T

270 lines
9.6 KiB
TypeScript

import type {
GitCommitAction,
GitCommitActionResult
} from '../../shared/git/commands/git-commit-action'
import { ipcRenderer } from 'electron'
import type {
GitForkSyncExpectedUpstream,
GitForkSyncResult
} from '../../shared/git/remotes/git-fork-sync'
import type { GitStagingArea, GitUpstreamStatus } from '../../shared/git/status/git-status-types'
import type { ConflictResolution } from '../../shared/source-control/listing/source-control-entry-actions'
import type { GitPushTarget } from '../../shared/worktree/types'
import type { GitStageWorktreeScope } from '../../shared/git/paths/git-stage-worktree-scope'
import type {
GitHistoryItemRef,
GitHistoryOptions,
GitHistoryResult
} from '../../shared/git/history/git-history-types'
import type { PreloadApi } from '../api-types'
export const gitApi = {
status: (args: {
worktreePath: string
connectionId?: string
includeIgnored?: boolean
bypassEffectiveUpstreamNegativeCache?: boolean
reuseLineStats?: boolean
branchLineTotalMergeBase?: string
requestToken?: string
wakeWslDistro?: boolean
}) => ipcRenderer.invoke('git:status', args),
cancelStatus: (args: { requestToken: string }): Promise<void> =>
ipcRenderer.invoke('git:cancelStatus', args),
setStatusUpstreamRefWatch: (args: {
worktreeId: string
worktreePath: string
executionHostId: string
connectionId?: string
branch?: string
upstreamName?: string
}): Promise<void> => ipcRenderer.invoke('git:setStatusUpstreamRefWatch', args),
submoduleStatus: (args: {
worktreePath: string
submodulePath: string
connectionId?: string
area?: GitStagingArea
}) => ipcRenderer.invoke('git:submoduleStatus', args),
checkIgnored: (args: {
worktreePath: string
paths: string[]
connectionId?: string
}): Promise<string[]> => ipcRenderer.invoke('git:checkIgnored', args),
findHugeFoldersToIgnore: (args: { worktreePath: string }): Promise<string[]> =>
ipcRenderer.invoke('git:findHugeFoldersToIgnore', args),
appendGitignore: (args: { worktreePath: string; folderName: string }): Promise<boolean> =>
ipcRenderer.invoke('git:appendGitignore', args),
refs: (args: {
worktreePath: string
connectionId?: string
query?: string
}): Promise<GitHistoryItemRef[]> => ipcRenderer.invoke('git:refs', args),
history: (
args: {
worktreePath: string
connectionId?: string
wakeWslDistro?: boolean
} & GitHistoryOptions
): Promise<GitHistoryResult> => ipcRenderer.invoke('git:history', args),
conflictOperation: (args: { worktreePath: string; connectionId?: string }) =>
ipcRenderer.invoke('git:conflictOperation', args),
mutationInFlight: (args: { worktreePath: string; connectionId?: string }) =>
ipcRenderer.invoke('git:mutationInFlight', args),
abortMerge: (args: { worktreePath: string; connectionId?: string }): Promise<void> =>
ipcRenderer.invoke('git:abortMerge', args),
abortRebase: (args: { worktreePath: string; connectionId?: string }): Promise<void> =>
ipcRenderer.invoke('git:abortRebase', args),
diff: (args: {
worktreePath: string
filePath: string
staged: boolean
compareAgainstHead?: boolean
oldPath?: string
connectionId?: string
wakeWslDistro?: boolean
}) => ipcRenderer.invoke('git:diff', args),
branchCompare: (args: { worktreePath: string; baseRef: string; connectionId?: string }) =>
ipcRenderer.invoke('git:branchCompare', args),
commitCompare: (args: { worktreePath: string; commitId: string; connectionId?: string }) =>
ipcRenderer.invoke('git:commitCompare', args),
upstreamStatus: (args: {
worktreePath: string
connectionId?: string
pushTarget?: GitPushTarget
}): Promise<GitUpstreamStatus> => ipcRenderer.invoke('git:upstreamStatus', args),
fetch: (args: {
worktreePath: string
worktreeId?: string
connectionId?: string
pushTarget?: GitPushTarget
}): Promise<void> => ipcRenderer.invoke('git:fetch', args),
syncFork: (args: {
worktreePath: string
connectionId?: string
expectedUpstream: GitForkSyncExpectedUpstream
}): Promise<GitForkSyncResult> => ipcRenderer.invoke('git:syncFork', args),
push: (args: {
worktreePath: string
worktreeId?: string
publish?: boolean
forceWithLease?: boolean
connectionId?: string
pushTarget?: unknown
}): Promise<void> => ipcRenderer.invoke('git:push', args),
pull: (args: {
worktreePath: string
worktreeId?: string
connectionId?: string
pushTarget?: GitPushTarget
}): Promise<void> => ipcRenderer.invoke('git:pull', args),
fastForward: (args: {
worktreePath: string
worktreeId?: string
connectionId?: string
pushTarget?: GitPushTarget
}): Promise<void> => ipcRenderer.invoke('git:fastForward', args),
rebaseFromBase: (args: {
worktreePath: string
baseRef: string
connectionId?: string
}): Promise<void> => ipcRenderer.invoke('git:rebaseFromBase', args),
branchDiff: (args: {
worktreePath: string
compare: { baseRef: string; baseOid: string; headOid: string; mergeBase: string }
filePath: string
oldPath?: string
connectionId?: string
wakeWslDistro?: boolean
}) => ipcRenderer.invoke('git:branchDiff', args),
commitDiff: (args: {
worktreePath: string
commitOid: string
parentOid?: string | null
filePath: string
oldPath?: string
connectionId?: string
wakeWslDistro?: boolean
}) => ipcRenderer.invoke('git:commitDiff', args),
commit: (args: {
worktreePath: string
message: string
connectionId?: string
}): Promise<{ success: boolean; error?: string }> => ipcRenderer.invoke('git:commit', args),
createBranch: (args: {
worktreePath: string
name: string
startPoint: string
connectionId?: string
}): Promise<GitCommitActionResult> => ipcRenderer.invoke('git:createBranch', args),
cherryPick: (args: {
worktreePath: string
commitId: string
connectionId?: string
}): Promise<GitCommitActionResult> => ipcRenderer.invoke('git:cherryPick', args),
revert: (args: {
worktreePath: string
commitId: string
connectionId?: string
}): Promise<GitCommitActionResult> => ipcRenderer.invoke('git:revert', args),
sequencerAbort: (args: {
worktreePath: string
operation: GitCommitAction
connectionId?: string
}): Promise<void> => ipcRenderer.invoke('git:sequencerAbort', args),
sequencerContinue: (args: {
worktreePath: string
operation: GitCommitAction
connectionId?: string
}): Promise<GitCommitActionResult | void> => ipcRenderer.invoke('git:sequencerContinue', args),
completeMerge: (args: {
worktreePath: string
connectionId?: string
}): Promise<{ success: boolean; error?: string }> =>
ipcRenderer.invoke('git:completeMerge', args),
generateCommitMessage: (args: {
worktreePath: string
worktreeId?: string
repoId?: string
connectionId?: string
sourceControlAiResolvedParams?: unknown
sourceControlAi?: unknown
agentCmdOverrides?: Record<string, string>
}) => ipcRenderer.invoke('git:generateCommitMessage', args),
discoverTerminalModels: (args: { agentId: string; worktree?: string }) =>
ipcRenderer.invoke('agent:discoverTerminalModels', args),
discoverCommitMessageModels: (args: {
agentId: string
worktreePath?: string
connectionId?: string
}) => ipcRenderer.invoke('git:discoverCommitMessageModels', args),
cancelGenerateCommitMessage: (args: {
worktreePath: string
connectionId?: string
}): Promise<void> => ipcRenderer.invoke('git:cancelGenerateCommitMessage', args),
generatePullRequestFields: (args: {
worktreePath: string
worktreeId?: string
repoId?: string
base: string
title: string
body: string
draft: boolean
provider?: unknown
useTemplate?: boolean
connectionId?: string
sourceControlAiResolvedParams?: unknown
sourceControlAi?: unknown
agentCmdOverrides?: Record<string, string>
}) => ipcRenderer.invoke('git:generatePullRequestFields', args),
cancelGeneratePullRequestFields: (args: {
worktreePath: string
connectionId?: string
}): Promise<void> => ipcRenderer.invoke('git:cancelGeneratePullRequestFields', args),
stage: (args: { worktreePath: string; filePath: string; connectionId?: string }): Promise<void> =>
ipcRenderer.invoke('git:stage', args),
resolveConflict: (args: {
worktreePath: string
filePath: string
resolution: ConflictResolution
connectionId?: string
}): Promise<void> => ipcRenderer.invoke('git:resolveConflict', args),
bulkStage: (args: {
worktreePath: string
filePaths: string[]
connectionId?: string
scope?: GitStageWorktreeScope
}): Promise<void> => ipcRenderer.invoke('git:bulkStage', args),
unstage: (args: {
worktreePath: string
filePath: string
connectionId?: string
}): Promise<void> => ipcRenderer.invoke('git:unstage', args),
bulkUnstage: (args: {
worktreePath: string
filePaths: string[]
connectionId?: string
}): Promise<void> => ipcRenderer.invoke('git:bulkUnstage', args),
discard: (args: {
worktreePath: string
filePath: string
connectionId?: string
}): Promise<void> => ipcRenderer.invoke('git:discard', args),
bulkDiscard: (args: {
worktreePath: string
filePaths: string[]
connectionId?: string
}): Promise<void> => ipcRenderer.invoke('git:bulkDiscard', args),
remoteFileUrl: (args: {
worktreePath: string
relativePath: string
line: number
endLine?: number
connectionId?: string
}): Promise<string | null> => ipcRenderer.invoke('git:remoteFileUrl', args),
remoteCommitUrl: (args: {
worktreePath: string
sha: string
connectionId?: string
}): Promise<string | null> => ipcRenderer.invoke('git:remoteCommitUrl', args)
} satisfies PreloadApi['git']