Expand description
§Local Git subprocess handlers
Mirrors stock VS Code’s ILocalGitService API
(src/vs/platform/git/common/localGitService.ts) plus two
Land-specific extensions: HandleExec for arbitrary argv
(used by the Git extension) and HandleIsAvailable for
synchronous feature detection.
Cancellation discipline: every long-running entry point
takes an operationId; the spawned PID is registered in
Shared::RunningProcesses for the duration of the run.
HandleCancel(operationId) looks the PID up and
SIGTERMs / taskkills it so the renderer can fire cancel
from a different tauri::invoke than the one that started
the operation.
Layout (one export per file, file name = identity):
HandleExec::HandleExec- arbitrary argv (object or positional shape).HandleClone::HandleClone,HandlePull::HandlePull,HandleCheckout::HandleCheckout,HandleRevParse::HandleRevParse,HandleFetch::HandleFetch,HandleRevListCount::HandleRevListCount- curatedgitoperations.HandleCancel::HandleCancel- SIGTERM / taskkill by op id.HandleIsAvailable::HandleIsAvailable- cachedgit --versionprobe.
Shared (private) - RunGit, the process registry,
and small parsers.
Modules§
- Handle
Cancel localGit:cancel(operationId)- SIGTERM (Unix) ortaskkill /T /F(Windows) the pid stashed forOperationId. Silent no-op when the id is unknown so late-arriving cancels for already-finished operations don’t spam errors.- Handle
Checkout localGit:checkout(operationId, repoPath, treeish, detached?).Detached=trueadds--detachso the caller can land on a commit hash without creating a tracking branch.- Handle
Clone localGit:clone(operationId, cloneUrl, targetPath, ref?). Optionalrefbecomes--branch <ref>so callers can shallow-clone a tag or branch.- Handle
Exec localGit:exec- arbitrarygitargv. Used by the Git extension for commands not on the curatedclone/pull/…list. Accepts both the modern{ Arguments, cwd?, operationId? }shape and the legacy positional(argv: string[], cwd?: string).- Handle
Fetch localGit:fetch(operationId, repoPath). Plaingit fetchagainst the configured upstream - no remote argument, no--all, mirroring stock VS Code’sLocalGitService.fetch.- Handle
IsAvailable localGit:isAvailable -> bool. Cheapgit --versionprobe cached in aOnceLockfor the process lifetime so the UI’s periodic poll doesn’t re-exec git every interval.- Handle
Pull localGit:pull(operationId, repoPath) -> bool. Three-call sequence: read HEAD,pull --ff-only, read HEAD again. Returnstruewhen the second HEAD differs from the first (i.e. the pull actually moved the branch).--ff-onlyavoids surprise merge commits - callers handle non-FF cases explicitly.- Handle
RevList Count localGit:revListCount(repoPath, fromRef, toRef) -> u64. Equivalent togit rev-list --count from..to- counts commits the GitLens / SCM viewlet “ahead/behind” badges display.- Handle
RevParse localGit:revParse(repoPath, ref) -> string. Defaultsref=HEADso the caller can pass two args or three. Output is trimmed -git rev-parseships a trailing newline that breaks string equality on the JS side.- Shared 🔒
- Shared helpers for the
Git/*atomic handlers. Holds: