@gitkraken/core-gitlens 0.32.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -1
- package/dist/git/cache.d.ts +121 -15
- package/dist/git/cache.js +316 -74
- package/dist/git/cache.js.map +1 -1
- package/dist/git/context.d.ts +3 -1
- package/dist/git/context.js.map +1 -1
- package/dist/git/errors.d.ts +3 -1
- package/dist/git/errors.js +4 -1
- package/dist/git/errors.js.map +1 -1
- package/dist/git/models/pullRequest.d.ts +90 -1
- package/dist/git/models/pullRequest.js +18 -2
- package/dist/git/models/pullRequest.js.map +1 -1
- package/dist/git/models/repositoryIdentities.d.ts +0 -1
- package/dist/git/models/repositoryIdentities.js +1 -4
- package/dist/git/models/repositoryIdentities.js.map +1 -1
- package/dist/git/providers/provider.d.ts +7 -0
- package/dist/git/providers/shared/remotes.js +2 -0
- package/dist/git/providers/shared/remotes.js.map +1 -1
- package/dist/git/remotes/gitlab.js +15 -9
- package/dist/git/remotes/gitlab.js.map +1 -1
- package/dist/git/service.js +4 -1
- package/dist/git/service.js.map +1 -1
- package/dist/git/utils/pullRequest.utils.d.ts +72 -1
- package/dist/git/utils/pullRequest.utils.js +99 -1
- package/dist/git/utils/pullRequest.utils.js.map +1 -1
- package/dist/git/utils/repository.utils.d.ts +16 -0
- package/dist/git/utils/repository.utils.js +37 -2
- package/dist/git/utils/repository.utils.js.map +1 -1
- package/dist/git/watching/changeEvent.d.ts +13 -3
- package/dist/git/watching/changeEvent.js +19 -4
- package/dist/git/watching/changeEvent.js.map +1 -1
- package/dist/git/watching/gitDirPoller.d.ts +10 -1
- package/dist/git/watching/gitDirPoller.js +9 -3
- package/dist/git/watching/gitDirPoller.js.map +1 -1
- package/dist/git/watching/unwatchedCacheValidator.d.ts +144 -0
- package/dist/git/watching/unwatchedCacheValidator.js +884 -0
- package/dist/git/watching/unwatchedCacheValidator.js.map +1 -0
- package/dist/git/watching/watchGroup.d.ts +6 -2
- package/dist/git/watching/watchGroup.js +35 -24
- package/dist/git/watching/watchGroup.js.map +1 -1
- package/dist/git/watching/watchService.d.ts +27 -1
- package/dist/git/watching/watchService.js +60 -17
- package/dist/git/watching/watchService.js.map +1 -1
- package/dist/git/watching/watchSession.d.ts +29 -12
- package/dist/git/watching/watchSession.js +52 -21
- package/dist/git/watching/watchSession.js.map +1 -1
- package/dist/git/watching/worktreeSummary.js +7 -7
- package/dist/git/watching/worktreeSummary.js.map +1 -1
- package/dist/git-cli/cliGitProvider.d.ts +28 -2
- package/dist/git-cli/cliGitProvider.js +63 -20
- package/dist/git-cli/cliGitProvider.js.map +1 -1
- package/dist/git-cli/exec/commandClassifier.d.ts +31 -1
- package/dist/git-cli/exec/commandClassifier.js +67 -16
- package/dist/git-cli/exec/commandClassifier.js.map +1 -1
- package/dist/git-cli/exec/git.d.ts +46 -2
- package/dist/git-cli/exec/git.js +87 -9
- package/dist/git-cli/exec/git.js.map +1 -1
- package/dist/git-cli/exec/gitDirResolver.d.ts +11 -0
- package/dist/git-cli/exec/gitDirResolver.js +34 -1
- package/dist/git-cli/exec/gitDirResolver.js.map +1 -1
- package/dist/git-cli/exec/gitQueue.js +2 -28
- package/dist/git-cli/exec/gitQueue.js.map +1 -1
- package/dist/git-cli/providers/branches.d.ts +1 -0
- package/dist/git-cli/providers/branches.js +21 -10
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/dist/git-cli/providers/config.d.ts +15 -1
- package/dist/git-cli/providers/config.js +67 -22
- package/dist/git-cli/providers/config.js.map +1 -1
- package/dist/git-cli/providers/pausedOperations.d.ts +1 -0
- package/dist/git-cli/providers/pausedOperations.js +4 -0
- package/dist/git-cli/providers/pausedOperations.js.map +1 -1
- package/dist/git-cli/providers/revision.js +2 -0
- package/dist/git-cli/providers/revision.js.map +1 -1
- package/dist/git-cli/providers/worktrees.js +36 -10
- package/dist/git-cli/providers/worktrees.js.map +1 -1
- package/dist/git-cli/service.d.ts +25 -1
- package/dist/git-cli/service.js +46 -1
- package/dist/git-cli/service.js.map +1 -1
- package/dist/plus/ai/errors.d.ts +8 -2
- package/dist/plus/ai/errors.js +15 -3
- package/dist/plus/ai/errors.js.map +1 -1
- package/dist/plus/git-github/api/github.d.ts +51 -1
- package/dist/plus/git-github/api/github.js +276 -3
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/models.d.ts +54 -1
- package/dist/plus/git-github/models.js +48 -3
- package/dist/plus/git-github/models.js.map +1 -1
- package/dist/plus/integrations/fieldPresence.d.ts +6 -1
- package/dist/plus/integrations/fieldPresence.js +19 -9
- package/dist/plus/integrations/fieldPresence.js.map +1 -1
- package/dist/plus/integrations/models/gitHostIntegration.d.ts +26 -1
- package/dist/plus/integrations/models/gitHostIntegration.js +51 -0
- package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
- package/dist/plus/integrations/models/integration.d.ts +15 -2
- package/dist/plus/integrations/models/integration.js +1 -1
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/providers/github.d.ts +16 -1
- package/dist/plus/integrations/providers/github.js +53 -1
- package/dist/plus/integrations/providers/github.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +10 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.js +62 -15
- package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.d.ts +8 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.js +32 -16
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.js.map +1 -1
- package/dist/plus/integrations/reads/etag.js +11 -0
- package/dist/plus/integrations/reads/etag.js.map +1 -1
- package/docs/integrations.md +39 -6
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worktrees.js","names":["basename","fs"],"sources":["../../../../git-cli/src/providers/worktrees.ts"],"sourcesContent":["import { exec } from 'child_process';\nimport { promises as fs } from 'fs';\nimport { join, resolve } from 'path';\nimport * as l10n from '@vscode/l10n';\nimport type { Cache } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport { WorktreeCreateError, WorktreeDeleteError } from '@gitlens/git/errors.js';\nimport type { GitBranch } from '@gitlens/git/models/branch.js';\nimport type { WorkspaceFolderResolver } from '@gitlens/git/models/worktree.js';\nimport { GitWorktree } from '@gitlens/git/models/worktree.js';\nimport type { GitOperationRunOptions } from '@gitlens/git/providers/operations.js';\nimport type { GitWorktreesSubProvider } from '@gitlens/git/providers/worktrees.js';\nimport { isCancellationError } from '@gitlens/utils/cancellation.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport { isWindows } from '@gitlens/utils/env/node/platform.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { basename, isDescendant, normalizePath } from '@gitlens/utils/path.js';\nimport { getSettledValue } from '@gitlens/utils/promise.js';\nimport type { CacheController } from '@gitlens/utils/promiseCache.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\nimport { fileUri, toFsPath } from '@gitlens/utils/uri.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport { mayWriteTracking } from '../exec/commandClassifier.js';\nimport type { Git, GitError } from '../exec/git.js';\nimport { getGitCommandError, GitErrors, isRunHookFailure } from '../exec/git.js';\nimport type { IndexRefresher } from '../exec/indexRefresh.js';\nimport { refreshIndexAfter } from '../exec/indexRefresh.js';\nimport { parseGitWorktrees } from '../parsers/worktreeParser.js';\n\n/** Extracts the lock reason from Git's `cannot remove a locked working tree` output, when it provides one */\nfunction getLockReason(ex: GitError): string | undefined {\n\treturn GitErrors.worktreeLockedReason.exec(ex.stderr || ex.stdout || ex.message || '')?.[1].trim() || undefined;\n}\n\n/**\n * The branch `git worktree add` says it created, from the `Preparing worktree (new branch '<name>')` line it writes to\n * stderr (git 2.17+, in English since every run sets `LC_ALL=C`)\n */\nfunction getNewWorktreeBranch(stderr: string | undefined): string | undefined {\n\treturn stderr ? /^Preparing worktree \\(new branch '(.+)'\\)$/m.exec(stderr)?.[1] : undefined;\n}\n\nconst unbornSha = /^0+$/;\n\n/**\n * Where `git worktree list` contradicts the branch list it was paired with, or `undefined` when they agree. `switched`\n * holds the worktrees whose checked-out branch differs from the one the branch list places there.\n */\nfunction findStaleBranches(\n\tworktrees: readonly GitWorktree[],\n\tbranches: readonly GitBranch[],\n\t/** Whether git says where each branch is checked out (`%(worktreepath)`); before it, only the current branch's is known */\n\tknowsPaths: boolean,\n): { switched: string[] } | undefined {\n\tif (!worktrees.length) return undefined;\n\n\tconst byName = new Map<string, GitBranch>();\n\tconst byPath = new Map<string, GitBranch>();\n\tfor (const b of branches) {\n\t\t// A detached HEAD's stand-in branch names no ref\n\t\tif (b.remote || b.detached) continue;\n\n\t\tbyName.set(b.name, b);\n\t\t// A rebasing branch's worktree lists as detached\n\t\tif (b.worktree && !b.rebasing) {\n\t\t\tbyPath.set(normalizePath(b.worktree.path), b);\n\t\t}\n\t}\n\n\t// Git places a branch checked out in several worktrees (`worktree add --force`) at only one of them\n\tconst listedBranches = new Map(worktrees.map(w => [w.path, w.branchName]));\n\n\tlet stale = false;\n\tconst switched: string[] = [];\n\tfor (const w of worktrees) {\n\t\t// A bare repository checks nothing out, though git places the branch its HEAD names there\n\t\tif (w.type === 'bare') {\n\t\t\tbyPath.delete(w.path);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst listed = byPath.get(w.path);\n\t\tif (listed != null) {\n\t\t\tbyPath.delete(w.path);\n\t\t\tif (listed.name !== w.branchName) {\n\t\t\t\tswitched.push(w.path);\n\t\t\t\tstale = true;\n\t\t\t}\n\t\t} else if (knowsPaths && w.branchName != null) {\n\t\t\t// Detached, or not yet a worktree, when the branches were read\n\t\t\tswitched.push(w.path);\n\t\t}\n\n\t\t// An unborn branch has no ref for the branch list to know\n\t\tif (w.branchName == null || !w.sha || unbornSha.test(w.sha)) continue;\n\n\t\tconst branch = byName.get(w.branchName);\n\t\tif (\n\t\t\tbranch == null ||\n\t\t\t(branch.sha != null && branch.sha !== w.sha) ||\n\t\t\tbranch.worktree === false ||\n\t\t\t(branch.worktree != null && listedBranches.get(normalizePath(branch.worktree.path)) !== w.branchName)\n\t\t) {\n\t\t\tstale = true;\n\t\t}\n\t}\n\n\t// A branch placed in a worktree that no longer lists it was removed or switched away\n\tif (byPath.size) {\n\t\tstale = true;\n\t}\n\n\treturn stale ? { switched: switched } : undefined;\n}\n\nexport class WorktreesGitSubProvider implements GitWorktreesSubProvider {\n\t/** Per common path, the read whose `git worktree list` hasn't started yet */\n\tprivate readonly _unspawnedReads = new Map<string, object>();\n\t/**\n\t * Per common path, the `git worktree list` output a fresh branch list still contradicted: a layout where git's two\n\t * listings never agree, which re-reading the branches again can't fix until the list changes\n\t */\n\tprivate readonly _lastingDisagreements = new Map<string, string>();\n\n\tconstructor(\n\t\tprivate readonly context: GitServiceContext,\n\t\tprivate readonly git: Git,\n\t\tprivate readonly cache: Cache,\n\t\tprivate readonly provider: CliGitProviderInternal,\n\t\t/**\n\t\t * Reads the absolute folders whose worktrees a repository's list leaves out, rejecting (or answering `undefined`)\n\t\t * when they can't be read; given only when folders are registered\n\t\t */\n\t\tprivate readonly readIgnoredWorktreeRoots?: (repoPath: string) => Promise<readonly string[] | undefined>,\n\t\t/** Refreshes the index of a worktree it just checked out */\n\t\tprivate readonly indexRefresher?: IndexRefresher,\n\t) {}\n\n\t/**\n\t * Creates a worktree (`git worktree add`). `runOptions` are spread into the underlying `git.run` call, so a\n\t * large checkout can run without the default command timeout (`{ timeout: 0 }`) and still be cancelled.\n\t */\n\t@debug()\n\tasync createWorktree(\n\t\trepoPath: string,\n\t\tpath: string,\n\t\toptions?: {\n\t\t\tcommitish?: string;\n\t\t\tcreateBranch?: string;\n\t\t\tdetach?: boolean;\n\t\t\tforce?: boolean;\n\t\t\tnoTracking?: boolean;\n\t\t},\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst args = ['worktree', 'add'];\n\t\tif (options?.force) {\n\t\t\targs.push('--force');\n\t\t}\n\t\tif (options?.createBranch) {\n\t\t\targs.push('-b', options.createBranch);\n\t\t}\n\t\tif (options?.createBranch && options.noTracking) {\n\t\t\targs.push('--no-track');\n\t\t}\n\t\tif (options?.detach) {\n\t\t\targs.push('--detach');\n\t\t}\n\t\targs.push(path);\n\t\tif (options?.commitish) {\n\t\t\targs.push(options.commitish);\n\t\t}\n\n\t\t// Without `-b`, git may still create a branch: from a remote branch of the commitish's name, or named after the\n\t\t// path when no commitish is given\n\t\tlet createdBranch = options?.createBranch;\n\t\t// A cancelled or timed-out run, or a host-rejected retry, leaves no output to name the branch git may have created\n\t\tlet mayHaveCreatedBranch = false;\n\t\ttry {\n\t\t\tconst run = () => this.git.run({ cwd: repoPath, ...runOptions }, ...args);\n\t\t\t// A relative path is the new worktree's location from `repoPath`, where git ran\n\t\t\tconst result = await refreshIndexAfter(this.indexRefresher, normalizePath(resolve(repoPath, path)), run);\n\t\t\tcreatedBranch ??= getNewWorktreeBranch(result.stderr);\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\t// `?.`: a host's index-lock retry hook may reject with anything, `undefined` included\n\t\t\tcreatedBranch ??= getNewWorktreeBranch((ex as GitError | undefined)?.stderr);\n\n\t\t\t// A cancelled or timed-out checkout, or a host-rejected index-lock retry, is not git refusing the worktree\n\t\t\tif (isCancellationError(ex) || isRunHookFailure(ex)) {\n\t\t\t\tmayHaveCreatedBranch = createdBranch == null && !options?.detach;\n\t\t\t\tthrow ex;\n\t\t\t}\n\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'worktree-create',\n\t\t\t\tex as GitError,\n\t\t\t\treason =>\n\t\t\t\t\tnew WorktreeCreateError(\n\t\t\t\t\t\t{ reason: reason, gitCommand: { repoPath: repoPath, args: args } },\n\t\t\t\t\t\tex as GitError,\n\t\t\t\t\t),\n\t\t\t);\n\t\t} finally {\n\t\t\t// A failed or cancelled add may already have created the branch (and its tracking in `.git/config`) or\n\t\t\t// the worktree directory.\n\t\t\t//\n\t\t\t// The tracking isn't announced as a `config` change, only evicted: git may also write repository-wide\n\t\t\t// keys (`extensions.relativeWorktrees` under `worktree.useRelativePaths`), so the write can't claim its\n\t\t\t// config change is confined to the new branch, and an unconfined one would refresh every worktree on each\n\t\t\t// add. The watcher's report of the file says what changed in it instead.\n\t\t\tif (createdBranch) {\n\t\t\t\t// Evict the cached base only — see `checkout -b` for why the persisted keys are left alone.\n\t\t\t\tthis.cache.deleteBaseBranchName(repoPath, createdBranch);\n\t\t\t\t// A branch git created on its own may track a remote branch, whatever the commitish looks like\n\t\t\t\tthis.context.hooks?.cache?.onReset?.(\n\t\t\t\t\trepoPath,\n\t\t\t\t\t...(!options?.createBranch || mayWriteTracking(options.commitish, options.noTracking)\n\t\t\t\t\t\t? (['branches', 'config', 'worktrees'] as const)\n\t\t\t\t\t\t: (['branches', 'worktrees'] as const)),\n\t\t\t\t);\n\t\t\t\tthis.context.hooks?.repository?.onChanged?.(\n\t\t\t\t\trepoPath,\n\t\t\t\t\t['worktrees', 'worktreeHead', 'heads'],\n\t\t\t\t\t[`refs/heads/${createdBranch}`],\n\t\t\t\t);\n\t\t\t} else if (mayHaveCreatedBranch) {\n\t\t\t\t// Git creates the branch before checking it out, so a run cut short may have left one it never named\n\t\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'config', 'worktrees');\n\t\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['worktrees', 'worktreeHead', 'heads']);\n\t\t\t} else {\n\t\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'worktrees');\n\t\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['worktrees', 'worktreeHead']);\n\t\t\t}\n\t\t}\n\t}\n\n\tasync createWorktreeWithResult(\n\t\trepoPath: string,\n\t\tpath: string,\n\t\toptions?: {\n\t\t\tcommitish?: string;\n\t\t\tcreateBranch?: string;\n\t\t\tdetach?: boolean;\n\t\t\tforce?: boolean;\n\t\t\tnoTracking?: boolean;\n\t\t},\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<GitWorktree | undefined> {\n\t\tawait this.createWorktree(repoPath, path, options, runOptions);\n\t\tconst normalized = normalizePath(path);\n\t\treturn this.getWorktree(\n\t\t\trepoPath,\n\t\t\tw => normalizePath(w.path) === normalized,\n\t\t\tundefined,\n\t\t\trunOptions?.cancellation,\n\t\t);\n\t}\n\n\t@debug({ quiet: true })\n\tasync getWorktree(\n\t\trepoPath: string,\n\t\tpredicate: (w: GitWorktree) => boolean,\n\t\toptions?: { force?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitWorktree | undefined> {\n\t\treturn (await this.getWorktrees(repoPath, options, cancellation)).find(predicate);\n\t}\n\n\t@debug({ quiet: true })\n\tasync getWorktrees(\n\t\trepoPath: string,\n\t\toptions?: { force?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitWorktree[]> {\n\t\t// A pending read that hasn't started `git worktree list` will see the state as of this call, so it is joined,\n\t\t// whether it was pending as the call started or is once the call would evict (another forced read's, say)\n\t\tlet force = options?.force === true && !this._unspawnedReads.has(this.cache.getCommonPath(repoPath));\n\n\t\tawait this.git.ensureSupports('git:worktrees', (requiredVersion, installedVersion) =>\n\t\t\tl10n.t(\n\t\t\t\t'Displaying worktrees requires a newer version of Git (>= {0}) than is currently installed ({1}). Please install a more recent version of Git and try again.',\n\t\t\t\trequiredVersion,\n\t\t\t\tinstalledVersion,\n\t\t\t),\n\t\t);\n\n\t\tif (force && this._unspawnedReads.has(this.cache.getCommonPath(repoPath))) {\n\t\t\tforce = false;\n\t\t}\n\n\t\treturn this.cache.getWorktrees(\n\t\t\trepoPath,\n\t\t\tasync (commonPath, cacheable, signal) => {\n\t\t\t\tconst unspawned = {};\n\t\t\t\tthis._unspawnedReads.set(commonPath, unspawned);\n\t\t\t\tconst onSpawned = () => {\n\t\t\t\t\tif (this._unspawnedReads.get(commonPath) === unspawned) {\n\t\t\t\t\t\tthis._unspawnedReads.delete(commonPath);\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\ttry {\n\t\t\t\t\treturn await this.readWorktrees(repoPath, commonPath, cacheable, signal ?? cancellation, onSpawned);\n\t\t\t\t} finally {\n\t\t\t\t\tonSpawned();\n\t\t\t\t}\n\t\t\t},\n\t\t\tforce ? { force: true } : undefined,\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprivate async readWorktrees(\n\t\trepoPath: string,\n\t\tcommonPath: string,\n\t\tcacheable: CacheController,\n\t\tsignal: AbortSignal | undefined,\n\t\tonSpawn: () => void,\n\t): Promise<GitWorktree[]> {\n\t\t// Read beside the list, which it doesn't depend on. `commonPath` is the main worktree, not the git dir,\n\t\t// so the roots come from the repository's own git dir\n\t\tconst rootsRead = this.readIgnoredWorktreeRoots?.(repoPath).catch(() => undefined);\n\t\tconst [dataResult, branchesResult] = await Promise.allSettled([\n\t\t\tthis.git.run(\n\t\t\t\t{ cwd: commonPath, cancellation: signal, onSpawn: onSpawn },\n\t\t\t\t'worktree',\n\t\t\t\t'list',\n\t\t\t\t'--porcelain',\n\t\t\t),\n\t\t\tthis.provider.branches.getBranches(commonPath, undefined, signal),\n\t\t]);\n\n\t\tif (dataResult.status === 'rejected') {\n\t\t\t// Don't cache a bogus empty result for a transient command failure — retry on next access.\n\t\t\tcacheable.invalidate();\n\t\t}\n\n\t\tconst getWorkspaceFolder: WorkspaceFolderResolver | undefined = this.context.workspace\n\t\t\t? uri => {\n\t\t\t\t\tconst folder = this.context.workspace!.getFolder(uri.fsPath);\n\t\t\t\t\tif (folder == null) return undefined;\n\t\t\t\t\treturn { uri: fileUri(folder.path), name: basename(folder.path) };\n\t\t\t\t}\n\t\t\t: undefined;\n\n\t\tconst data = getSettledValue(dataResult)?.stdout;\n\t\tlet worktrees = parseGitWorktrees(\n\t\t\tdata,\n\t\t\tcommonPath,\n\t\t\tgetSettledValue(branchesResult)?.values ?? [],\n\t\t\tgetWorkspaceFolder,\n\t\t);\n\n\t\t// The branches come from the cache, which can lag the list just read (a forced read pairs a fresh list with\n\t\t// them). Where the list contradicts them it proves them stale, so they are re-read, once\n\t\tconst knowsPaths = await this.git.supports('git:for-each-ref:worktreePath');\n\t\tconst stale =\n\t\t\tbranchesResult.status === 'fulfilled'\n\t\t\t\t? findStaleBranches(worktrees, branchesResult.value.values, knowsPaths)\n\t\t\t\t: undefined;\n\t\tif (stale == null) {\n\t\t\tthis._lastingDisagreements.delete(commonPath);\n\t\t} else if (this._lastingDisagreements.get(commonPath) !== data) {\n\t\t\tthis.context.hooks?.cache?.onReset?.(commonPath, 'branches');\n\t\t\tfor (const path of stale.switched) {\n\t\t\t\tthis.context.hooks?.cache?.onReset?.(path, 'branch');\n\t\t\t}\n\n\t\t\tlet branches: GitBranch[] | undefined;\n\t\t\ttry {\n\t\t\t\t({ values: branches } = await this.provider.branches.getBranches(commonPath, undefined, signal));\n\t\t\t} catch {\n\t\t\t\t// Keep the branches matched from the stale list, but not in the cache\n\t\t\t\tcacheable.invalidate();\n\t\t\t}\n\n\t\t\tif (branches != null) {\n\t\t\t\tworktrees = parseGitWorktrees(data, commonPath, branches, getWorkspaceFolder);\n\t\t\t\tif (data != null && findStaleBranches(worktrees, branches, knowsPaths) != null) {\n\t\t\t\t\tthis._lastingDisagreements.set(commonPath, data);\n\t\t\t\t}\n\t\t\t\t// The host's views show the branches the watcher missed a change of; which moved is unknown. Only the\n\t\t\t\t// host hears it: announced as a write of core's, the watch layer would take an outside `heads` report\n\t\t\t\t// arriving meanwhile for its echo and drop it, though nothing of the kind was evicted for it\n\t\t\t\tfor (const path of new Set([commonPath, ...this.cache.getWorktreePaths(commonPath)])) {\n\t\t\t\t\tthis.provider.notifyHost(path, ['heads']);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (rootsRead != null) {\n\t\t\tconst roots = await rootsRead;\n\t\t\tif (roots == null) {\n\t\t\t\t// The folders couldn't be read: an unfiltered list would keep ignored worktrees in the shared\n\t\t\t\t// cache until the next change\n\t\t\t\tcacheable.invalidate();\n\t\t\t} else if (roots.length) {\n\t\t\t\tworktrees = worktrees.filter(w => !roots.some(root => isDescendant(normalizePath(w.path), root)));\n\t\t\t}\n\t\t}\n\n\t\t// Older git prints a bare `locked` even when a reason exists; recover it from the admin dir\n\t\tif (await this.git.supports('git:worktree:list:lock-reason')) return worktrees;\n\n\t\treturn Promise.all(worktrees.map(w => this.withLockReason(w)));\n\t}\n\n\tprivate async withLockReason(worktree: GitWorktree): Promise<GitWorktree> {\n\t\tif (worktree.locked !== true || worktree.isDefault || worktree.type === 'bare') return worktree;\n\n\t\ttry {\n\t\t\t// A linked worktree's `.git` is a file: `gitdir: <admin dir>`, relative to the worktree when not absolute\n\t\t\tconst dotGit = join(worktree.uri.fsPath, '.git');\n\t\t\tconst match = /^gitdir:\\s*(.+?)\\s*$/m.exec(await fs.readFile(dotGit, 'utf8'));\n\t\t\tif (match == null) return worktree;\n\n\t\t\tconst reason = (await fs.readFile(join(resolve(worktree.uri.fsPath, match[1]), 'locked'), 'utf8')).trim();\n\t\t\tif (!reason) return worktree;\n\n\t\t\treturn new GitWorktree(\n\t\t\t\tworktree.isDefault,\n\t\t\t\tworktree.type,\n\t\t\t\tworktree.repoPath,\n\t\t\t\tworktree.uri,\n\t\t\t\treason,\n\t\t\t\tworktree.prunable,\n\t\t\t\tworktree.sha,\n\t\t\t\tworktree.branch,\n\t\t\t\tworktree.workspaceFolder,\n\t\t\t\tworktree.branchName,\n\t\t\t);\n\t\t} catch {\n\t\t\treturn worktree;\n\t\t}\n\t}\n\n\t@debug({ quiet: true })\n\tgetWorktreesDefaultUri(repoPath: string): Uri | undefined {\n\t\treturn this.context.workspace?.getWorktreeDefaultUri?.(repoPath);\n\t}\n\n\t/**\n\t * Deletes a worktree (`git worktree remove`). Pass `force: 'locked'` to also override a locked worktree.\n\t *\n\t * `runOptions` are spread into the underlying `git.run` call (e.g. `{ timeout: 0 }` for a large worktree\n\t * whose removal may exceed the default command timeout).\n\t *\n\t * On failure, the thrown {@link WorktreeDeleteError}'s `original` property carries the raw\n\t * {@link GitError} (stderr/stdout/exit code) untouched — a caller that needs to classify a\n\t * platform-specific failure (e.g. a Windows file-lock retry) can read it directly rather than parsing\n\t * the typed error's message.\n\t */\n\t@debug()\n\tasync deleteWorktree(\n\t\trepoPath: string,\n\t\tpath: string | Uri,\n\t\toptions?: { force?: boolean | 'locked' },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\tawait this.git.ensureSupports('git:worktrees', (requiredVersion, installedVersion) =>\n\t\t\tl10n.t(\n\t\t\t\t'Deleting worktrees requires a newer version of Git (>= {0}) than is currently installed ({1}). Please install a more recent version of Git and try again.',\n\t\t\t\trequiredVersion,\n\t\t\t\tinstalledVersion,\n\t\t\t),\n\t\t);\n\n\t\tconst args = ['worktree', 'remove'];\n\t\tif (options?.force) {\n\t\t\targs.push('--force');\n\t\t\t// Git requires a second `--force` to remove a locked worktree\n\t\t\tif (options.force === 'locked') {\n\t\t\t\targs.push('--force');\n\t\t\t}\n\t\t}\n\n\t\tconst pathStr = normalizePath(toFsPath(path));\n\t\targs.push(pathStr);\n\n\t\tlet deleted = false;\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...args);\n\t\t\tdeleted = true;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\t// A cancelled or timed-out removal (`runOptions.cancellation`/`timeout`), or a host-rejected index-lock\n\t\t\t// retry, is not git refusing it, and wrapping it would hand the caller a `WorktreeDeleteError` whose\n\t\t\t// `original` is no `GitError` at all\n\t\t\tif (isCancellationError(ex) || isRunHookFailure(ex)) throw ex;\n\n\t\t\tconst gitError = getGitCommandError(\n\t\t\t\t'worktree-delete',\n\t\t\t\tex as GitError,\n\t\t\t\treason =>\n\t\t\t\t\tnew WorktreeDeleteError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason,\n\t\t\t\t\t\t\tlockReason: reason === 'locked' ? getLockReason(ex as GitError) : undefined,\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: args },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex as GitError,\n\t\t\t\t\t),\n\t\t\t);\n\n\t\t\tif (gitError.details.reason === 'directoryNotEmpty') {\n\t\t\t\tscope?.warn(\n\t\t\t\t\t`Failed to fully delete worktree '${pathStr}' because it is not empty. Attempting to delete it manually.`,\n\t\t\t\t);\n\t\t\t\ttry {\n\t\t\t\t\tawait fs.rm(pathStr, { force: true, recursive: true });\n\t\t\t\t\tdeleted = true;\n\t\t\t\t\treturn;\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (isWindows) {\n\t\t\t\t\t\tconst match = /EPERM: operation not permitted, unlink '(.*?)'/i.exec((ex as GitError).message);\n\t\t\t\t\t\tif (match != null) {\n\t\t\t\t\t\t\tscope?.warn(\n\t\t\t\t\t\t\t\t`Failed to manually delete '${pathStr}' because it is in use. Attempting to forcefully delete it.`,\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t// Windows-specific: `del` via cmd.exe to force-remove a locked symlink.\n\t\t\t\t\t\t\t// Node's fs.rm/unlink fails with EPERM when the symlink target is in use.\n\t\t\t\t\t\t\tfunction deleteInUseSymlink(symlink: string) {\n\t\t\t\t\t\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\t\t\t\t\t\texec(`del \"${symlink}\"`, (ex, stdout, stderr) => {\n\t\t\t\t\t\t\t\t\t\tif (ex) {\n\t\t\t\t\t\t\t\t\t\t\treject(ex instanceof Error ? ex : new Error(String(ex)));\n\t\t\t\t\t\t\t\t\t\t} else if (stderr) {\n\t\t\t\t\t\t\t\t\t\t\treject(new Error(stderr));\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\tresolve(stdout);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst [, file] = match;\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tawait deleteInUseSymlink(file);\n\t\t\t\t\t\t\t\tawait fs.rm(pathStr, { force: true, recursive: true, maxRetries: 1, retryDelay: 1 });\n\t\t\t\t\t\t\t\tdeleted = true;\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\t\t\tscope?.error(ex, `Failed to forcefully delete '${pathStr}' because it is in use.`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthrow gitError;\n\t\t} finally {\n\t\t\tif (deleted) {\n\t\t\t\t// Clean up Cache registry + per-worktree cache entries for the deleted worktree.\n\t\t\t\t// Order matters: unregister before emitting the repo-level change so any listener\n\t\t\t\t// that re-queries worktree-aware state sees the registry already updated.\n\t\t\t\tthis.cache.unregisterRepoPath(pathStr);\n\t\t\t}\n\t\t\t// A failed or cancelled removal may already have taken the worktree's files or admin entry\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'worktrees');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['worktrees', 'worktreeHead']);\n\t\t}\n\t}\n\n\t@debug()\n\tasync pruneWorktrees(repoPath: string, options?: { expire?: string }): Promise<void> {\n\t\tawait this.git.ensureSupports('git:worktrees', (requiredVersion, installedVersion) =>\n\t\t\tl10n.t(\n\t\t\t\t'Pruning worktrees requires a newer version of Git (>= {0}) than is currently installed ({1}). Please install a more recent version of Git and try again.',\n\t\t\t\trequiredVersion,\n\t\t\t\tinstalledVersion,\n\t\t\t),\n\t\t);\n\n\t\tconst before = await this.listWorktreePaths(repoPath);\n\n\t\tconst args = ['worktree', 'prune'];\n\t\tif (options?.expire) {\n\t\t\targs.push('--expire', options.expire);\n\t\t}\n\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath, errors: 'throw' }, ...args);\n\n\t\t\tconst after = await this.listWorktreePaths(repoPath);\n\n\t\t\t// Order matters (see `deleteWorktree`): unregister before emitting the repo-level change so any\n\t\t\t// listener that re-queries worktree-aware state sees the registry already updated.\n\t\t\tif (before != null && after != null) {\n\t\t\t\tfor (const path of before) {\n\t\t\t\t\tif (!after.has(path)) {\n\t\t\t\t\t\tthis.cache.unregisterRepoPath(path);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'worktrees');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['worktrees', 'worktreeHead']);\n\t\t}\n\t}\n\n\t/**\n\t * Raw worktree paths currently known to git (`worktree <path>` lines from `--porcelain`), normalized the\n\t * same way {@link deleteWorktree} does. A failed listing (`errors: 'ignore'`) yields an empty set rather\n\t * than throwing — used by `pruneWorktrees` to diff before/after, where a transient read failure must not\n\t * be mistaken for every worktree having vanished.\n\t */\n\tprivate async listWorktreePaths(repoPath: string): Promise<Set<string> | undefined> {\n\t\tconst result = await this.git.run({ cwd: repoPath, errors: 'ignore' }, 'worktree', 'list', '--porcelain');\n\t\t// A failed listing is not an empty one: read as empty, the after-prune one would unregister everything\n\t\tif (result.completion.status !== 'exited' || result.exitCode !== 0) return undefined;\n\n\t\tconst paths = new Set<string>();\n\t\tfor (const line of result.stdout.split('\\n')) {\n\t\t\tif (line.startsWith('worktree ')) {\n\t\t\t\tpaths.add(normalizePath(toFsPath(line.slice('worktree '.length).trim())));\n\t\t\t}\n\t\t}\n\t\treturn paths;\n\t}\n\n\t@debug()\n\tasync lockWorktree(repoPath: string, path: string | Uri, options?: { reason?: string }): Promise<void> {\n\t\tawait this.git.ensureSupports('git:worktrees', (requiredVersion, installedVersion) =>\n\t\t\tl10n.t(\n\t\t\t\t'Locking worktrees requires a newer version of Git (>= {0}) than is currently installed ({1}). Please install a more recent version of Git and try again.',\n\t\t\t\trequiredVersion,\n\t\t\t\tinstalledVersion,\n\t\t\t),\n\t\t);\n\n\t\tconst args = ['worktree', 'lock'];\n\t\tif (options?.reason) {\n\t\t\targs.push('--reason', options.reason);\n\t\t}\n\t\targs.push(normalizePath(toFsPath(path)));\n\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath, errors: 'throw' }, ...args);\n\t\t} finally {\n\t\t\t// A lock touches no worktree's HEAD, so no worktree's git results or merge targets\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'worktreeList');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['worktrees']);\n\t\t}\n\t}\n\n\t@debug()\n\tasync unlockWorktree(repoPath: string, path: string | Uri): Promise<void> {\n\t\tawait this.git.ensureSupports('git:worktrees', (requiredVersion, installedVersion) =>\n\t\t\tl10n.t(\n\t\t\t\t'Unlocking worktrees requires a newer version of Git (>= {0}) than is currently installed ({1}). Please install a more recent version of Git and try again.',\n\t\t\t\trequiredVersion,\n\t\t\t\tinstalledVersion,\n\t\t\t),\n\t\t);\n\n\t\tconst pathStr = normalizePath(toFsPath(path));\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath, errors: 'throw' }, 'worktree', 'unlock', pathStr);\n\t\t} finally {\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'worktreeList');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['worktrees']);\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA8BA,SAAS,cAAc,IAAkC;CACxD,OAAO,UAAU,qBAAqB,KAAK,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,KAAK,KAAA;AACvG;;;;;AAMA,SAAS,qBAAqB,QAAgD;CAC7E,OAAO,SAAS,8CAA8C,KAAK,MAAM,CAAC,GAAG,KAAK,KAAA;AACnF;AAEA,MAAM,YAAY;;;;;AAMlB,SA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A"}
|
|
1
|
+
{"version":3,"file":"worktrees.js","names":["basename","fs","dirname"],"sources":["../../../../git-cli/src/providers/worktrees.ts"],"sourcesContent":["import { exec } from 'child_process';\nimport { promises as fs } from 'fs';\nimport { join, resolve } from 'path';\nimport * as l10n from '@vscode/l10n';\nimport type { Cache } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport { WorktreeCreateError, WorktreeDeleteError } from '@gitlens/git/errors.js';\nimport type { GitBranch } from '@gitlens/git/models/branch.js';\nimport type { WorkspaceFolderResolver } from '@gitlens/git/models/worktree.js';\nimport { GitWorktree } from '@gitlens/git/models/worktree.js';\nimport type { GitOperationRunOptions } from '@gitlens/git/providers/operations.js';\nimport type { GitWorktreesSubProvider } from '@gitlens/git/providers/worktrees.js';\nimport { isCancellationError } from '@gitlens/utils/cancellation.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport { isWindows } from '@gitlens/utils/env/node/platform.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { basename, dirname, isDescendant, normalizePath } from '@gitlens/utils/path.js';\nimport { getSettledValue } from '@gitlens/utils/promise.js';\nimport type { CacheController } from '@gitlens/utils/promiseCache.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\nimport { fileUri, toFsPath } from '@gitlens/utils/uri.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport { mayWriteTracking } from '../exec/commandClassifier.js';\nimport type { Git, GitError } from '../exec/git.js';\nimport { getGitCommandError, GitErrors, isRunHookFailure } from '../exec/git.js';\nimport { parseGitFile } from '../exec/gitDirResolver.js';\nimport type { IndexRefresher } from '../exec/indexRefresh.js';\nimport { refreshIndexAfter } from '../exec/indexRefresh.js';\nimport { parseGitWorktrees } from '../parsers/worktreeParser.js';\n\n/** Extracts the lock reason from Git's `cannot remove a locked working tree` output, when it provides one */\nfunction getLockReason(ex: GitError): string | undefined {\n\treturn GitErrors.worktreeLockedReason.exec(ex.stderr || ex.stdout || ex.message || '')?.[1].trim() || undefined;\n}\n\n/**\n * The branch `git worktree add` says it created, from the `Preparing worktree (new branch '<name>')` line it writes to\n * stderr (git 2.17+, in English since every run sets `LC_ALL=C`)\n */\nfunction getNewWorktreeBranch(stderr: string | undefined): string | undefined {\n\treturn stderr ? /^Preparing worktree \\(new branch '(.+)'\\)$/m.exec(stderr)?.[1] : undefined;\n}\n\nconst unbornSha = /^0+$/;\n\n/**\n * Where `git worktree list` contradicts the branch list it was paired with, or `undefined` when they agree. `switched`\n * holds the worktrees whose checked-out branch differs from the one the branch list places there.\n */\nfunction findStaleBranches(\n\tworktrees: readonly GitWorktree[],\n\tbranches: readonly GitBranch[],\n\t/** Whether git says where each branch is checked out (`%(worktreepath)`); before it, only the current branch's is known */\n\tknowsPaths: boolean,\n): { switched: string[] } | undefined {\n\tif (!worktrees.length) return undefined;\n\n\tconst byName = new Map<string, GitBranch>();\n\tconst byPath = new Map<string, GitBranch>();\n\tfor (const b of branches) {\n\t\t// A detached HEAD's stand-in branch names no ref\n\t\tif (b.remote || b.detached) continue;\n\n\t\tbyName.set(b.name, b);\n\t\t// A rebasing branch's worktree lists as detached\n\t\tif (b.worktree && !b.rebasing) {\n\t\t\tbyPath.set(normalizePath(b.worktree.path), b);\n\t\t}\n\t}\n\n\t// Git places a branch checked out in several worktrees (`worktree add --force`) at only one of them\n\tconst listedBranches = new Map(worktrees.map(w => [w.path, w.branchName]));\n\n\tlet stale = false;\n\tconst switched: string[] = [];\n\tfor (const w of worktrees) {\n\t\t// A bare repository checks nothing out, though git places the branch its HEAD names there\n\t\tif (w.type === 'bare') {\n\t\t\tbyPath.delete(w.path);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst listed = byPath.get(w.path);\n\t\tif (listed != null) {\n\t\t\tbyPath.delete(w.path);\n\t\t\tif (listed.name !== w.branchName) {\n\t\t\t\tswitched.push(w.path);\n\t\t\t\tstale = true;\n\t\t\t}\n\t\t} else if (knowsPaths && w.branchName != null) {\n\t\t\t// Detached, or not yet a worktree, when the branches were read\n\t\t\tswitched.push(w.path);\n\t\t}\n\n\t\t// An unborn branch has no ref for the branch list to know\n\t\tif (w.branchName == null || !w.sha || unbornSha.test(w.sha)) continue;\n\n\t\tconst branch = byName.get(w.branchName);\n\t\tif (\n\t\t\tbranch == null ||\n\t\t\t(branch.sha != null && branch.sha !== w.sha) ||\n\t\t\tbranch.worktree === false ||\n\t\t\t(branch.worktree != null && listedBranches.get(normalizePath(branch.worktree.path)) !== w.branchName)\n\t\t) {\n\t\t\tstale = true;\n\t\t}\n\t}\n\n\t// A branch placed in a worktree that no longer lists it was removed or switched away\n\tif (byPath.size) {\n\t\tstale = true;\n\t}\n\n\treturn stale ? { switched: switched } : undefined;\n}\n\nexport class WorktreesGitSubProvider implements GitWorktreesSubProvider {\n\t/** Per common path, the read whose `git worktree list` hasn't started yet */\n\tprivate readonly _unspawnedReads = new Map<string, object>();\n\t/**\n\t * Per common path, the `git worktree list` output a fresh branch list still contradicted: a layout where git's two\n\t * listings never agree, which re-reading the branches again can't fix until the list changes\n\t */\n\tprivate readonly _lastingDisagreements = new Map<string, string>();\n\n\tconstructor(\n\t\tprivate readonly context: GitServiceContext,\n\t\tprivate readonly git: Git,\n\t\tprivate readonly cache: Cache,\n\t\tprivate readonly provider: CliGitProviderInternal,\n\t\t/**\n\t\t * Reads the absolute folders whose worktrees a repository's list leaves out, rejecting (or answering `undefined`)\n\t\t * when they can't be read; given only when folders are registered\n\t\t */\n\t\tprivate readonly readIgnoredWorktreeRoots?: (repoPath: string) => Promise<readonly string[] | undefined>,\n\t\t/** Refreshes the index of a worktree it just checked out */\n\t\tprivate readonly indexRefresher?: IndexRefresher,\n\t) {}\n\n\t/**\n\t * Creates a worktree (`git worktree add`). `runOptions` are spread into the underlying `git.run` call, so a\n\t * large checkout can run without the default command timeout (`{ timeout: 0 }`) and still be cancelled.\n\t */\n\t@debug()\n\tasync createWorktree(\n\t\trepoPath: string,\n\t\tpath: string,\n\t\toptions?: {\n\t\t\tcommitish?: string;\n\t\t\tcreateBranch?: string;\n\t\t\tdetach?: boolean;\n\t\t\tforce?: boolean;\n\t\t\tnoTracking?: boolean;\n\t\t},\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst args = ['worktree', 'add'];\n\t\tif (options?.force) {\n\t\t\targs.push('--force');\n\t\t}\n\t\tif (options?.createBranch) {\n\t\t\targs.push('-b', options.createBranch);\n\t\t}\n\t\tif (options?.createBranch && options.noTracking) {\n\t\t\targs.push('--no-track');\n\t\t}\n\t\tif (options?.detach) {\n\t\t\targs.push('--detach');\n\t\t}\n\t\targs.push(path);\n\t\tif (options?.commitish) {\n\t\t\targs.push(options.commitish);\n\t\t}\n\n\t\t// Without `-b`, git may still create a branch: from a remote branch of the commitish's name, or named after the\n\t\t// path when no commitish is given\n\t\tlet createdBranch = options?.createBranch;\n\t\t// A cancelled or timed-out run, or a host-rejected retry, leaves no output to name the branch git may have created\n\t\tlet mayHaveCreatedBranch = false;\n\t\t// A relative path is the new worktree's location from `repoPath`, where git ran\n\t\tconst worktreePath = normalizePath(resolve(repoPath, path));\n\t\ttry {\n\t\t\tconst run = () => this.git.run({ cwd: repoPath, ...runOptions }, ...args);\n\t\t\tconst result = await refreshIndexAfter(this.indexRefresher, worktreePath, run);\n\t\t\tcreatedBranch ??= getNewWorktreeBranch(result.stderr);\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\t// `?.`: a host's index-lock retry hook may reject with anything, `undefined` included\n\t\t\tcreatedBranch ??= getNewWorktreeBranch((ex as GitError | undefined)?.stderr);\n\n\t\t\t// A cancelled or timed-out checkout, or a host-rejected index-lock retry, is not git refusing the worktree\n\t\t\tif (isCancellationError(ex) || isRunHookFailure(ex)) {\n\t\t\t\tmayHaveCreatedBranch = createdBranch == null && !options?.detach;\n\t\t\t\tthrow ex;\n\t\t\t}\n\n\t\t\tthrow getGitCommandError(\n\t\t\t\t'worktree-create',\n\t\t\t\tex as GitError,\n\t\t\t\treason =>\n\t\t\t\t\tnew WorktreeCreateError(\n\t\t\t\t\t\t{ reason: reason, gitCommand: { repoPath: repoPath, args: args } },\n\t\t\t\t\t\tex as GitError,\n\t\t\t\t\t),\n\t\t\t);\n\t\t} finally {\n\t\t\t// A failed or cancelled add may already have created the branch (and its tracking in `.git/config`) or\n\t\t\t// the worktree directory.\n\t\t\t//\n\t\t\t// The tracking isn't announced as a `config` change, only evicted: git may also write repository-wide\n\t\t\t// keys (`extensions.relativeWorktrees` under `worktree.useRelativePaths`), so the write can't claim its\n\t\t\t// config change is confined to the new branch, and an unconfined one would refresh every worktree on each\n\t\t\t// add. The watcher's report of the file says what changed in it instead.\n\t\t\t//\n\t\t\t// Named, so other worktrees' watchers take their reports of the new entry and its HEAD for this add's own\n\t\t\tconst added = await readLinkedWorktreeId(worktreePath);\n\t\t\tconst moved = { movedWorktrees: added != null ? [added] : [] };\n\t\t\tif (createdBranch) {\n\t\t\t\t// Evict the cached base only — see `checkout -b` for why the persisted keys are left alone.\n\t\t\t\tthis.cache.deleteBaseBranchName(repoPath, createdBranch);\n\t\t\t\t// A branch git created on its own may track a remote branch, whatever the commitish looks like\n\t\t\t\tthis.context.hooks?.cache?.onReset?.(\n\t\t\t\t\trepoPath,\n\t\t\t\t\t...(!options?.createBranch || mayWriteTracking(options.commitish, options.noTracking)\n\t\t\t\t\t\t? (['branches', 'config', 'worktrees'] as const)\n\t\t\t\t\t\t: (['branches', 'worktrees'] as const)),\n\t\t\t\t);\n\t\t\t\tthis.provider.announceWrite(\n\t\t\t\t\trepoPath,\n\t\t\t\t\t['worktrees', 'worktreeHead', 'heads'],\n\t\t\t\t\t[`refs/heads/${createdBranch}`],\n\t\t\t\t\tmoved,\n\t\t\t\t);\n\t\t\t} else if (mayHaveCreatedBranch) {\n\t\t\t\t// Git creates the branch before checking it out, so a run cut short may have left one it never named\n\t\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches', 'config', 'worktrees');\n\t\t\t\tthis.provider.announceWrite(repoPath, ['worktrees', 'worktreeHead', 'heads'], undefined, moved);\n\t\t\t} else {\n\t\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'worktrees');\n\t\t\t\tthis.provider.announceWrite(repoPath, ['worktrees', 'worktreeHead'], undefined, moved);\n\t\t\t}\n\t\t}\n\t}\n\n\tasync createWorktreeWithResult(\n\t\trepoPath: string,\n\t\tpath: string,\n\t\toptions?: {\n\t\t\tcommitish?: string;\n\t\t\tcreateBranch?: string;\n\t\t\tdetach?: boolean;\n\t\t\tforce?: boolean;\n\t\t\tnoTracking?: boolean;\n\t\t},\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<GitWorktree | undefined> {\n\t\tawait this.createWorktree(repoPath, path, options, runOptions);\n\t\tconst normalized = normalizePath(path);\n\t\treturn this.getWorktree(\n\t\t\trepoPath,\n\t\t\tw => normalizePath(w.path) === normalized,\n\t\t\tundefined,\n\t\t\trunOptions?.cancellation,\n\t\t);\n\t}\n\n\t@debug({ quiet: true })\n\tasync getWorktree(\n\t\trepoPath: string,\n\t\tpredicate: (w: GitWorktree) => boolean,\n\t\toptions?: { force?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitWorktree | undefined> {\n\t\treturn (await this.getWorktrees(repoPath, options, cancellation)).find(predicate);\n\t}\n\n\t@debug({ quiet: true })\n\tasync getWorktrees(\n\t\trepoPath: string,\n\t\toptions?: { force?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitWorktree[]> {\n\t\t// A pending read that hasn't started `git worktree list` will see the state as of this call, so it is joined,\n\t\t// whether it was pending as the call started or is once the call would evict (another forced read's, say)\n\t\tlet force = options?.force === true && !this._unspawnedReads.has(this.cache.getCommonPath(repoPath));\n\n\t\tawait this.git.ensureSupports('git:worktrees', (requiredVersion, installedVersion) =>\n\t\t\tl10n.t(\n\t\t\t\t'Displaying worktrees requires a newer version of Git (>= {0}) than is currently installed ({1}). Please install a more recent version of Git and try again.',\n\t\t\t\trequiredVersion,\n\t\t\t\tinstalledVersion,\n\t\t\t),\n\t\t);\n\n\t\t// Validated before the check below, so the cache's forced read evicts right after it rather than after a wait\n\t\tconst validation = this.cache.validateBeforeRead(repoPath);\n\t\tif (validation != null) {\n\t\t\tawait validation;\n\t\t}\n\n\t\tif (force && this._unspawnedReads.has(this.cache.getCommonPath(repoPath))) {\n\t\t\tforce = false;\n\t\t}\n\n\t\treturn this.cache.getWorktrees(\n\t\t\trepoPath,\n\t\t\tasync (commonPath, cacheable, signal) => {\n\t\t\t\tconst unspawned = {};\n\t\t\t\tthis._unspawnedReads.set(commonPath, unspawned);\n\t\t\t\tconst onSpawned = () => {\n\t\t\t\t\tif (this._unspawnedReads.get(commonPath) === unspawned) {\n\t\t\t\t\t\tthis._unspawnedReads.delete(commonPath);\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\ttry {\n\t\t\t\t\treturn await this.readWorktrees(repoPath, commonPath, cacheable, signal ?? cancellation, onSpawned);\n\t\t\t\t} finally {\n\t\t\t\t\tonSpawned();\n\t\t\t\t}\n\t\t\t},\n\t\t\tforce ? { force: true } : undefined,\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprivate async readWorktrees(\n\t\trepoPath: string,\n\t\tcommonPath: string,\n\t\tcacheable: CacheController,\n\t\tsignal: AbortSignal | undefined,\n\t\tonSpawn: () => void,\n\t): Promise<GitWorktree[]> {\n\t\t// Read beside the list, which it doesn't depend on. `commonPath` is the main worktree, not the git dir,\n\t\t// so the roots come from the repository's own git dir\n\t\tconst rootsRead = this.readIgnoredWorktreeRoots?.(repoPath).catch(() => undefined);\n\t\tconst [dataResult, branchesResult] = await Promise.allSettled([\n\t\t\tthis.git.run(\n\t\t\t\t{ cwd: commonPath, cancellation: signal, onSpawn: onSpawn },\n\t\t\t\t'worktree',\n\t\t\t\t'list',\n\t\t\t\t'--porcelain',\n\t\t\t),\n\t\t\tthis.provider.branches.getBranches(commonPath, undefined, signal),\n\t\t]);\n\n\t\tif (dataResult.status === 'rejected') {\n\t\t\t// Don't cache a bogus empty result for a transient command failure — retry on next access.\n\t\t\tcacheable.invalidate();\n\t\t}\n\n\t\tconst getWorkspaceFolder: WorkspaceFolderResolver | undefined = this.context.workspace\n\t\t\t? uri => {\n\t\t\t\t\tconst folder = this.context.workspace!.getFolder(uri.fsPath);\n\t\t\t\t\tif (folder == null) return undefined;\n\t\t\t\t\treturn { uri: fileUri(folder.path), name: basename(folder.path) };\n\t\t\t\t}\n\t\t\t: undefined;\n\n\t\tconst data = getSettledValue(dataResult)?.stdout;\n\t\tlet worktrees = parseGitWorktrees(\n\t\t\tdata,\n\t\t\tcommonPath,\n\t\t\tgetSettledValue(branchesResult)?.values ?? [],\n\t\t\tgetWorkspaceFolder,\n\t\t);\n\n\t\t// The branches come from the cache, which can lag the list just read (a forced read pairs a fresh list with\n\t\t// them). Where the list contradicts them it proves them stale, so they are re-read, once\n\t\tconst knowsPaths = await this.git.supports('git:for-each-ref:worktreePath');\n\t\tconst stale =\n\t\t\tbranchesResult.status === 'fulfilled'\n\t\t\t\t? findStaleBranches(worktrees, branchesResult.value.values, knowsPaths)\n\t\t\t\t: undefined;\n\t\tif (stale == null) {\n\t\t\tthis._lastingDisagreements.delete(commonPath);\n\t\t} else if (this._lastingDisagreements.get(commonPath) !== data) {\n\t\t\tthis.context.hooks?.cache?.onReset?.(commonPath, 'branches');\n\t\t\tfor (const path of stale.switched) {\n\t\t\t\tthis.context.hooks?.cache?.onReset?.(path, 'branch');\n\t\t\t}\n\n\t\t\tlet branches: GitBranch[] | undefined;\n\t\t\ttry {\n\t\t\t\t({ values: branches } = await this.provider.branches.getBranches(commonPath, undefined, signal));\n\t\t\t} catch {\n\t\t\t\t// Keep the branches matched from the stale list, but not in the cache\n\t\t\t\tcacheable.invalidate();\n\t\t\t}\n\n\t\t\tif (branches != null) {\n\t\t\t\tworktrees = parseGitWorktrees(data, commonPath, branches, getWorkspaceFolder);\n\t\t\t\tif (data != null && findStaleBranches(worktrees, branches, knowsPaths) != null) {\n\t\t\t\t\tthis._lastingDisagreements.set(commonPath, data);\n\t\t\t\t}\n\t\t\t\t// The host's views show the branches the watcher missed a change of; which moved is unknown. Only the\n\t\t\t\t// host hears it: announced as a write of core's, the watch layer would take an outside `heads` report\n\t\t\t\t// arriving meanwhile for its echo and drop it, though nothing of the kind was evicted for it\n\t\t\t\tfor (const path of new Set([commonPath, ...this.cache.getWorktreePaths(commonPath)])) {\n\t\t\t\t\tthis.provider.notifyHost(path, ['heads']);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (rootsRead != null) {\n\t\t\tconst roots = await rootsRead;\n\t\t\tif (roots == null) {\n\t\t\t\t// The folders couldn't be read: an unfiltered list would keep ignored worktrees in the shared\n\t\t\t\t// cache until the next change\n\t\t\t\tcacheable.invalidate();\n\t\t\t} else if (roots.length) {\n\t\t\t\tworktrees = worktrees.filter(w => !roots.some(root => isDescendant(normalizePath(w.path), root)));\n\t\t\t}\n\t\t}\n\n\t\t// Older git prints a bare `locked` even when a reason exists; recover it from the admin dir\n\t\tif (await this.git.supports('git:worktree:list:lock-reason')) return worktrees;\n\n\t\treturn Promise.all(worktrees.map(w => this.withLockReason(w)));\n\t}\n\n\tprivate async withLockReason(worktree: GitWorktree): Promise<GitWorktree> {\n\t\tif (worktree.locked !== true || worktree.isDefault || worktree.type === 'bare') return worktree;\n\n\t\ttry {\n\t\t\t// A linked worktree's `.git` is a file: `gitdir: <admin dir>`, relative to the worktree when not absolute\n\t\t\tconst dotGit = join(worktree.uri.fsPath, '.git');\n\t\t\tconst match = /^gitdir:\\s*(.+?)\\s*$/m.exec(await fs.readFile(dotGit, 'utf8'));\n\t\t\tif (match == null) return worktree;\n\n\t\t\tconst reason = (await fs.readFile(join(resolve(worktree.uri.fsPath, match[1]), 'locked'), 'utf8')).trim();\n\t\t\tif (!reason) return worktree;\n\n\t\t\treturn new GitWorktree(\n\t\t\t\tworktree.isDefault,\n\t\t\t\tworktree.type,\n\t\t\t\tworktree.repoPath,\n\t\t\t\tworktree.uri,\n\t\t\t\treason,\n\t\t\t\tworktree.prunable,\n\t\t\t\tworktree.sha,\n\t\t\t\tworktree.branch,\n\t\t\t\tworktree.workspaceFolder,\n\t\t\t\tworktree.branchName,\n\t\t\t);\n\t\t} catch {\n\t\t\treturn worktree;\n\t\t}\n\t}\n\n\t@debug({ quiet: true })\n\tgetWorktreesDefaultUri(repoPath: string): Uri | undefined {\n\t\treturn this.context.workspace?.getWorktreeDefaultUri?.(repoPath);\n\t}\n\n\t/**\n\t * Deletes a worktree (`git worktree remove`). Pass `force: 'locked'` to also override a locked worktree.\n\t *\n\t * `runOptions` are spread into the underlying `git.run` call (e.g. `{ timeout: 0 }` for a large worktree\n\t * whose removal may exceed the default command timeout).\n\t *\n\t * On failure, the thrown {@link WorktreeDeleteError}'s `original` property carries the raw\n\t * {@link GitError} (stderr/stdout/exit code) untouched — a caller that needs to classify a\n\t * platform-specific failure (e.g. a Windows file-lock retry) can read it directly rather than parsing\n\t * the typed error's message.\n\t */\n\t@debug()\n\tasync deleteWorktree(\n\t\trepoPath: string,\n\t\tpath: string | Uri,\n\t\toptions?: { force?: boolean | 'locked' },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\tawait this.git.ensureSupports('git:worktrees', (requiredVersion, installedVersion) =>\n\t\t\tl10n.t(\n\t\t\t\t'Deleting worktrees requires a newer version of Git (>= {0}) than is currently installed ({1}). Please install a more recent version of Git and try again.',\n\t\t\t\trequiredVersion,\n\t\t\t\tinstalledVersion,\n\t\t\t),\n\t\t);\n\n\t\tconst args = ['worktree', 'remove'];\n\t\tif (options?.force) {\n\t\t\targs.push('--force');\n\t\t\t// Git requires a second `--force` to remove a locked worktree\n\t\t\tif (options.force === 'locked') {\n\t\t\t\targs.push('--force');\n\t\t\t}\n\t\t}\n\n\t\tconst pathStr = normalizePath(toFsPath(path));\n\t\targs.push(pathStr);\n\t\t// Read before the removal takes the worktree's `.git` file\n\t\tconst removed = this.cache.getLinkedWorktreeId(pathStr) ?? (await readLinkedWorktreeId(pathStr));\n\n\t\tlet deleted = false;\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath, errors: 'throw', ...runOptions }, ...args);\n\t\t\tdeleted = true;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\t// A cancelled or timed-out removal (`runOptions.cancellation`/`timeout`), or a host-rejected index-lock\n\t\t\t// retry, is not git refusing it, and wrapping it would hand the caller a `WorktreeDeleteError` whose\n\t\t\t// `original` is no `GitError` at all\n\t\t\tif (isCancellationError(ex) || isRunHookFailure(ex)) throw ex;\n\n\t\t\tconst gitError = getGitCommandError(\n\t\t\t\t'worktree-delete',\n\t\t\t\tex as GitError,\n\t\t\t\treason =>\n\t\t\t\t\tnew WorktreeDeleteError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason,\n\t\t\t\t\t\t\tlockReason: reason === 'locked' ? getLockReason(ex as GitError) : undefined,\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath, args: args },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex as GitError,\n\t\t\t\t\t),\n\t\t\t);\n\n\t\t\tif (gitError.details.reason === 'directoryNotEmpty') {\n\t\t\t\tscope?.warn(\n\t\t\t\t\t`Failed to fully delete worktree '${pathStr}' because it is not empty. Attempting to delete it manually.`,\n\t\t\t\t);\n\t\t\t\ttry {\n\t\t\t\t\tawait fs.rm(pathStr, { force: true, recursive: true });\n\t\t\t\t\tdeleted = true;\n\t\t\t\t\treturn;\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (isWindows) {\n\t\t\t\t\t\tconst match = /EPERM: operation not permitted, unlink '(.*?)'/i.exec((ex as GitError).message);\n\t\t\t\t\t\tif (match != null) {\n\t\t\t\t\t\t\tscope?.warn(\n\t\t\t\t\t\t\t\t`Failed to manually delete '${pathStr}' because it is in use. Attempting to forcefully delete it.`,\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t// Windows-specific: `del` via cmd.exe to force-remove a locked symlink.\n\t\t\t\t\t\t\t// Node's fs.rm/unlink fails with EPERM when the symlink target is in use.\n\t\t\t\t\t\t\tfunction deleteInUseSymlink(symlink: string) {\n\t\t\t\t\t\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\t\t\t\t\t\texec(`del \"${symlink}\"`, (ex, stdout, stderr) => {\n\t\t\t\t\t\t\t\t\t\tif (ex) {\n\t\t\t\t\t\t\t\t\t\t\treject(ex instanceof Error ? ex : new Error(String(ex)));\n\t\t\t\t\t\t\t\t\t\t} else if (stderr) {\n\t\t\t\t\t\t\t\t\t\t\treject(new Error(stderr));\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\tresolve(stdout);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst [, file] = match;\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tawait deleteInUseSymlink(file);\n\t\t\t\t\t\t\t\tawait fs.rm(pathStr, { force: true, recursive: true, maxRetries: 1, retryDelay: 1 });\n\t\t\t\t\t\t\t\tdeleted = true;\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\t\t\tscope?.error(ex, `Failed to forcefully delete '${pathStr}' because it is in use.`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthrow gitError;\n\t\t} finally {\n\t\t\tif (deleted) {\n\t\t\t\t// Clean up Cache registry + per-worktree cache entries for the deleted worktree.\n\t\t\t\t// Order matters: unregister before emitting the repo-level change so any listener\n\t\t\t\t// that re-queries worktree-aware state sees the registry already updated.\n\t\t\t\tthis.cache.unregisterRepoPath(pathStr);\n\t\t\t}\n\t\t\t// A failed or cancelled removal may already have taken the worktree's files or admin entry\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'worktrees');\n\t\t\tthis.provider.announceWrite(repoPath, ['worktrees', 'worktreeHead'], undefined, {\n\t\t\t\tmovedWorktrees: removed != null ? [removed] : [],\n\t\t\t});\n\t\t}\n\t}\n\n\t@debug()\n\tasync pruneWorktrees(repoPath: string, options?: { expire?: string }): Promise<void> {\n\t\tawait this.git.ensureSupports('git:worktrees', (requiredVersion, installedVersion) =>\n\t\t\tl10n.t(\n\t\t\t\t'Pruning worktrees requires a newer version of Git (>= {0}) than is currently installed ({1}). Please install a more recent version of Git and try again.',\n\t\t\t\trequiredVersion,\n\t\t\t\tinstalledVersion,\n\t\t\t),\n\t\t);\n\n\t\tconst before = await this.listWorktreePaths(repoPath);\n\t\t// Those of the pruned worktrees that were registered; the others' are unknown\n\t\tconst pruned: string[] = [];\n\n\t\tconst args = ['worktree', 'prune'];\n\t\tif (options?.expire) {\n\t\t\targs.push('--expire', options.expire);\n\t\t}\n\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath, errors: 'throw' }, ...args);\n\n\t\t\tconst after = await this.listWorktreePaths(repoPath);\n\n\t\t\t// Order matters (see `deleteWorktree`): unregister before emitting the repo-level change so any\n\t\t\t// listener that re-queries worktree-aware state sees the registry already updated.\n\t\t\tif (before != null && after != null) {\n\t\t\t\tfor (const path of before) {\n\t\t\t\t\tif (!after.has(path)) {\n\t\t\t\t\t\tconst id = this.cache.getLinkedWorktreeId(path);\n\t\t\t\t\t\tif (id != null) {\n\t\t\t\t\t\t\tpruned.push(id);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.cache.unregisterRepoPath(path);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'worktrees');\n\t\t\tthis.provider.announceWrite(repoPath, ['worktrees', 'worktreeHead'], undefined, { movedWorktrees: pruned });\n\t\t}\n\t}\n\n\t/**\n\t * Raw worktree paths currently known to git (`worktree <path>` lines from `--porcelain`), normalized the\n\t * same way {@link deleteWorktree} does. A failed listing (`errors: 'ignore'`) yields an empty set rather\n\t * than throwing — used by `pruneWorktrees` to diff before/after, where a transient read failure must not\n\t * be mistaken for every worktree having vanished.\n\t */\n\tprivate async listWorktreePaths(repoPath: string): Promise<Set<string> | undefined> {\n\t\tconst result = await this.git.run({ cwd: repoPath, errors: 'ignore' }, 'worktree', 'list', '--porcelain');\n\t\t// A failed listing is not an empty one: read as empty, the after-prune one would unregister everything\n\t\tif (result.completion.status !== 'exited' || result.exitCode !== 0) return undefined;\n\n\t\tconst paths = new Set<string>();\n\t\tfor (const line of result.stdout.split('\\n')) {\n\t\t\tif (line.startsWith('worktree ')) {\n\t\t\t\tpaths.add(normalizePath(toFsPath(line.slice('worktree '.length).trim())));\n\t\t\t}\n\t\t}\n\t\treturn paths;\n\t}\n\n\t@debug()\n\tasync lockWorktree(repoPath: string, path: string | Uri, options?: { reason?: string }): Promise<void> {\n\t\tawait this.git.ensureSupports('git:worktrees', (requiredVersion, installedVersion) =>\n\t\t\tl10n.t(\n\t\t\t\t'Locking worktrees requires a newer version of Git (>= {0}) than is currently installed ({1}). Please install a more recent version of Git and try again.',\n\t\t\t\trequiredVersion,\n\t\t\t\tinstalledVersion,\n\t\t\t),\n\t\t);\n\n\t\tconst args = ['worktree', 'lock'];\n\t\tif (options?.reason) {\n\t\t\targs.push('--reason', options.reason);\n\t\t}\n\t\targs.push(normalizePath(toFsPath(path)));\n\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath, errors: 'throw' }, ...args);\n\t\t} finally {\n\t\t\t// A lock touches no worktree's HEAD, so no worktree's git results or merge targets\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'worktreeList');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['worktrees']);\n\t\t}\n\t}\n\n\t@debug()\n\tasync unlockWorktree(repoPath: string, path: string | Uri): Promise<void> {\n\t\tawait this.git.ensureSupports('git:worktrees', (requiredVersion, installedVersion) =>\n\t\t\tl10n.t(\n\t\t\t\t'Unlocking worktrees requires a newer version of Git (>= {0}) than is currently installed ({1}). Please install a more recent version of Git and try again.',\n\t\t\t\trequiredVersion,\n\t\t\t\tinstalledVersion,\n\t\t\t),\n\t\t);\n\n\t\tconst pathStr = normalizePath(toFsPath(path));\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath, errors: 'throw' }, 'worktree', 'unlock', pathStr);\n\t\t} finally {\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'worktreeList');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['worktrees']);\n\t\t}\n\t}\n}\n\n/**\n * The admin id (the `<id>` of `.git/worktrees/<id>`) of the linked worktree at `worktreePath`, from the admin entry its\n * `.git` file names; `undefined` when there is none to read\n */\nasync function readLinkedWorktreeId(worktreePath: string): Promise<string | undefined> {\n\ttry {\n\t\tconst dir = parseGitFile(await fs.readFile(join(worktreePath, '.git'), 'utf8'));\n\t\tif (dir == null) return undefined;\n\n\t\tconst adminDir = normalizePath(resolve(worktreePath, dir));\n\t\treturn basename(dirname(adminDir)) === 'worktrees' ? basename(adminDir) : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA+BA,SAAS,cAAc,IAAkC;CACxD,OAAO,UAAU,qBAAqB,KAAK,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,KAAK,KAAA;AACvG;;;;;AAMA,SAAS,qBAAqB,QAAgD;CAC7E,OAAO,SAAS,8CAA8C,KAAK,MAAM,CAAC,GAAG,KAAK,KAAA;AACnF;AAEA,MAAM,YAAY;;;;;AAMlB,SAAS,kBACR,WACA,UAEA,YACqC;CACrC,IAAI,CAAC,UAAU,QAAQ,OAAO,KAAA;CAE9B,MAAM,yBAAS,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,OAAO,KAAK,CAAC,CAAA,GAAA,wBAAA,WAAA,gBAAA,IAAA;AA8KrB,WAAA,CAAA,MAAM,EAAE,OAAO,KAAK,CAAC,CAAA,GAAA,wBAAA,WAAA,0BAAA,IAAA;AAgBrB,WAAA,CAAA,MAAM,CAAA,GAAA,wBAAA,WAAA,kBAAA,IAAA;AAsHN,WAAA,CAAA,MAAM,CAAA,GAAA,wBAAA,WAAA,kBAAA,IAAA;AA+DN,WAAA,CAAA,MAAM,CAAA,GAAA,wBAAA,WAAA,gBAAA,IAAA;AAyBN,WAAA,CAAA,MAAM,CAAA,GAAA,wBAAA,WAAA,kBAAA,IAAA;;;;;AAwBR,eAAe,qBAAqB,cAAmD;CACtF,IAAI;EACH,MAAM,MAAM,aAAa,MAAMA,SAAG,SAAS,KAAK,cAAc,MAAM,GAAG,MAAM,CAAC;EAC9E,IAAI,OAAO,MAAM,OAAO,KAAA;EAExB,MAAM,WAAW,cAAc,QAAQ,cAAc,GAAG,CAAC;EACzD,OAAOD,WAASE,UAAQ,QAAQ,CAAC,MAAM,cAAcF,WAAS,QAAQ,IAAI,KAAA;CAC3E,QAAQ;EACP;CACD;AACD"}
|
|
@@ -22,7 +22,11 @@ export interface CliGitServiceOptions {
|
|
|
22
22
|
locator?: () => Promise<GitLocation>;
|
|
23
23
|
/** Host-provided context hooks (cache events, workspace, integrations, telemetry, fs) */
|
|
24
24
|
context: CliGitProviderOptions['context'];
|
|
25
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Git execution options passed through to the underlying Git executor. `gitOptions.isTrusted(repoPath)` is the
|
|
27
|
+
* per-repository trust gate: a `false` answer rejects git runs in that path with `WorkspaceUntrustedError` before
|
|
28
|
+
* any process starts. It applies only when `context.workspace.isTrusted` is unset; that flag wins when present.
|
|
29
|
+
*/
|
|
26
30
|
gitOptions?: CliGitProviderOptions['gitOptions'];
|
|
27
31
|
/** Use an existing Cache instance, or one will be created */
|
|
28
32
|
cache?: CliGitProviderOptions['cache'];
|
|
@@ -40,6 +44,26 @@ export interface CliGitServiceOptions {
|
|
|
40
44
|
* watcher is asked.
|
|
41
45
|
*/
|
|
42
46
|
watchPolling?: WatchPollingOptions;
|
|
47
|
+
/**
|
|
48
|
+
* Keeps the caches that never expire (branches, current branch, refs, tags, remotes, worktrees, stashes, gk config,
|
|
49
|
+
* paused operation, and what derives from them) fresh for repositories whose `.git` directory nothing watches:
|
|
50
|
+
* before such a read, stats the files a watcher would have reported, and lists the ref directories and worktree
|
|
51
|
+
* admin entries, applying what moved as a watcher event would. Files git writes by rename are read only once the
|
|
52
|
+
* directory they're in moved, so a read of an idle repository costs a stat per git dir, per ref directory, per
|
|
53
|
+
* linked worktree and per file git writes in place, at most once per 250ms per repository; a watched one costs
|
|
54
|
+
* nothing, unless its watch is suspended, which holds what it hears until it resumes. Never runs git: a repository
|
|
55
|
+
* whose git dir nothing resolved yet is read from its own files, and one whose files can't show it (bare, a
|
|
56
|
+
* submodule, `--separate-git-dir`, `core.worktree`) isn't validated until a read resolves it, its files looked at
|
|
57
|
+
* again every 30 seconds. What moves in a worktree under an {@link ignoredWorktreeFolders} folder clears nothing. Without a
|
|
58
|
+
* {@link watchingProvider}, every repository counts as unwatched. A read waits at most `timeoutMs` (default 1000)
|
|
59
|
+
* for the stats, then is served from the cache, and the stats run one at a time per repository and two at once
|
|
60
|
+
* overall. A stat on a hung mount holds one of Node's file-system threads until it returns; one outstanding past
|
|
61
|
+
* `timeoutMs` lets other repositories' stats go on, as long as the stats hold all but two of the threads
|
|
62
|
+
* (`UV_THREADPOOL_SIZE`, default 4), which leaves the host two. Off by default.
|
|
63
|
+
*/
|
|
64
|
+
validateUnwatchedCaches?: boolean | {
|
|
65
|
+
readonly timeoutMs?: number;
|
|
66
|
+
};
|
|
43
67
|
/** For tests only; production never passes it (see `WorktreeSummaryServiceOptions.verifyBaseRemeasure`) */
|
|
44
68
|
verifyBaseRemeasure?: WorktreeSummaryServiceOptions['verifyBaseRemeasure'];
|
|
45
69
|
}
|
package/dist/git-cli/service.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { fileUri } from "../utils/uri.js";
|
|
2
|
+
import { isNotFound } from "../git/watching/watchGroup.js";
|
|
2
3
|
import { GitService } from "../git/service.js";
|
|
3
4
|
import { CliGitProvider } from "./cliGitProvider.js";
|
|
5
|
+
import { UnwatchedCacheValidator } from "../git/watching/unwatchedCacheValidator.js";
|
|
4
6
|
import { findGitPath } from "./exec/locator.js";
|
|
7
|
+
import { env } from "node:process";
|
|
5
8
|
//#region ../git-cli/src/service.ts
|
|
6
9
|
/**
|
|
7
10
|
* Creates a ready-to-use {@link GitService} backed by the CLI git provider.
|
|
@@ -39,14 +42,56 @@ function createCliGitService(options) {
|
|
|
39
42
|
refreshIndexAfterWrites: options.refreshIndexAfterWrites
|
|
40
43
|
});
|
|
41
44
|
service.register(provider, () => true);
|
|
45
|
+
if (options.validateUnwatchedCaches) {
|
|
46
|
+
const fs = options.context.fs;
|
|
47
|
+
const validator = new UnwatchedCacheValidator({
|
|
48
|
+
cache: provider.cache,
|
|
49
|
+
timeoutMs: typeof options.validateUnwatchedCaches === "object" ? options.validateUnwatchedCaches.timeoutMs : void 0,
|
|
50
|
+
maxFsThreads: getThreadPoolSize() - 2,
|
|
51
|
+
stat: async (path) => {
|
|
52
|
+
try {
|
|
53
|
+
const stat = await fs.stat(fileUri(path));
|
|
54
|
+
return stat != null ? {
|
|
55
|
+
mtime: stat.mtime,
|
|
56
|
+
size: stat.size
|
|
57
|
+
} : void 0;
|
|
58
|
+
} catch (ex) {
|
|
59
|
+
if (isNotFound(ex)) return void 0;
|
|
60
|
+
throw ex;
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
readDirectory: (path) => fs.readDirectory(fileUri(path)),
|
|
64
|
+
readFile: async (path) => {
|
|
65
|
+
try {
|
|
66
|
+
return await fs.readFile(fileUri(path));
|
|
67
|
+
} catch (ex) {
|
|
68
|
+
if (isNotFound(ex)) return void 0;
|
|
69
|
+
throw ex;
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
getIgnoredWorktreeRoots: (repoPath) => provider.cache.gitDir.get(repoPath) != null ? provider.getIgnoredWorktreeRoots(repoPath) : Promise.resolve([]),
|
|
73
|
+
resolveGitDir: (repoPath) => provider.config.resolveGitDirWithoutGit(repoPath),
|
|
74
|
+
isWatched: (repoPath) => service.watchService?.isRepoWatched(repoPath) ?? false
|
|
75
|
+
});
|
|
76
|
+
provider.cache.setReadValidator((repoPath) => validator.validate(repoPath), () => validator.getResourceUsage());
|
|
77
|
+
service.watchService?.onDidChangeRepoWatched((e) => {
|
|
78
|
+
if (e.watched) validator.onWatched(e.repoPath);
|
|
79
|
+
else validator.onUnwatched(e.repoPath);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
42
82
|
service.watchService?.onDidChangeWorkingTree((repoPath) => provider.cache.onWorkingTreeChanged(repoPath));
|
|
43
83
|
service.watchService?.onDidChangeRepository((e) => {
|
|
44
84
|
const changes = e.getUnannouncedChanges();
|
|
45
|
-
if (changes.length) provider.cache.onRepositoryChanged(e.repoPath, changes);
|
|
85
|
+
if (changes.length) provider.cache.onRepositoryChanged(e.repoPath, changes, { movedWorktrees: e.movedWorktrees });
|
|
46
86
|
});
|
|
47
87
|
service.watchService?.onDidChangeFetchHead((repoPath) => provider.cache.onRepositoryChanged(repoPath, ["lastFetched"]));
|
|
48
88
|
return service;
|
|
49
89
|
}
|
|
90
|
+
/** The size of libuv's thread pool, which runs Node's file-system calls, as libuv reads it at its first use */
|
|
91
|
+
function getThreadPoolSize() {
|
|
92
|
+
const size = Number.parseInt(env.UV_THREADPOOL_SIZE ?? "", 10);
|
|
93
|
+
return Number.isNaN(size) ? 4 : Math.min(Math.max(size, 1), 1024);
|
|
94
|
+
}
|
|
50
95
|
//#endregion
|
|
51
96
|
export { createCliGitService };
|
|
52
97
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","names":[],"sources":["../../../git-cli/src/service.ts"],"sourcesContent":["import { GitService } from '@gitlens/git/service.js';\nimport type { FileWatchingProvider } from '@gitlens/git/watching/provider.js';\nimport type { WatchPollingOptions } from '@gitlens/git/watching/watchService.js';\nimport type { WorktreeSummaryServiceOptions } from '@gitlens/git/watching/worktreeSummary.js';\nimport { fileUri } from '@gitlens/utils/uri.js';\nimport type { CliGitProviderOptions } from './cliGitProvider.js';\nimport { CliGitProvider } from './cliGitProvider.js';\nimport type { GitLocation } from './exec/locator.js';\nimport { findGitPath } from './exec/locator.js';\n\n/**\n * Options for {@link createCliGitService}.\n */\nexport interface CliGitServiceOptions {\n\t/**\n\t * Path(s) to the git binary.\n\t * Auto-detected if omitted (searches PATH, platform-specific locations).\n\t * Ignored when {@link locator} is provided.\n\t */\n\tgitPath?: string | string[];\n\n\t/**\n\t * Custom git binary resolver. When provided, used instead of the\n\t * default `findGitPath(gitPath)` lookup.\n\t */\n\tlocator?: () => Promise<GitLocation>;\n\n\t/** Host-provided context hooks (cache events, workspace, integrations, telemetry, fs) */\n\tcontext: CliGitProviderOptions['context'];\n\n\t/** Git execution options passed through to the underlying Git executor */\n\tgitOptions?: CliGitProviderOptions['gitOptions'];\n\n\t/** Use an existing Cache instance, or one will be created */\n\tcache?: CliGitProviderOptions['cache'];\n\n\t/** Folders, relative to a repository's common git dir, whose worktrees core acts as if didn't exist */\n\tignoredWorktreeFolders?: CliGitProviderOptions['ignoredWorktreeFolders'];\n\n\t/** Refreshes a checkout's index after core's own writes rewrote it (see `CliGitProviderOptions`); off by default */\n\trefreshIndexAfterWrites?: CliGitProviderOptions['refreshIndexAfterWrites'];\n\n\t/**\n\t * Filesystem watching provider. When provided, the {@link GitService}\n\t * will watch repositories for changes (file creates, edits, deletes).\n\t */\n\twatchingProvider?: FileWatchingProvider;\n\n\t/**\n\t * Polls in place of (or beside) the watchers {@link watchingProvider} reports it can't trust. When omitted, no\n\t * watcher is asked.\n\t */\n\twatchPolling?: WatchPollingOptions;\n\n\t/** For tests only; production never passes it (see `WorktreeSummaryServiceOptions.verifyBaseRemeasure`) */\n\tverifyBaseRemeasure?: WorktreeSummaryServiceOptions['verifyBaseRemeasure'];\n}\n\n/**\n * Creates a ready-to-use {@link GitService} backed by the CLI git provider.\n *\n * This is the primary entry point for standalone (non-VS Code) consumers\n * of the `@gitlens/git-cli` library. It creates a singleton {@link GitService},\n * wires up a {@link CliGitProvider}, and registers it for all repository paths.\n *\n * @example\n * ```typescript\n * const git = createCliGitService({ context: {} });\n *\n * const repo = git.forRepo('/path/to/repo')!;\n * const branches = await repo.branches.getBranches();\n * const status = await repo.status.getStatus();\n * await repo.ops!.fetch({ remote: 'origin' });\n *\n * git.dispose(); // cleans up provider, cache, and module-level state\n * ```\n */\nexport function createCliGitService(options: CliGitServiceOptions): GitService {\n\tconst service = GitService.createSingleton(options.watchingProvider, {\n\t\twatchPolling: options.watchPolling,\n\t\tverifyBaseRemeasure: options.verifyBaseRemeasure,\n\t\t// The host's file system reads the shared `.git/config` the watch service compares reports of\n\t\treadFile: path => options.context.fs.readFile(fileUri(path)),\n\t\t// And lists the directory the admin entries of its worktrees are in\n\t\treadDirectory: path => options.context.fs.readDirectory(fileUri(path)),\n\t});\n\n\tconst locator = options.locator ?? (() => findGitPath(options.gitPath ?? null));\n\tconst provider = new CliGitProvider({\n\t\tcontext: options.context,\n\t\tlocator: locator,\n\t\tgitOptions: options.gitOptions,\n\t\tcache: options.cache,\n\t\tignoredWorktreeFolders: options.ignoredWorktreeFolders,\n\t\trefreshIndexAfterWrites: options.refreshIndexAfterWrites,\n\t});\n\n\tservice.register(provider, () => true);\n\n\t// Advance the provider cache's status generation clock from the watch session's global events — the standalone\n\t// analogue of what the VS Code host wires in `GitProviderService`. Without this, a consumer that passes a\n\t// `watchingProvider` and drives watch sessions gets FS events but a FROZEN clock, so `dedupeByStatusGeneration`\n\t// degrades to the pre-change/post-change stale-join this branch exists to fix. Standalone has no `Repository`\n\t// models, so there are no force-fired `closed`/`lastFetched` bypassing the session for the global repo event to\n\t// miss. Subscriptions are torn down with the service (its `watchService`'s emitters are disposed on dispose).\n\tservice.watchService?.onDidChangeWorkingTree(repoPath => provider.cache.onWorkingTreeChanged(repoPath));\n\t// Announced kinds were evicted when core announced its write; evicting them again would discard what the host\n\t// re-read since\n\tservice.watchService?.onDidChangeRepository(e => {\n\t\tconst changes = e.getUnannouncedChanges();\n\t\tif (changes.length) {\n\t\t\tprovider.cache.onRepositoryChanged(e.repoPath, changes);\n\t\t}\n\t});\n\t// FETCH_HEAD maps to no session change, and there's no `Repository` model here to force-fire `lastFetched` (as\n\t// the VS Code host does), so bridge it straight to the cache or the last-fetched time is never re-read.\n\tservice.watchService?.onDidChangeFetchHead(repoPath =>\n\t\tprovider.cache.onRepositoryChanged(repoPath, ['lastFetched']),\n\t);\n\treturn service;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA6EA,SAAgB,oBAAoB,SAA2C;CAC9E,MAAM,UAAU,WAAW,gBAAgB,QAAQ,kBAAkB;EACpE,cAAc,QAAQ;EACtB,qBAAqB,QAAQ;EAE7B,WAAU,SAAQ,QAAQ,QAAQ,GAAG,SAAS,QAAQ,IAAI,CAAC;EAE3D,gBAAe,SAAQ,QAAQ,QAAQ,GAAG,cAAc,QAAQ,IAAI,CAAC;CACtE,CAAC;CAED,MAAM,UAAU,QAAQ,kBAAkB,YAAY,QAAQ,WAAW,IAAI;CAC7E,MAAM,WAAW,IAAI,eAAe;EACnC,SAAS,QAAQ;EACR;EACT,YAAY,QAAQ;EACpB,OAAO,QAAQ;EACf,wBAAwB,QAAQ;EAChC,yBAAyB,QAAQ;CAClC,CAAC;CAED,QAAQ,SAAS,gBAAgB,IAAI;CAQrC,QAAQ,cAAc,wBAAuB,aAAY,SAAS,MAAM,qBAAqB,QAAQ,CAAC;CAGtG,QAAQ,cAAc,uBAAsB,MAAK;EAChD,MAAM,UAAU,EAAE,sBAAsB;EACxC,IAAI,QAAQ,QACX,SAAS,MAAM,oBAAoB,EAAE,UAAU,OAAO;CAExD,CAAC;CAGD,QAAQ,cAAc,sBAAqB,aAC1C,SAAS,MAAM,oBAAoB,UAAU,CAAC,aAAa,CAAC,CAC7D;CACA,OAAO;AACR"}
|
|
1
|
+
{"version":3,"file":"service.js","names":[],"sources":["../../../git-cli/src/service.ts"],"sourcesContent":["import { env } from 'node:process';\nimport { GitService } from '@gitlens/git/service.js';\nimport type { FileWatchingProvider } from '@gitlens/git/watching/provider.js';\nimport { UnwatchedCacheValidator } from '@gitlens/git/watching/unwatchedCacheValidator.js';\nimport { isNotFound } from '@gitlens/git/watching/watchGroup.js';\nimport type { WatchPollingOptions } from '@gitlens/git/watching/watchService.js';\nimport type { WorktreeSummaryServiceOptions } from '@gitlens/git/watching/worktreeSummary.js';\nimport { fileUri } from '@gitlens/utils/uri.js';\nimport type { CliGitProviderOptions } from './cliGitProvider.js';\nimport { CliGitProvider } from './cliGitProvider.js';\nimport type { GitLocation } from './exec/locator.js';\nimport { findGitPath } from './exec/locator.js';\n\n/**\n * Options for {@link createCliGitService}.\n */\nexport interface CliGitServiceOptions {\n\t/**\n\t * Path(s) to the git binary.\n\t * Auto-detected if omitted (searches PATH, platform-specific locations).\n\t * Ignored when {@link locator} is provided.\n\t */\n\tgitPath?: string | string[];\n\n\t/**\n\t * Custom git binary resolver. When provided, used instead of the\n\t * default `findGitPath(gitPath)` lookup.\n\t */\n\tlocator?: () => Promise<GitLocation>;\n\n\t/** Host-provided context hooks (cache events, workspace, integrations, telemetry, fs) */\n\tcontext: CliGitProviderOptions['context'];\n\n\t/**\n\t * Git execution options passed through to the underlying Git executor. `gitOptions.isTrusted(repoPath)` is the\n\t * per-repository trust gate: a `false` answer rejects git runs in that path with `WorkspaceUntrustedError` before\n\t * any process starts. It applies only when `context.workspace.isTrusted` is unset; that flag wins when present.\n\t */\n\tgitOptions?: CliGitProviderOptions['gitOptions'];\n\n\t/** Use an existing Cache instance, or one will be created */\n\tcache?: CliGitProviderOptions['cache'];\n\n\t/** Folders, relative to a repository's common git dir, whose worktrees core acts as if didn't exist */\n\tignoredWorktreeFolders?: CliGitProviderOptions['ignoredWorktreeFolders'];\n\n\t/** Refreshes a checkout's index after core's own writes rewrote it (see `CliGitProviderOptions`); off by default */\n\trefreshIndexAfterWrites?: CliGitProviderOptions['refreshIndexAfterWrites'];\n\n\t/**\n\t * Filesystem watching provider. When provided, the {@link GitService}\n\t * will watch repositories for changes (file creates, edits, deletes).\n\t */\n\twatchingProvider?: FileWatchingProvider;\n\n\t/**\n\t * Polls in place of (or beside) the watchers {@link watchingProvider} reports it can't trust. When omitted, no\n\t * watcher is asked.\n\t */\n\twatchPolling?: WatchPollingOptions;\n\n\t/**\n\t * Keeps the caches that never expire (branches, current branch, refs, tags, remotes, worktrees, stashes, gk config,\n\t * paused operation, and what derives from them) fresh for repositories whose `.git` directory nothing watches:\n\t * before such a read, stats the files a watcher would have reported, and lists the ref directories and worktree\n\t * admin entries, applying what moved as a watcher event would. Files git writes by rename are read only once the\n\t * directory they're in moved, so a read of an idle repository costs a stat per git dir, per ref directory, per\n\t * linked worktree and per file git writes in place, at most once per 250ms per repository; a watched one costs\n\t * nothing, unless its watch is suspended, which holds what it hears until it resumes. Never runs git: a repository\n\t * whose git dir nothing resolved yet is read from its own files, and one whose files can't show it (bare, a\n\t * submodule, `--separate-git-dir`, `core.worktree`) isn't validated until a read resolves it, its files looked at\n\t * again every 30 seconds. What moves in a worktree under an {@link ignoredWorktreeFolders} folder clears nothing. Without a\n\t * {@link watchingProvider}, every repository counts as unwatched. A read waits at most `timeoutMs` (default 1000)\n\t * for the stats, then is served from the cache, and the stats run one at a time per repository and two at once\n\t * overall. A stat on a hung mount holds one of Node's file-system threads until it returns; one outstanding past\n\t * `timeoutMs` lets other repositories' stats go on, as long as the stats hold all but two of the threads\n\t * (`UV_THREADPOOL_SIZE`, default 4), which leaves the host two. Off by default.\n\t */\n\tvalidateUnwatchedCaches?: boolean | { readonly timeoutMs?: number };\n\n\t/** For tests only; production never passes it (see `WorktreeSummaryServiceOptions.verifyBaseRemeasure`) */\n\tverifyBaseRemeasure?: WorktreeSummaryServiceOptions['verifyBaseRemeasure'];\n}\n\n/**\n * Creates a ready-to-use {@link GitService} backed by the CLI git provider.\n *\n * This is the primary entry point for standalone (non-VS Code) consumers\n * of the `@gitlens/git-cli` library. It creates a singleton {@link GitService},\n * wires up a {@link CliGitProvider}, and registers it for all repository paths.\n *\n * @example\n * ```typescript\n * const git = createCliGitService({ context: {} });\n *\n * const repo = git.forRepo('/path/to/repo')!;\n * const branches = await repo.branches.getBranches();\n * const status = await repo.status.getStatus();\n * await repo.ops!.fetch({ remote: 'origin' });\n *\n * git.dispose(); // cleans up provider, cache, and module-level state\n * ```\n */\nexport function createCliGitService(options: CliGitServiceOptions): GitService {\n\tconst service = GitService.createSingleton(options.watchingProvider, {\n\t\twatchPolling: options.watchPolling,\n\t\tverifyBaseRemeasure: options.verifyBaseRemeasure,\n\t\t// The host's file system reads the shared `.git/config` the watch service compares reports of\n\t\treadFile: path => options.context.fs.readFile(fileUri(path)),\n\t\t// And lists the directory the admin entries of its worktrees are in\n\t\treadDirectory: path => options.context.fs.readDirectory(fileUri(path)),\n\t});\n\n\tconst locator = options.locator ?? (() => findGitPath(options.gitPath ?? null));\n\tconst provider = new CliGitProvider({\n\t\tcontext: options.context,\n\t\tlocator: locator,\n\t\tgitOptions: options.gitOptions,\n\t\tcache: options.cache,\n\t\tignoredWorktreeFolders: options.ignoredWorktreeFolders,\n\t\trefreshIndexAfterWrites: options.refreshIndexAfterWrites,\n\t});\n\n\tservice.register(provider, () => true);\n\n\tif (options.validateUnwatchedCaches) {\n\t\tconst fs = options.context.fs;\n\t\tconst validator = new UnwatchedCacheValidator({\n\t\t\tcache: provider.cache,\n\t\t\ttimeoutMs:\n\t\t\t\ttypeof options.validateUnwatchedCaches === 'object'\n\t\t\t\t\t? options.validateUnwatchedCaches.timeoutMs\n\t\t\t\t\t: undefined,\n\t\t\tmaxFsThreads: getThreadPoolSize() - 2,\n\t\t\tstat: async path => {\n\t\t\t\ttry {\n\t\t\t\t\tconst stat = await fs.stat(fileUri(path));\n\t\t\t\t\treturn stat != null ? { mtime: stat.mtime, size: stat.size } : undefined;\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (isNotFound(ex)) return undefined;\n\n\t\t\t\t\tthrow ex;\n\t\t\t\t}\n\t\t\t},\n\t\t\treadDirectory: path => fs.readDirectory(fileUri(path)),\n\t\t\treadFile: async path => {\n\t\t\t\ttry {\n\t\t\t\t\treturn await fs.readFile(fileUri(path));\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (isNotFound(ex)) return undefined;\n\n\t\t\t\t\tthrow ex;\n\t\t\t\t}\n\t\t\t},\n\t\t\t// Only for a path whose git dir is cached, which it finds the common git dir from without running git\n\t\t\tgetIgnoredWorktreeRoots: repoPath =>\n\t\t\t\tprovider.cache.gitDir.get(repoPath) != null\n\t\t\t\t\t? provider.getIgnoredWorktreeRoots(repoPath)\n\t\t\t\t\t: Promise.resolve([]),\n\t\t\tresolveGitDir: repoPath => provider.config.resolveGitDirWithoutGit(repoPath),\n\t\t\t// The watch service keys repositories as the cache does (`getRepositoryKey` normalizes a file path alike)\n\t\t\tisWatched: repoPath => service.watchService?.isRepoWatched(repoPath) ?? false,\n\t\t});\n\t\tprovider.cache.setReadValidator(\n\t\t\trepoPath => validator.validate(repoPath),\n\t\t\t() => validator.getResourceUsage(),\n\t\t);\n\t\tservice.watchService?.onDidChangeRepoWatched(e => {\n\t\t\tif (e.watched) {\n\t\t\t\tvalidator.onWatched(e.repoPath);\n\t\t\t} else {\n\t\t\t\tvalidator.onUnwatched(e.repoPath);\n\t\t\t}\n\t\t});\n\t}\n\n\t// Advance the provider cache's status generation clock from the watch session's global events — the standalone\n\t// analogue of what the VS Code host wires in `GitProviderService`. Without this, a consumer that passes a\n\t// `watchingProvider` and drives watch sessions gets FS events but a FROZEN clock, so `dedupeByStatusGeneration`\n\t// degrades to the pre-change/post-change stale-join this branch exists to fix. Standalone has no `Repository`\n\t// models, so there are no force-fired `closed`/`lastFetched` bypassing the session for the global repo event to\n\t// miss. Subscriptions are torn down with the service (its `watchService`'s emitters are disposed on dispose).\n\tservice.watchService?.onDidChangeWorkingTree(repoPath => provider.cache.onWorkingTreeChanged(repoPath));\n\t// Announced kinds were evicted when core announced its write; evicting them again would discard what the host\n\t// re-read since\n\tservice.watchService?.onDidChangeRepository(e => {\n\t\tconst changes = e.getUnannouncedChanges();\n\t\tif (changes.length) {\n\t\t\tprovider.cache.onRepositoryChanged(e.repoPath, changes, { movedWorktrees: e.movedWorktrees });\n\t\t}\n\t});\n\t// FETCH_HEAD maps to no session change, and there's no `Repository` model here to force-fire `lastFetched` (as\n\t// the VS Code host does), so bridge it straight to the cache or the last-fetched time is never re-read.\n\tservice.watchService?.onDidChangeFetchHead(repoPath =>\n\t\tprovider.cache.onRepositoryChanged(repoPath, ['lastFetched']),\n\t);\n\treturn service;\n}\n\n/** The size of libuv's thread pool, which runs Node's file-system calls, as libuv reads it at its first use */\nfunction getThreadPoolSize(): number {\n\tconst size = Number.parseInt(env.UV_THREADPOOL_SIZE ?? '', 10);\n\treturn Number.isNaN(size) ? 4 : Math.min(Math.max(size, 1), 1024);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAuGA,SAAgB,oBAAoB,SAA2C;CAC9E,MAAM,UAAU,WAAW,gBAAgB,QAAQ,kBAAkB;EACpE,cAAc,QAAQ;EACtB,qBAAqB,QAAQ;EAE7B,WAAU,SAAQ,QAAQ,QAAQ,GAAG,SAAS,QAAQ,IAAI,CAAC;EAE3D,gBAAe,SAAQ,QAAQ,QAAQ,GAAG,cAAc,QAAQ,IAAI,CAAC;CACtE,CAAC;CAED,MAAM,UAAU,QAAQ,kBAAkB,YAAY,QAAQ,WAAW,IAAI;CAC7E,MAAM,WAAW,IAAI,eAAe;EACnC,SAAS,QAAQ;EACR;EACT,YAAY,QAAQ;EACpB,OAAO,QAAQ;EACf,wBAAwB,QAAQ;EA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AQ,CAAC;CAGtG,QAAQ,cAAc,uBAAsB,MAAK;EAChD,MAAM,UAAU,EAAE,sBAAsB;EACxC,IAAI,QAAQ,QACX,SAAS,MAAM,oBAAoB,EAAE,UAAU,SAAS,EAAE,gBAAgB,EAAE,eAAe,CAAC;CAE9F,CAAC;CAGD,QAAQ,cAAc,sBAAqB,aAC1C,SAAS,MAAM,oBAAoB,UAAU,CAAC,aAAa,CAAC,CAC7D;CACA,OAAO;AACR;;AAGA,SAAS,oBAA4B;CACpC,MAAM,OAAO,OAAO,SAAS,IAAI,sBAAsB,IAAI,EAAE;CAC7D,OAAO,OAAO,MAAM,IAAI,IAAI,IAAI,KAAK,IAAI,KAAK,IAAI,MAAM,CAAC,GAAG,IAAI;AACjE"}
|
package/dist/plus/ai/errors.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AIModel } from "./models/model.js";
|
|
1
2
|
//#region ../plus/ai/src/errors.d.ts
|
|
2
3
|
export declare const enum AIErrorReason {
|
|
3
4
|
DeniedByOrganization = 0,
|
|
@@ -12,13 +13,18 @@ export declare const enum AIErrorReason {
|
|
|
12
13
|
Unauthorized = 9,
|
|
13
14
|
UserQuotaExceeded = 10,
|
|
14
15
|
NoNetwork = 11,
|
|
15
|
-
Unreachable = 12
|
|
16
|
+
Unreachable = 12,
|
|
17
|
+
ModelUnavailable = 13
|
|
16
18
|
}
|
|
17
19
|
export declare class AIError extends Error {
|
|
18
20
|
readonly diagnosticMessage: string;
|
|
19
21
|
readonly original?: Error;
|
|
20
22
|
readonly reason: AIErrorReason | undefined;
|
|
21
|
-
|
|
23
|
+
/** Optional provider context. Omitted preserves the legacy GitKraken quota message and credit offers, so a
|
|
24
|
+
* non-GitKraken provider must pass its own to get provider-neutral text (and no credit offers). Also names
|
|
25
|
+
* the provider in the model-unavailable message. */
|
|
26
|
+
readonly provider?: AIModel['provider'];
|
|
27
|
+
constructor(reason: AIErrorReason, original?: Error, provider?: AIModel['provider']);
|
|
22
28
|
get diagnosticString(): string;
|
|
23
29
|
}
|
|
24
30
|
export declare class AuthenticationRequiredError extends Error {
|
package/dist/plus/ai/errors.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { gitKrakenProviderDescriptor } from "./constants.js";
|
|
1
2
|
import * as l10n from "@vscode/l10n";
|
|
2
3
|
//#region ../plus/ai/src/errors.ts
|
|
3
4
|
let AIErrorReason = /* @__PURE__ */ function(AIErrorReason) {
|
|
@@ -14,13 +15,18 @@ let AIErrorReason = /* @__PURE__ */ function(AIErrorReason) {
|
|
|
14
15
|
AIErrorReason[AIErrorReason["UserQuotaExceeded"] = 10] = "UserQuotaExceeded";
|
|
15
16
|
AIErrorReason[AIErrorReason["NoNetwork"] = 11] = "NoNetwork";
|
|
16
17
|
AIErrorReason[AIErrorReason["Unreachable"] = 12] = "Unreachable";
|
|
18
|
+
AIErrorReason[AIErrorReason["ModelUnavailable"] = 13] = "ModelUnavailable";
|
|
17
19
|
return AIErrorReason;
|
|
18
20
|
}({});
|
|
19
21
|
var AIError = class extends Error {
|
|
20
22
|
diagnosticMessage;
|
|
21
23
|
original;
|
|
22
24
|
reason;
|
|
23
|
-
|
|
25
|
+
/** Optional provider context. Omitted preserves the legacy GitKraken quota message and credit offers, so a
|
|
26
|
+
* non-GitKraken provider must pass its own to get provider-neutral text (and no credit offers). Also names
|
|
27
|
+
* the provider in the model-unavailable message. */
|
|
28
|
+
provider;
|
|
29
|
+
constructor(reason, original, provider) {
|
|
24
30
|
let message;
|
|
25
31
|
let diagnosticMessage;
|
|
26
32
|
switch (reason) {
|
|
@@ -34,7 +40,7 @@ var AIError = class extends Error {
|
|
|
34
40
|
break;
|
|
35
41
|
case 10:
|
|
36
42
|
diagnosticMessage = "You have exceeded your user token limit";
|
|
37
|
-
message = l10n.t("You’ve reached the weekly AI usage included in your plan.");
|
|
43
|
+
message = provider != null && provider.id !== gitKrakenProviderDescriptor.id ? l10n.t("You’ve reached the AI usage limit for {0}. Check your plan and usage with {0}, or switch to a different provider.", provider.name) : l10n.t("You’ve reached the weekly AI usage included in your plan.");
|
|
38
44
|
break;
|
|
39
45
|
case 4:
|
|
40
46
|
diagnosticMessage = "Rate limit exceeded";
|
|
@@ -64,6 +70,10 @@ var AIError = class extends Error {
|
|
|
64
70
|
diagnosticMessage = "Model not supported for this request";
|
|
65
71
|
message = l10n.t("Model not supported for this request");
|
|
66
72
|
break;
|
|
73
|
+
case 13:
|
|
74
|
+
diagnosticMessage = "Model is no longer available";
|
|
75
|
+
message = provider != null ? l10n.t("The selected model is no longer available from {0}. Switch to a different model and try again.", provider.name) : l10n.t("The selected model is no longer available. Switch to a different model and try again.");
|
|
76
|
+
break;
|
|
67
77
|
case 9:
|
|
68
78
|
diagnosticMessage = "You are not authorized to use the specified provider or model";
|
|
69
79
|
message = l10n.t("You are not authorized to use the specified provider or model");
|
|
@@ -84,6 +94,7 @@ var AIError = class extends Error {
|
|
|
84
94
|
this.diagnosticMessage = diagnosticMessage;
|
|
85
95
|
this.original = original;
|
|
86
96
|
this.reason = reason;
|
|
97
|
+
this.provider = provider;
|
|
87
98
|
Error.captureStackTrace?.(this, new.target);
|
|
88
99
|
}
|
|
89
100
|
get diagnosticString() {
|
|
@@ -157,7 +168,8 @@ function isAIUnavailableError(ex) {
|
|
|
157
168
|
case 10:
|
|
158
169
|
case 11:
|
|
159
170
|
case 12:
|
|
160
|
-
case 7:
|
|
171
|
+
case 7:
|
|
172
|
+
case 13: return true;
|
|
161
173
|
default: return false;
|
|
162
174
|
}
|
|
163
175
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","names":[],"sources":["../../../../plus/ai/src/errors.ts"],"sourcesContent":["import * as l10n from '@vscode/l10n';\n\nexport const enum AIErrorReason {\n\tDeniedByOrganization,\n\tDeniedByUser,\n\tNoEntitlement,\n\tNoRequestData,\n\tRateLimitExceeded,\n\tRateLimitOrFundsExceeded,\n\tRequestTooLarge,\n\tModelNotSupported,\n\tServiceCapacityExceeded,\n\tUnauthorized,\n\tUserQuotaExceeded,\n\tNoNetwork,\n\tUnreachable,\n}\n\nexport class AIError extends Error {\n\treadonly diagnosticMessage: string;\n\treadonly original?: Error;\n\treadonly reason: AIErrorReason | undefined;\n\n\tconstructor(reason: AIErrorReason, original?: Error) {\n\t\tlet message: string;\n\t\tlet diagnosticMessage: string;\n\t\tswitch (reason) {\n\t\t\tcase AIErrorReason.NoEntitlement:\n\t\t\t\tdiagnosticMessage = 'You do not have the required entitlement to use this feature';\n\t\t\t\tmessage = l10n.t('You do not have the required entitlement to use this feature');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.RequestTooLarge:\n\t\t\t\tdiagnosticMessage = 'The request is too large';\n\t\t\t\tmessage = l10n.t('The request is too large');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.UserQuotaExceeded:\n\t\t\t\tdiagnosticMessage = 'You have exceeded your user token limit';\n\t\t\t\tmessage = l10n.t('You’ve reached the weekly AI usage included in your plan.');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.RateLimitExceeded:\n\t\t\t\tdiagnosticMessage = 'Rate limit exceeded';\n\t\t\t\tmessage = l10n.t('Rate limit exceeded.');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.RateLimitOrFundsExceeded:\n\t\t\t\tdiagnosticMessage = 'Rate limit exceeded or your account is out of funds';\n\t\t\t\tmessage = l10n.t('Rate limit exceeded or your account is out of funds.');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.ServiceCapacityExceeded:\n\t\t\t\tdiagnosticMessage = 'Service capacity exceeded';\n\t\t\t\tmessage = l10n.t('Service capacity exceeded.');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.NoNetwork:\n\t\t\t\tdiagnosticMessage = 'Unable to reach the AI service. Please check your internet connection.';\n\t\t\t\tmessage = l10n.t('Unable to reach the AI service. Please check your internet connection.');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.Unreachable:\n\t\t\t\tdiagnosticMessage = 'The AI service is temporarily unreachable.';\n\t\t\t\tmessage = l10n.t('The AI service is temporarily unreachable.');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.NoRequestData:\n\t\t\t\tdiagnosticMessage = original?.message ?? 'No data was provided for the request';\n\t\t\t\tmessage = original?.message ?? l10n.t('No data was provided for the request');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.ModelNotSupported:\n\t\t\t\tdiagnosticMessage = 'Model not supported for this request';\n\t\t\t\tmessage = l10n.t('Model not supported for this request');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.Unauthorized:\n\t\t\t\tdiagnosticMessage = 'You are not authorized to use the specified provider or model';\n\t\t\t\tmessage = l10n.t('You are not authorized to use the specified provider or model');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.DeniedByOrganization:\n\t\t\t\tdiagnosticMessage = 'Your organization has denied access to the specified provider or model';\n\t\t\t\tmessage = l10n.t('Your organization has denied access to the specified provider or model');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.DeniedByUser:\n\t\t\t\tdiagnosticMessage = 'You have denied access to the specified provider or model';\n\t\t\t\tmessage = l10n.t('You have denied access to the specified provider or model');\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tdiagnosticMessage = original?.message ?? 'An unknown error occurred';\n\t\t\t\tmessage = original?.message ?? l10n.t('An unknown error occurred');\n\t\t\t\tbreak;\n\t\t}\n\n\t\tsuper(message);\n\n\t\tthis.diagnosticMessage = diagnosticMessage;\n\t\tthis.original = original;\n\t\tthis.reason = reason;\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n\n\tget diagnosticString(): string {\n\t\treturn `${this.name}: ${this.diagnosticMessage}`;\n\t}\n}\n\nexport class AuthenticationRequiredError extends Error {\n\tconstructor() {\n\t\tsuper(l10n.t('Authentication required'));\n\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n}\n\nexport class AINoRequestDataError extends AIError {\n\tconstructor(message?: string) {\n\t\tsuper(AIErrorReason.NoRequestData, message ? new Error(message) : undefined);\n\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n}\n\nconst noNetworkErrorCodes = new Set([\n\t'ENOTFOUND',\n\t'ECONNREFUSED',\n\t'EAI_AGAIN',\n\t'EHOSTUNREACH',\n\t'ENETUNREACH',\n\t'ENETDOWN',\n\t'UND_ERR_CONNECT_TIMEOUT',\n]);\n\nconst unreachableErrorCodes = new Set(['ECONNRESET', 'ETIMEDOUT', 'UND_ERR_SOCKET']);\n\nexport function classifyNetworkError(ex: unknown): AIErrorReason.NoNetwork | AIErrorReason.Unreachable | undefined {\n\tlet current: unknown = ex;\n\tlet sawFetchFailed = false;\n\tfor (let depth = 0; depth < 5 && current != null; depth++) {\n\t\tif (!(current instanceof Error)) break;\n\n\t\tif (current.name === 'TypeError' && current.message === 'fetch failed') {\n\t\t\tsawFetchFailed = true;\n\t\t}\n\t\tconst code = (current as { code?: unknown }).code;\n\t\tif (typeof code === 'string') {\n\t\t\tif (noNetworkErrorCodes.has(code)) return AIErrorReason.NoNetwork;\n\t\t\tif (unreachableErrorCodes.has(code)) return AIErrorReason.Unreachable;\n\t\t}\n\n\t\tcurrent = (current as { cause?: unknown }).cause;\n\t}\n\treturn sawFetchFailed ? AIErrorReason.NoNetwork : undefined;\n}\n\n/**\n * Whether an error means AI itself is unavailable, rather than this particular request being\n * unacceptable. The distinction matters to any caller running a loop: an unavailable-AI failure will\n * repeat identically for every remaining item, so the loop should stop and say so, while a\n * request-shaped failure (too large, no data) may well succeed on the next item.\n *\n * `RequestTooLarge` and `NoRequestData` are therefore deliberately excluded — they're properties of\n * the one request that failed.\n *\n * An `AuthenticationRequiredError` (expired GitKraken session) counts too: it isn't an `AIError`, but\n * every remaining request will fail identically until the user signs in again.\n */\nexport function isAIUnavailableError(ex: unknown): ex is AIError | AuthenticationRequiredError {\n\tif (ex instanceof AuthenticationRequiredError) return true;\n\tif (!(ex instanceof AIError)) return false;\n\n\tswitch (ex.reason) {\n\t\tcase AIErrorReason.DeniedByOrganization:\n\t\tcase AIErrorReason.DeniedByUser:\n\t\tcase AIErrorReason.NoEntitlement:\n\t\tcase AIErrorReason.RateLimitExceeded:\n\t\tcase AIErrorReason.RateLimitOrFundsExceeded:\n\t\tcase AIErrorReason.ServiceCapacityExceeded:\n\t\tcase AIErrorReason.Unauthorized:\n\t\tcase AIErrorReason.UserQuotaExceeded:\n\t\tcase AIErrorReason.NoNetwork:\n\t\tcase AIErrorReason.Unreachable:\n\t\tcase AIErrorReason.ModelNotSupported:\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n"],"mappings":";;AAEA,IAAkB,gBAAX,yBAAA,eAAA;CACN,cAAA,cAAA,0BAAA,KAAA;CACA,cAAA,cAAA,kBAAA,KAAA;CACA,cAAA,cAAA,mBAAA,KAAA;CACA,cAAA,cAAA,mBAAA,KAAA;CACA,cAAA,cAAA,uBAAA,KAAA;CACA,cAAA,cAAA,8BAAA,KAAA;CACA,cAAA,cAAA,qBAAA,KAAA;CACA,cAAA,cAAA,uBAAA,KAAA;CACA,cAAA,cAAA,6BAAA,KAAA;CACA,cAAA,cAAA,kBAAA,KAAA;CACA,cAAA,cAAA,uBAAA,MAAA;CACA,cAAA,cAAA,eAAA,MAAA;CACA,cAAA,cAAA,iBAAA,MAAA;;AACD,EAAA,CAAA,CAAA;AAEA,IAAa,UAAb,cAA6B,MAAM;CAClC;CACA;CACA;CAEA,YAAY,QAAuB,UAAkB;EACpD,IAAI;EACJ,IAAI;EACJ,QAAQ,QAAR;GACC,KAAA;IACC,oBAAoB;IACpB,UAAU,KAAK,EAAE,8DAA8D;IAC/E;GACD,KAAA;IACC,oBAAoB;IACpB,UAAU,KAAK,EAAE,0BAA0B;IAC3C;GACD,KAAA;IACC,oBAAoB;IACpB,UAAU,KAAK,EAAE,2DAA2D;IAC5E;GACD,KAAA;IACC,oBAAoB;IACpB,UAAU,KAAK,EAAE,sBAAsB;IACvC;GACD,KAAA;IACC,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,IAAI,IAAI;CAAC;CAAc;CAAa;AAAgB,CAAC;AAEnF,SAAgB,qBAAqB,IAA8E;CAClH,IAAI,UAAmB;CACvB,IAAI,iBAAiB;CACrB,KAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,WAAW,MAAM,SAAS;EAC1D,IAAI,EAAE,mBAAmB,QAAQ;EAEjC,IAAI,QAAQ,SAAS,eAAe,QAAQ,YAAY,gBACvD,iBAAiB;EAElB,MAAM,OAAQ,QAA+B;EAC7C,IAAI,OAAO,SAAS,UAAU;GAC7B,IAAI,oBAAoB,IAAI,IAAI,GAAG,OAAA;GACnC,IAAI,sBAAsB,IAAI,IAAI,GAAG,OAAA;EACtC;EAEA,UAAW,QAAgC;CAC5C;CACA,OAAO,iBAAA,KAA2C,KAAA;AACnD;;;;;;;;;;;;;AAcA,SAAgB,qBAAqB,IAA0D;CAC9F,IAAI,cAAc,6BAA6B,OAAO;CACtD,IAAI,EAAE,cAAc,UAAU,OAAO;CAErC,QAAQ,GAAG,QAAX;EACC,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA,GACC,OAAO;EACR,SACC,OAAO;CACT;AACD"}
|
|
1
|
+
{"version":3,"file":"errors.js","names":[],"sources":["../../../../plus/ai/src/errors.ts"],"sourcesContent":["import * as l10n from '@vscode/l10n';\nimport { gitKrakenProviderDescriptor } from './constants.js';\nimport type { AIModel } from './models/model.js';\n\nexport const enum AIErrorReason {\n\tDeniedByOrganization,\n\tDeniedByUser,\n\tNoEntitlement,\n\tNoRequestData,\n\tRateLimitExceeded,\n\tRateLimitOrFundsExceeded,\n\tRequestTooLarge,\n\tModelNotSupported,\n\tServiceCapacityExceeded,\n\tUnauthorized,\n\tUserQuotaExceeded,\n\tNoNetwork,\n\tUnreachable,\n\tModelUnavailable,\n}\n\nexport class AIError extends Error {\n\treadonly diagnosticMessage: string;\n\treadonly original?: Error;\n\treadonly reason: AIErrorReason | undefined;\n\t/** Optional provider context. Omitted preserves the legacy GitKraken quota message and credit offers, so a\n\t * non-GitKraken provider must pass its own to get provider-neutral text (and no credit offers). Also names\n\t * the provider in the model-unavailable message. */\n\treadonly provider?: AIModel['provider'];\n\n\tconstructor(reason: AIErrorReason, original?: Error, provider?: AIModel['provider']) {\n\t\tlet message: string;\n\t\tlet diagnosticMessage: string;\n\t\tswitch (reason) {\n\t\t\tcase AIErrorReason.NoEntitlement:\n\t\t\t\tdiagnosticMessage = 'You do not have the required entitlement to use this feature';\n\t\t\t\tmessage = l10n.t('You do not have the required entitlement to use this feature');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.RequestTooLarge:\n\t\t\t\tdiagnosticMessage = 'The request is too large';\n\t\t\t\tmessage = l10n.t('The request is too large');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.UserQuotaExceeded:\n\t\t\t\tdiagnosticMessage = 'You have exceeded your user token limit';\n\t\t\t\tmessage =\n\t\t\t\t\tprovider != null && provider.id !== gitKrakenProviderDescriptor.id\n\t\t\t\t\t\t? l10n.t(\n\t\t\t\t\t\t\t\t'You’ve reached the AI usage limit for {0}. Check your plan and usage with {0}, or switch to a different provider.',\n\t\t\t\t\t\t\t\tprovider.name,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: l10n.t('You’ve reached the weekly AI usage included in your plan.');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.RateLimitExceeded:\n\t\t\t\tdiagnosticMessage = 'Rate limit exceeded';\n\t\t\t\tmessage = l10n.t('Rate limit exceeded.');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.RateLimitOrFundsExceeded:\n\t\t\t\tdiagnosticMessage = 'Rate limit exceeded or your account is out of funds';\n\t\t\t\tmessage = l10n.t('Rate limit exceeded or your account is out of funds.');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.ServiceCapacityExceeded:\n\t\t\t\tdiagnosticMessage = 'Service capacity exceeded';\n\t\t\t\tmessage = l10n.t('Service capacity exceeded.');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.NoNetwork:\n\t\t\t\tdiagnosticMessage = 'Unable to reach the AI service. Please check your internet connection.';\n\t\t\t\tmessage = l10n.t('Unable to reach the AI service. Please check your internet connection.');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.Unreachable:\n\t\t\t\tdiagnosticMessage = 'The AI service is temporarily unreachable.';\n\t\t\t\tmessage = l10n.t('The AI service is temporarily unreachable.');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.NoRequestData:\n\t\t\t\tdiagnosticMessage = original?.message ?? 'No data was provided for the request';\n\t\t\t\tmessage = original?.message ?? l10n.t('No data was provided for the request');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.ModelNotSupported:\n\t\t\t\tdiagnosticMessage = 'Model not supported for this request';\n\t\t\t\tmessage = l10n.t('Model not supported for this request');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.ModelUnavailable:\n\t\t\t\tdiagnosticMessage = 'Model is no longer available';\n\t\t\t\tmessage =\n\t\t\t\t\tprovider != null\n\t\t\t\t\t\t? l10n.t(\n\t\t\t\t\t\t\t\t'The selected model is no longer available from {0}. Switch to a different model and try again.',\n\t\t\t\t\t\t\t\tprovider.name,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: l10n.t(\n\t\t\t\t\t\t\t\t'The selected model is no longer available. Switch to a different model and try again.',\n\t\t\t\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.Unauthorized:\n\t\t\t\tdiagnosticMessage = 'You are not authorized to use the specified provider or model';\n\t\t\t\tmessage = l10n.t('You are not authorized to use the specified provider or model');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.DeniedByOrganization:\n\t\t\t\tdiagnosticMessage = 'Your organization has denied access to the specified provider or model';\n\t\t\t\tmessage = l10n.t('Your organization has denied access to the specified provider or model');\n\t\t\t\tbreak;\n\t\t\tcase AIErrorReason.DeniedByUser:\n\t\t\t\tdiagnosticMessage = 'You have denied access to the specified provider or model';\n\t\t\t\tmessage = l10n.t('You have denied access to the specified provider or model');\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tdiagnosticMessage = original?.message ?? 'An unknown error occurred';\n\t\t\t\tmessage = original?.message ?? l10n.t('An unknown error occurred');\n\t\t\t\tbreak;\n\t\t}\n\n\t\tsuper(message);\n\n\t\tthis.diagnosticMessage = diagnosticMessage;\n\t\tthis.original = original;\n\t\tthis.reason = reason;\n\t\tthis.provider = provider;\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n\n\tget diagnosticString(): string {\n\t\treturn `${this.name}: ${this.diagnosticMessage}`;\n\t}\n}\n\nexport class AuthenticationRequiredError extends Error {\n\tconstructor() {\n\t\tsuper(l10n.t('Authentication required'));\n\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n}\n\nexport class AINoRequestDataError extends AIError {\n\tconstructor(message?: string) {\n\t\tsuper(AIErrorReason.NoRequestData, message ? new Error(message) : undefined);\n\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n}\n\nconst noNetworkErrorCodes = new Set([\n\t'ENOTFOUND',\n\t'ECONNREFUSED',\n\t'EAI_AGAIN',\n\t'EHOSTUNREACH',\n\t'ENETUNREACH',\n\t'ENETDOWN',\n\t'UND_ERR_CONNECT_TIMEOUT',\n]);\n\nconst unreachableErrorCodes = new Set(['ECONNRESET', 'ETIMEDOUT', 'UND_ERR_SOCKET']);\n\nexport function classifyNetworkError(ex: unknown): AIErrorReason.NoNetwork | AIErrorReason.Unreachable | undefined {\n\tlet current: unknown = ex;\n\tlet sawFetchFailed = false;\n\tfor (let depth = 0; depth < 5 && current != null; depth++) {\n\t\tif (!(current instanceof Error)) break;\n\n\t\tif (current.name === 'TypeError' && current.message === 'fetch failed') {\n\t\t\tsawFetchFailed = true;\n\t\t}\n\t\tconst code = (current as { code?: unknown }).code;\n\t\tif (typeof code === 'string') {\n\t\t\tif (noNetworkErrorCodes.has(code)) return AIErrorReason.NoNetwork;\n\t\t\tif (unreachableErrorCodes.has(code)) return AIErrorReason.Unreachable;\n\t\t}\n\n\t\tcurrent = (current as { cause?: unknown }).cause;\n\t}\n\treturn sawFetchFailed ? AIErrorReason.NoNetwork : undefined;\n}\n\n/**\n * Whether an error means AI itself is unavailable, rather than this particular request being\n * unacceptable. The distinction matters to any caller running a loop: an unavailable-AI failure will\n * repeat identically for every remaining item, so the loop should stop and say so, while a\n * request-shaped failure (too large, no data) may well succeed on the next item.\n *\n * `RequestTooLarge` and `NoRequestData` are therefore deliberately excluded — they're properties of\n * the one request that failed.\n *\n * An `AuthenticationRequiredError` (expired GitKraken session) counts too: it isn't an `AIError`, but\n * every remaining request will fail identically until the user signs in again.\n */\nexport function isAIUnavailableError(ex: unknown): ex is AIError | AuthenticationRequiredError {\n\tif (ex instanceof AuthenticationRequiredError) return true;\n\tif (!(ex instanceof AIError)) return false;\n\n\tswitch (ex.reason) {\n\t\tcase AIErrorReason.DeniedByOrganization:\n\t\tcase AIErrorReason.DeniedByUser:\n\t\tcase AIErrorReason.NoEntitlement:\n\t\tcase AIErrorReason.RateLimitExceeded:\n\t\tcase AIErrorReason.RateLimitOrFundsExceeded:\n\t\tcase AIErrorReason.ServiceCapacityExceeded:\n\t\tcase AIErrorReason.Unauthorized:\n\t\tcase AIErrorReason.UserQuotaExceeded:\n\t\tcase AIErrorReason.NoNetwork:\n\t\tcase AIErrorReason.Unreachable:\n\t\tcase AIErrorReason.ModelNotSupported:\n\t\tcase AIErrorReason.ModelUnavailable:\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n"],"mappings":";;;AAIA,IAAkB,gBAAX,yBAAA,eAAA;CACN,cAAA,cAAA,0BAAA,KAAA;CACA,cAAA,cAAA,kBAAA,KAAA;CACA,cAAA,cAAA,mBAAA,KAAA;CACA,cAAA,cAAA,mBAAA,KAAA;CACA,cAAA,cAAA,uBAAA,KAAA;CACA,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,IAAI,IAAI,GAAG,OAAA;GACnC,IAAI,sBAAsB,IAAI,IAAI,GAAG,OAAA;EACtC;EAEA,UAAW,QAAgC;CAC5C;CACA,OAAO,iBAAA,KAA2C,KAAA;AACnD;;;;;;;;;;;;;AAcA,SAAgB,qBAAqB,IAA0D;CAC9F,IAAI,cAAc,6BAA6B,OAAO;CACtD,IAAI,EAAE,cAAc,UAAU,OAAO;CAErC,QAAQ,GAAG,QAAX;EACC,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA,IACC,OAAO;EACR,SACC,OAAO;CACT;AACD"}
|
|
@@ -6,7 +6,7 @@ import { Provider } from "../../../git/models/remoteProvider.js";
|
|
|
6
6
|
import { GitUser } from "../../../git/models/user.js";
|
|
7
7
|
import { IssueOrPullRequest, IssueOrPullRequestState } from "../../../git/models/issueOrPullRequest.js";
|
|
8
8
|
import { Issue, IssueSearchCriteria, IssueShape, IssueSorting } from "../../../git/models/issue.js";
|
|
9
|
-
import { PullRequest, PullRequestMergeMethod, PullRequestSearchCriteria, PullRequestShape, PullRequestStateFilter } from "../../../git/models/pullRequest.js";
|
|
9
|
+
import { PullRequest, PullRequestMergeMethod, PullRequestMergeQueueActionFailureReason, PullRequestMergeQueueActionResult, PullRequestMergeQueueEntry, PullRequestSearchCriteria, PullRequestShape, PullRequestStateFilter } from "../../../git/models/pullRequest.js";
|
|
10
10
|
import { Account, UnidentifiedAuthor } from "../../../git/models/author.js";
|
|
11
11
|
import { DefaultBranch } from "../../../git/models/defaultBranch.js";
|
|
12
12
|
import { RepositoryMetadata } from "../../../git/models/repositoryMetadata.js";
|
|
@@ -647,6 +647,20 @@ export declare class GitHubApi {
|
|
|
647
647
|
getRepositoryStacks(provider: Provider, token: GitHubTokenInfo, owner: string, repo: string, options?: {
|
|
648
648
|
baseUrl?: string;
|
|
649
649
|
}, cancellation?: AbortSignal): Promise<GitHubStackResource[] | undefined>;
|
|
650
|
+
/**
|
|
651
|
+
* The merge-queue entries of the given base branches, keyed by pull request number, in one request — each
|
|
652
|
+
* branch's queue is an alias on the one `repository` selection. For list surfaces whose pull requests arrive
|
|
653
|
+
* through provider-apis' repository-scoped read, which selects no `mergeQueueEntry`; callers join by number.
|
|
654
|
+
*
|
|
655
|
+
* INTERIM: remove once provider-apis carries the merge-queue entry on its pull requests (goals S6).
|
|
656
|
+
*
|
|
657
|
+
* github.com only, like the `mergeQueueEntry` selection: `undefined` on GitHub Enterprise Server, whose schema
|
|
658
|
+
* isn't verified to have `mergeQueue`, and for a repository GitHub reports not found. A branch without a queue
|
|
659
|
+
* contributes nothing. At most the first 100 entries of each queue are read.
|
|
660
|
+
*/
|
|
661
|
+
getMergeQueueEntriesForBranches(provider: Provider, token: GitHubTokenInfo, owner: string, repo: string, branches: readonly string[], options?: {
|
|
662
|
+
baseUrl?: string;
|
|
663
|
+
}, cancellation?: AbortSignal): Promise<Map<number, PullRequestMergeQueueEntry> | undefined>;
|
|
650
664
|
/**
|
|
651
665
|
* Merges a stacked pull request, and with it every layer below it.
|
|
652
666
|
*
|
|
@@ -662,7 +676,43 @@ export declare class GitHubApi {
|
|
|
662
676
|
mergeMethod?: PullRequestMergeMethod;
|
|
663
677
|
baseUrl?: string;
|
|
664
678
|
}, cancellation?: AbortSignal): Promise<boolean>;
|
|
679
|
+
/**
|
|
680
|
+
* Adds a pull request to its base branch's merge queue, at the back (no `jump`). GitHub takes no merge method here:
|
|
681
|
+
* the base branch's ruleset decides it. `expectedHeadSha` makes GitHub refuse a head that moved since it was read.
|
|
682
|
+
*
|
|
683
|
+
* GitHub's refusals come back as a `failed` result saying why (see {@link toGitHubMergeQueueActionFailure}),
|
|
684
|
+
* without prompting to re-authenticate on a FORBIDDEN, which here means the account may not queue, not that the
|
|
685
|
+
* token is bad. A failure to reach GitHub, a refused credential or a rate limit is thrown as from any other request,
|
|
686
|
+
* and cancellation throws `CancellationError`. Like every mutation it is never retried. github.com only, like the
|
|
687
|
+
* merge-queue reads: `unsupported` on GitHub Enterprise Server, whose schema isn't verified to have it.
|
|
688
|
+
*/
|
|
689
|
+
enqueuePullRequest(provider: Provider, token: GitHubTokenInfo, nodeId: string, expectedHeadSha: string, options?: {
|
|
690
|
+
baseUrl?: string;
|
|
691
|
+
}, cancellation?: AbortSignal): Promise<PullRequestMergeQueueActionResult>;
|
|
692
|
+
/**
|
|
693
|
+
* Removes a pull request from its base branch's merge queue, losing its place there. Fails and throws as
|
|
694
|
+
* {@link enqueuePullRequest} does, and is github.com only like it.
|
|
695
|
+
*/
|
|
696
|
+
dequeuePullRequest(provider: Provider, token: GitHubTokenInfo, nodeId: string, options?: {
|
|
697
|
+
baseUrl?: string;
|
|
698
|
+
}, cancellation?: AbortSignal): Promise<PullRequestMergeQueueActionResult>;
|
|
665
699
|
}
|
|
700
|
+
/**
|
|
701
|
+
* Why GitHub refused to add a pull request to its merge queue or remove it, from the error its GraphQL answer carried
|
|
702
|
+
* (`errors[]`, which `graphql` throws as a `GraphqlResponseError`, or wraps in an `AuthenticationError` for FORBIDDEN
|
|
703
|
+
* and a `RequestNotFoundError` for NOT_FOUND). `undefined` for anything that isn't GitHub's answer about the action
|
|
704
|
+
* — a failure to reach it, a refused credential (HTTP 401/403), a rate limit — which the caller handles like any
|
|
705
|
+
* other request's failure.
|
|
706
|
+
*
|
|
707
|
+
* Only the wordings observed live (2026-11-06; see {@link mergeQueueActionFailurePatterns}) are recognized. Dequeue's
|
|
708
|
+
* refusal is generic and embeds the pull request's title, so it is never matched by wording and maps to `unknown`.
|
|
709
|
+
* When no message matches, the error's `type` decides (FORBIDDEN is `permission`), and anything else is `unknown`.
|
|
710
|
+
* The message is GitHub's own, for logs, never for display.
|
|
711
|
+
*/
|
|
712
|
+
export declare function toGitHubMergeQueueActionFailure(ex: unknown): {
|
|
713
|
+
reason: PullRequestMergeQueueActionFailureReason;
|
|
714
|
+
message: string;
|
|
715
|
+
} | undefined;
|
|
666
716
|
export declare function toGitHubSearchStateQualifier(include: IssueOrPullRequestState[] | undefined): string;
|
|
667
717
|
export declare function filterPullRequestsBySearchState<T extends {
|
|
668
718
|
state: IssueOrPullRequestState;
|