@gitkraken/core-gitlens 0.8.0 → 0.9.1

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.
Files changed (87) hide show
  1. package/CHANGELOG.md +43 -1
  2. package/dist/git/cache.d.ts +11 -0
  3. package/dist/git/cache.js +26 -3
  4. package/dist/git/cache.js.map +1 -1
  5. package/dist/git/context.d.ts +3 -2
  6. package/dist/git/context.js.map +1 -1
  7. package/dist/git/features.d.ts +1 -1
  8. package/dist/git/features.js +1 -0
  9. package/dist/git/features.js.map +1 -1
  10. package/dist/git/models/reflog.d.ts +6 -0
  11. package/dist/git/models/reflog.js.map +1 -1
  12. package/dist/git/models/revision.d.ts +0 -1
  13. package/dist/git/models/revision.js +1 -2
  14. package/dist/git/models/revision.js.map +1 -1
  15. package/dist/git/providers/commits.d.ts +20 -1
  16. package/dist/git/providers/operations.d.ts +13 -0
  17. package/dist/git/providers/provider.d.ts +14 -4
  18. package/dist/git/providers/refs.d.ts +10 -0
  19. package/dist/git/providers/revision.d.ts +2 -0
  20. package/dist/git/providers/staging.d.ts +2 -1
  21. package/dist/git/providers/stash.d.ts +3 -2
  22. package/dist/git/providers/status.d.ts +4 -0
  23. package/dist/git/run.types.d.ts +16 -0
  24. package/dist/git-cli/cliGitProvider.d.ts +24 -3
  25. package/dist/git-cli/cliGitProvider.js +79 -17
  26. package/dist/git-cli/cliGitProvider.js.map +1 -1
  27. package/dist/git-cli/exec/commandClassifier.d.ts +31 -0
  28. package/dist/git-cli/exec/commandClassifier.js +391 -0
  29. package/dist/git-cli/exec/commandClassifier.js.map +1 -0
  30. package/dist/git-cli/exec/git.d.ts +24 -3
  31. package/dist/git-cli/exec/git.js +116 -12
  32. package/dist/git-cli/exec/git.js.map +1 -1
  33. package/dist/git-cli/parsers/reflogParser.d.ts +7 -0
  34. package/dist/git-cli/parsers/reflogParser.js +11 -1
  35. package/dist/git-cli/parsers/reflogParser.js.map +1 -1
  36. package/dist/git-cli/providers/branches.js +16 -14
  37. package/dist/git-cli/providers/branches.js.map +1 -1
  38. package/dist/git-cli/providers/commits.d.ts +4 -2
  39. package/dist/git-cli/providers/commits.js +55 -4
  40. package/dist/git-cli/providers/commits.js.map +1 -1
  41. package/dist/git-cli/providers/diff.js +4 -4
  42. package/dist/git-cli/providers/diff.js.map +1 -1
  43. package/dist/git-cli/providers/operations.d.ts +12 -0
  44. package/dist/git-cli/providers/operations.js +26 -3
  45. package/dist/git-cli/providers/operations.js.map +1 -1
  46. package/dist/git-cli/providers/patch.js +2 -5
  47. package/dist/git-cli/providers/patch.js.map +1 -1
  48. package/dist/git-cli/providers/refs.d.ts +5 -0
  49. package/dist/git-cli/providers/refs.js +26 -1
  50. package/dist/git-cli/providers/refs.js.map +1 -1
  51. package/dist/git-cli/providers/remotes.js +3 -2
  52. package/dist/git-cli/providers/remotes.js.map +1 -1
  53. package/dist/git-cli/providers/revision.d.ts +2 -0
  54. package/dist/git-cli/providers/revision.js +11 -0
  55. package/dist/git-cli/providers/revision.js.map +1 -1
  56. package/dist/git-cli/providers/staging.d.ts +2 -1
  57. package/dist/git-cli/providers/staging.js +12 -7
  58. package/dist/git-cli/providers/staging.js.map +1 -1
  59. package/dist/git-cli/providers/stash.d.ts +3 -2
  60. package/dist/git-cli/providers/stash.js +34 -22
  61. package/dist/git-cli/providers/stash.js.map +1 -1
  62. package/dist/git-cli/providers/status.d.ts +2 -0
  63. package/dist/git-cli/providers/status.js +27 -9
  64. package/dist/git-cli/providers/status.js.map +1 -1
  65. package/dist/plus/git-github/api/github.d.ts +13 -0
  66. package/dist/plus/git-github/api/github.js +36 -6
  67. package/dist/plus/git-github/api/github.js.map +1 -1
  68. package/dist/plus/git-github/providers/github/commits.d.ts +4 -2
  69. package/dist/plus/git-github/providers/github/commits.js +3 -1
  70. package/dist/plus/git-github/providers/github/commits.js.map +1 -1
  71. package/dist/plus/git-github/providers/github/revision.d.ts +1 -0
  72. package/dist/plus/git-github/providers/github/revision.js +5 -0
  73. package/dist/plus/git-github/providers/github/revision.js.map +1 -1
  74. package/dist/plus/integrations/collectionMetadata.d.ts +6 -0
  75. package/dist/plus/integrations/collectionMetadata.js +7 -4
  76. package/dist/plus/integrations/collectionMetadata.js.map +1 -1
  77. package/dist/plus/integrations/models/gitHostIntegration.d.ts +13 -0
  78. package/dist/plus/integrations/models/gitHostIntegration.js +19 -0
  79. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  80. package/dist/plus/integrations/providers/github.d.ts +16 -1
  81. package/dist/plus/integrations/providers/github.js +39 -1
  82. package/dist/plus/integrations/providers/github.js.map +1 -1
  83. package/dist/plus/integrations/reads/resolveRepository.js +26 -5
  84. package/dist/plus/integrations/reads/resolveRepository.js.map +1 -1
  85. package/docs/integrations.md +22 -5
  86. package/docs/kepler-git-write-api-parity.md +140 -14
  87. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"cliGitProvider.js","names":["fs"],"sources":["../../../git-cli/src/cliGitProvider.ts"],"sourcesContent":["import { promises as fs } from 'node:fs';\nimport * as path from 'node:path';\nimport type { CachedGitTypes } from '@gitlens/git/cache.js';\nimport { Cache } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport type { GitFileStatus } from '@gitlens/git/models/fileStatus.js';\nimport type { RepositoryChange } from '@gitlens/git/models/repository.js';\nimport { deletedOrMissing } from '@gitlens/git/models/revision.js';\nimport type { GitProvider, GitProviderDescriptor } from '@gitlens/git/providers/provider.js';\nimport { parseGitRemoteUrl } from '@gitlens/git/utils/remote.utils.js';\nimport { isUncommitted } from '@gitlens/git/utils/revision.utils.js';\nimport { GitIgnoreFilter } from '@gitlens/git/watching/gitIgnoreFilter.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { joinPaths, maybeUri, normalizePath, splitPath } from '@gitlens/utils/path.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\nimport { fileUri, joinUriPath, parseUri, toFsPath } from '@gitlens/utils/uri.js';\nimport { fsExists } from './exec/exec.js';\nimport type { FilteredGitFeatures, GitFeatureOrPrefix, GitFeatures } from './exec/features.js';\nimport type { GitFeatureUnsupportedMessage, GitOptions } from './exec/git.js';\nimport { Git } from './exec/git.js';\nimport type { GitLocation } from './exec/locator.js';\nimport { BlameGitSubProvider } from './providers/blame.js';\nimport { BranchesGitSubProvider } from './providers/branches.js';\nimport { CommitsGitSubProvider } from './providers/commits.js';\nimport { ConfigGitSubProvider } from './providers/config.js';\nimport { ContributorsGitSubProvider } from './providers/contributors.js';\nimport { DiffGitSubProvider } from './providers/diff.js';\nimport { GraphGitSubProvider } from './providers/graph.js';\nimport { MaintenanceGitSubProvider } from './providers/maintenance.js';\nimport { OperationsGitSubProvider } from './providers/operations.js';\nimport { PatchGitSubProvider } from './providers/patch.js';\nimport { PausedOperationsGitSubProvider } from './providers/pausedOperations.js';\nimport { RefsGitSubProvider } from './providers/refs.js';\nimport { RemotesGitSubProvider } from './providers/remotes.js';\nimport { RevisionGitSubProvider } from './providers/revision.js';\nimport { StagingGitSubProvider } from './providers/staging.js';\nimport { StashGitSubProvider } from './providers/stash.js';\nimport { StatusGitSubProvider } from './providers/status.js';\nimport { TagsGitSubProvider } from './providers/tags.js';\nimport { WorktreesGitSubProvider } from './providers/worktrees.js';\n\nexport interface CliGitProviderOptions {\n\t/** Use an existing Cache instance, or one will be created */\n\tcache?: Cache;\n\t/** Context providing config and event bus hooks */\n\tcontext: GitServiceContext;\n\t/** Function that resolves the git binary location (path + version) */\n\tlocator: () => Promise<GitLocation>;\n\t/** Pre-built Git executor — when provided, used instead of creating a new Git from locator/options */\n\tgit?: Git;\n\t/** Git execution options (timeout, trust, queue config, hooks, etc.) */\n\tgitOptions?: GitOptions;\n\t/**\n\t * Whether repositories reached through this provider are on the LOCAL filesystem. `false` disables the\n\t * maintenance sub-provider entirely (Live Share): its probes stat local paths, and its writes are\n\t * rejected by the host's command allowlist, so inheriting it yields empty reports and swallowed\n\t * failures rather than an honest \"unsupported here\". Defaults to `true`.\n\t */\n\tlocalRepositories?: boolean;\n}\n\n/**\n * Exposes `isTrackedWithDetails` as a callable method for sub-providers.\n * The class declares it as a regular method, but TypeScript's structural\n * typing makes it inaccessible through the class type alone when consumed\n * internally — this type re-maps it to ensure sub-providers can call it.\n */\nexport type CliGitProviderInternal = Omit<CliGitProvider, 'isTrackedWithDetails'> & {\n\tisTrackedWithDetails: CliGitProvider['isTrackedWithDetails'];\n};\n\n/**\n * A fully-wired CLI-based git provider that executes git commands via `child_process`.\n * Implements both `CliGitProviderInternal` (for internal sub-provider wiring)\n * and `GitProvider` (for registration in a provider registry).\n *\n * @example\n * ```typescript\n * const provider = new CliGitProvider({\n * context: { events: myEvents },\n * locator: () => findGitPath(null),\n * gitOptions: { gitTimeout: 30000 },\n * });\n *\n * const branches = await provider.branches.getBranches(repoPath);\n * const status = await provider.status.getStatus(repoPath);\n * ```\n */\nexport class CliGitProvider implements GitProvider {\n\treadonly descriptor: GitProviderDescriptor = { id: 'git', name: 'Git', virtual: false };\n\n\tprivate readonly _cache: Cache;\n\tprivate readonly _cacheOwned: boolean;\n\tprivate readonly _git: Git;\n\n\treadonly context: GitServiceContext;\n\tprivate readonly _localRepositories: boolean;\n\n\tconstructor(options: CliGitProviderOptions) {\n\t\t// Every typed write announces itself through `onReset`, so the provider clears its own state there\n\t\t// rather than trusting each host to: a host with no handler still reads fresh after a write. A write\n\t\t// hard-evicts, so a caller after it never joins a read that started before it; watcher-driven clears\n\t\t// reach `Cache.clearCaches` directly and keep sharing in-flight reads.\n\t\tconst hostHooks = options.context.hooks;\n\t\tthis.context = {\n\t\t\t...options.context,\n\t\t\thooks: {\n\t\t\t\t...hostHooks,\n\t\t\t\tcache: {\n\t\t\t\t\t...hostHooks?.cache,\n\t\t\t\t\tonReset: (repoPath, ...types) => {\n\t\t\t\t\t\tthis._cache.evictCaches(repoPath, ...types);\n\t\t\t\t\t\tthis._git.clearPendingCommands();\n\t\t\t\t\t\thostHooks?.cache?.onReset?.(repoPath, ...types);\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t\tthis._localRepositories = options.localRepositories ?? true;\n\t\tthis._git =\n\t\t\toptions.git ??\n\t\t\tnew Git(options.locator, {\n\t\t\t\t...options.gitOptions,\n\t\t\t\tisTrusted:\n\t\t\t\t\toptions.context.workspace?.isTrusted != null\n\t\t\t\t\t\t? () => options.context.workspace!.isTrusted!\n\t\t\t\t\t\t: undefined,\n\t\t\t});\n\t\tthis._cacheOwned = !(options.cache instanceof Cache);\n\t\tthis._cache = options.cache instanceof Cache ? options.cache : new Cache();\n\t}\n\n\t/** The underlying cache instance (for repo path registration, etc.) */\n\tget cache(): Cache {\n\t\treturn this._cache;\n\t}\n\n\t/** The underlying git execution instance (for sub-providers that need direct exec/stream access) */\n\tget git(): Git {\n\t\treturn this._git;\n\t}\n\n\t/** Returns whether the installed git version supports the given feature. */\n\tsupports(feature: GitFeatures): boolean | Promise<boolean> {\n\t\treturn this._git.supports(feature);\n\t}\n\n\t/** Returns all features matching the prefix that the installed git version supports. */\n\tsupported<T extends GitFeatureOrPrefix>(feature: T): FilteredGitFeatures<T>[] | Promise<FilteredGitFeatures<T>[]> {\n\t\treturn this._git.supported(feature);\n\t}\n\n\t/** Throws if the installed git version does not support the given feature. */\n\tasync ensureSupports(feature: GitFeatures, prefix: string, suffix: string): Promise<void>;\n\tasync ensureSupports(feature: GitFeatures, message: GitFeatureUnsupportedMessage): Promise<void>;\n\tasync ensureSupports(\n\t\tfeature: GitFeatures,\n\t\tprefixOrMessage: string | GitFeatureUnsupportedMessage,\n\t\tsuffix?: string,\n\t): Promise<void> {\n\t\treturn typeof prefixOrMessage === 'function'\n\t\t\t? this._git.ensureSupports(feature, prefixOrMessage)\n\t\t\t: this._git.ensureSupports(feature, prefixOrMessage, suffix!);\n\t}\n\n\t/** Returns the installed git version string. */\n\tasync version(): Promise<string> {\n\t\treturn this._git.version();\n\t}\n\n\t/** Returns the resolved git binary path. */\n\tasync path(): Promise<string> {\n\t\treturn this._git.path();\n\t}\n\n\tasync clone(url: string, parentPath: string): Promise<string | undefined> {\n\t\tlet count = 0;\n\t\tconst [, , remotePath] = parseGitRemoteUrl(url);\n\t\tconst remoteName = remotePath.split('/').pop();\n\t\tif (!remoteName) return undefined;\n\n\t\tlet folderPath = joinPaths(parentPath, remoteName);\n\t\twhile ((await fsExists(folderPath)) && count < 20) {\n\t\t\tcount++;\n\t\t\tfolderPath = joinPaths(parentPath, `${remoteName}-${count}`);\n\t\t}\n\n\t\tawait this._git.run({ cwd: parentPath }, 'clone', url, folderPath);\n\n\t\treturn folderPath;\n\t}\n\n\t/** Creates a new repository at `targetPath` (`git init`), creating it first if it doesn't yet exist. */\n\tasync init(targetPath: string, options?: { defaultBranch?: string; bare?: boolean }): Promise<void> {\n\t\tawait fs.mkdir(targetPath, { recursive: true });\n\n\t\tconst args = ['init'];\n\t\tif (options?.defaultBranch) {\n\t\t\targs.push('-b', options.defaultBranch);\n\t\t}\n\t\tif (options?.bare) {\n\t\t\targs.push('--bare');\n\t\t}\n\n\t\t// Run inside the target rather than naming it from its parent: a relative `targetPath` would otherwise\n\t\t// be resolved against the parent a second time\n\t\tawait this._git.run({ cwd: targetPath }, ...args);\n\t}\n\n\t/**\n\t * Notifies the provider that `repoPath` was mutated outside of a typed sub-provider method — e.g. a\n\t * consumer that ran a command through the raw `git.run`/`provider.git.run` escape hatch. Fires the same\n\t * `cache.onReset`/`repository.onChanged` hooks a typed mutator would, so, exactly as after a typed write,\n\t * the provider clears its own caches for `repoPath` (every type, or just `options.cache` when given) and\n\t * its pending commands before the host's handlers run.\n\t */\n\tnotifyChanged(\n\t\trepoPath: string,\n\t\tchanges: readonly RepositoryChange[],\n\t\toptions?: { cache?: readonly CachedGitTypes[] | 'all' },\n\t): void {\n\t\tconst types = options?.cache;\n\t\tif (types == null || types === 'all') {\n\t\t\t// No types = everything, for the provider's own clear and the host's handler alike.\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath);\n\t\t} else if (types.length) {\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, ...types);\n\t\t}\n\n\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, [...changes]);\n\t}\n\n\tprivate _blame: BlameGitSubProvider | undefined;\n\tget blame(): BlameGitSubProvider {\n\t\treturn (this._blame ??= new BlameGitSubProvider(\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _branches: BranchesGitSubProvider | undefined;\n\tget branches(): BranchesGitSubProvider {\n\t\treturn (this._branches ??= new BranchesGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _commits: CommitsGitSubProvider | undefined;\n\tget commits(): CommitsGitSubProvider {\n\t\treturn (this._commits ??= new CommitsGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _config: ConfigGitSubProvider | undefined;\n\tget config(): ConfigGitSubProvider {\n\t\treturn (this._config ??= new ConfigGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _contributors: ContributorsGitSubProvider | undefined;\n\tget contributors(): ContributorsGitSubProvider {\n\t\treturn (this._contributors ??= new ContributorsGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _diff: DiffGitSubProvider | undefined;\n\tget diff(): DiffGitSubProvider {\n\t\treturn (this._diff ??= new DiffGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _graph: GraphGitSubProvider | undefined;\n\tget graph(): GraphGitSubProvider {\n\t\treturn (this._graph ??= new GraphGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _maintenance: MaintenanceGitSubProvider | undefined;\n\t// Optional so subclasses whose repos aren't local can report the capability as absent — see\n\t// `VslsGitProvider`. Consumers already treat `maintenance == null` as \"unsupported here\" (web builds\n\t// never register it at all).\n\tget maintenance(): MaintenanceGitSubProvider | undefined {\n\t\tif (!this._localRepositories) return undefined;\n\n\t\treturn (this._maintenance ??= new MaintenanceGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _ops: OperationsGitSubProvider | undefined;\n\tget ops(): OperationsGitSubProvider {\n\t\treturn (this._ops ??= new OperationsGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _patch: PatchGitSubProvider | undefined;\n\tget patch(): PatchGitSubProvider {\n\t\treturn (this._patch ??= new PatchGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _pausedOps: PausedOperationsGitSubProvider | undefined;\n\tget pausedOps(): PausedOperationsGitSubProvider {\n\t\treturn (this._pausedOps ??= new PausedOperationsGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _refs: RefsGitSubProvider | undefined;\n\tget refs(): RefsGitSubProvider {\n\t\treturn (this._refs ??= new RefsGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _remotes: RemotesGitSubProvider | undefined;\n\tget remotes(): RemotesGitSubProvider {\n\t\treturn (this._remotes ??= new RemotesGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _revision: RevisionGitSubProvider | undefined;\n\tget revision(): RevisionGitSubProvider {\n\t\treturn (this._revision ??= new RevisionGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _staging: StagingGitSubProvider | undefined;\n\tget staging(): StagingGitSubProvider {\n\t\treturn (this._staging ??= new StagingGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _stash: StashGitSubProvider | undefined;\n\tget stash(): StashGitSubProvider {\n\t\treturn (this._stash ??= new StashGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _status: StatusGitSubProvider | undefined;\n\tget status(): StatusGitSubProvider {\n\t\treturn (this._status ??= new StatusGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _tags: TagsGitSubProvider | undefined;\n\tget tags(): TagsGitSubProvider {\n\t\treturn (this._tags ??= new TagsGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _worktrees: WorktreesGitSubProvider | undefined;\n\tget worktrees(): WorktreesGitSubProvider {\n\t\treturn (this._worktrees ??= new WorktreesGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tgetAbsoluteUri(pathOrUri: string | Uri, base: string | Uri): Uri {\n\t\tconst baseUri = typeof base !== 'string' ? base : fileUri(base);\n\t\tif (typeof pathOrUri !== 'string') return pathOrUri;\n\t\tif (maybeUri(pathOrUri)) return parseUri(pathOrUri);\n\t\tif (path.isAbsolute(pathOrUri)) return fileUri(pathOrUri);\n\t\treturn joinUriPath(baseUri, pathOrUri);\n\t}\n\n\tgetRelativePath(pathOrUri: string | Uri, base: string | Uri): string {\n\t\tconst [relativePath] = splitPath(toFsPath(pathOrUri), toFsPath(base));\n\t\treturn relativePath;\n\t}\n\n\tasync excludeIgnoredUris(repoPath: string, uris: Uri[]): Promise<Uri[]> {\n\t\tconst filter = this.getIgnoreFilter(repoPath);\n\t\tawait filter.ready();\n\t\treturn uris.filter(uri => {\n\t\t\tconst relativePath = normalizePath(path.relative(repoPath, toFsPath(uri)));\n\t\t\treturn !relativePath || !filter.isIgnored(relativePath);\n\t\t});\n\t}\n\n\tasync getIgnoredUrisFilter(repoPath: string): Promise<(uri: Uri) => boolean> {\n\t\tconst filter = this.getIgnoreFilter(repoPath);\n\t\tawait filter.ready();\n\t\treturn (uri: Uri) => {\n\t\t\tconst relativePath = normalizePath(path.relative(repoPath, toFsPath(uri)));\n\t\t\treturn relativePath ? filter.isIgnored(relativePath) : false;\n\t\t};\n\t}\n\n\tasync getLastFetchedTimestamp(repoPath: string): Promise<number | undefined> {\n\t\treturn this._cache.getLastFetchedTimestamp(repoPath, async (commonPath): Promise<number | undefined> => {\n\t\t\tconst gitDir = await this.config.getGitDir?.(commonPath);\n\t\t\tif (gitDir == null) return undefined;\n\n\t\t\tconst gitDirUri = gitDir.commonUri ?? gitDir.uri;\n\t\t\tconst fetchHeadUri = joinUriPath(gitDirUri, 'FETCH_HEAD');\n\t\t\tconst stats = await this.context.fs.stat(fetchHeadUri);\n\t\t\t// If the file is empty, assume the fetch failed, and don't update the timestamp\n\t\t\tif (stats != null && stats.size > 0) return stats.mtime;\n\n\t\t\treturn undefined;\n\t\t});\n\t}\n\n\tgetIgnoreFilter(repoPath: string): GitIgnoreFilter {\n\t\tlet filter = this._cache.gitIgnore.get(repoPath);\n\t\tif (filter == null) {\n\t\t\tconst gitDir = this._cache.gitDir.get(repoPath);\n\t\t\tconst gitDirPath = gitDir?.uri.fsPath ?? `${repoPath}/.git`;\n\t\t\tfilter = new GitIgnoreFilter({\n\t\t\t\trepoPath: repoPath,\n\t\t\t\tgitDirPath: gitDirPath,\n\t\t\t\tfs: this.context.fs,\n\t\t\t\tgetGlobalExcludesPath:\n\t\t\t\t\tthis.config.getConfig != null\n\t\t\t\t\t\t? async () => this.config.getConfig(repoPath, 'core.excludesFile')\n\t\t\t\t\t\t: undefined,\n\t\t\t});\n\t\t\tthis._cache.gitIgnore.set(repoPath, filter);\n\t\t}\n\t\treturn filter;\n\t}\n\n\tprivate async isTrackedWithDetails(\n\t\tfilePath: string,\n\t\trepoPath: string,\n\t\trev?: string,\n\t): Promise<{ path: string; status?: GitFileStatus; originalPath?: string } | undefined> {\n\t\tif (rev === deletedOrMissing) return undefined;\n\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst [relativePath, root] = splitPath(filePath, repoPath);\n\n\t\t\t// Check if the file exists in the working tree first (better cache reuse)\n\t\t\tlet tracked = await this.revision.exists(root, relativePath);\n\t\t\tif (tracked) return { path: relativePath };\n\n\t\t\t// If a specific revision was provided, check there too\n\t\t\tif (rev && !isUncommitted(rev)) {\n\t\t\t\ttracked = await this.revision.exists(root, relativePath, rev);\n\t\t\t\tif (!tracked) {\n\t\t\t\t\t// Check the parent revision (file might have been deleted in this rev)\n\t\t\t\t\ttracked = await this.revision.exists(root, relativePath, `${rev}^`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn tracked ? { path: relativePath } : undefined;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tdispose(): void {\n\t\tthis._git.dispose();\n\t\tif (this._cacheOwned) {\n\t\t\tthis._cache.dispose();\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwFA,IAAa,iBAAb,MAAmD;CAClD,aAA6C;EAAE,IAAI;EAAO,MAAM;EAAO,SAAS;CAAM;CAEtF;CACA;CACA;CAEA;CACA;CAEA,YAAY,SAAgC;EAK3C,MAAM,YAAY,QAAQ,QAAQ;EAClC,KAAK,UAAU;GACd,GAAG,QAAQ;GACX,OAAO;IACN,GAAG;IACH,OAAO;KACN,GAAG,WAAW;KACd,UAAU,UAAU,GAAG,UAAU;MAChC,KAAK,OAAO,YAAY,UAAU,GAAG,KAAK;MAC1C,KAAK,KAAK,qBAAqB;MAC/B,WAAW,OAAO,UAAU,UAAU,GAAG,KAAK;KAC/C;IACD;GACD;EACD;EACA,KAAK,qBAAqB,QAAQ,qBAAqB;EACvD,KAAK,OACJ,QAAQ,OACR,IAAI,IAAI,QAAQ,SAAS;GACxB,GAAG,QAAQ;GACX,WACC,QAAQ,QAAQ,WAAW,aAAa,aAC/B,QAAQ,QAAQ,UAAW,YACjC,KAAA;EACL,CAAC;EACF,KAAK,cAAc,EAAE,QAAQ,iBAAiB;EAC9C,KAAK,SAAS,QAAQ,iBAAiB,QAAQ,QAAQ,QAAQ,IAAI,MAAM;CAC1E;;CAGA,IAAI,QAAe;EAClB,OAAO,KAAK;CACb;;CAGA,IAAI,MAAW;EACd,OAAO,KAAK;CACb;;CAGA,SAAS,SAAkD;EAC1D,OAAO,KAAK,KAAK,SAAS,OAAO;CAClC;;CAGA,UAAwC,SAA0E;EACjH,OAAO,KAAK,KAAK,UAAU,OAAO;CACnC;CAKA,MAAM,eACL,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,OAAO;CACR;CAEA,MAAc,qBACb,UACA,UACA,KACuF;EACvF,IAAI,QAAA,6CAA0B,OAAO,KAAA;EAErC,MAAM,QAAQ,gBAAgB;EAE9B,IAAI;GACH,MAAM,CAAC,cAAc,QAAQ,UAAU,UAAU,QAAQ;GAGzD,IAAI,UAAU,MAAM,KAAK,SAAS,OAAO,MAAM,YAAY;GAC3D,IAAI,SAAS,OAAO,EAAE,MAAM,aAAa;GAGzC,IAAI,OAAO,CAAC,cAAc,GAAG,GAAG;IAC/B,UAAU,MAAM,KAAK,SAAS,OAAO,MAAM,cAAc,GAAG;IAC5D,IAAI,CAAC,SAEJ,UAAU,MAAM,KAAK,SAAS,OAAO,MAAM,cAAc,GAAG,IAAI,EAAE;GAEpE;GAEA,OAAO,UAAU,EAAE,MAAM,aAAa,IAAI,KAAA;EAC3C,SAAS,IAAI;GACZ,OAAO,MAAM,EAAE;GACf;EACD;CACD;CAEA,UAAgB;EACf,KAAK,KAAK,QAAQ;EAClB,IAAI,KAAK,aACR,KAAK,OAAO,QAAQ;CAEtB;AACD"}
1
+ {"version":3,"file":"cliGitProvider.js","names":["fs"],"sources":["../../../git-cli/src/cliGitProvider.ts"],"sourcesContent":["import { promises as fs } from 'node:fs';\nimport * as path from 'node:path';\nimport type { CachedGitTypes } from '@gitlens/git/cache.js';\nimport { Cache } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport type { GitFileStatus } from '@gitlens/git/models/fileStatus.js';\nimport type { RepositoryChange } from '@gitlens/git/models/repository.js';\nimport { deletedOrMissing } from '@gitlens/git/models/revision.js';\nimport type { GitOperationRunOptions } from '@gitlens/git/providers/operations.js';\nimport type { GitProvider, GitProviderDescriptor } from '@gitlens/git/providers/provider.js';\nimport { parseGitRemoteUrl } from '@gitlens/git/utils/remote.utils.js';\nimport { isUncommitted } from '@gitlens/git/utils/revision.utils.js';\nimport { GitIgnoreFilter } from '@gitlens/git/watching/gitIgnoreFilter.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { joinPaths, maybeUri, normalizePath, splitPath } from '@gitlens/utils/path.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\nimport { fileUri, joinUriPath, parseUri, toFsPath } from '@gitlens/utils/uri.js';\nimport { fsExists } from './exec/exec.js';\nimport type { FilteredGitFeatures, GitFeatureOrPrefix, GitFeatures } from './exec/features.js';\nimport type { GitFeatureUnsupportedMessage, GitOptions } from './exec/git.js';\nimport { Git } from './exec/git.js';\nimport type { GitLocation } from './exec/locator.js';\nimport { BlameGitSubProvider } from './providers/blame.js';\nimport { BranchesGitSubProvider } from './providers/branches.js';\nimport { CommitsGitSubProvider } from './providers/commits.js';\nimport { ConfigGitSubProvider } from './providers/config.js';\nimport { ContributorsGitSubProvider } from './providers/contributors.js';\nimport { DiffGitSubProvider } from './providers/diff.js';\nimport { GraphGitSubProvider } from './providers/graph.js';\nimport { MaintenanceGitSubProvider } from './providers/maintenance.js';\nimport { OperationsGitSubProvider } from './providers/operations.js';\nimport { PatchGitSubProvider } from './providers/patch.js';\nimport { PausedOperationsGitSubProvider } from './providers/pausedOperations.js';\nimport { RefsGitSubProvider } from './providers/refs.js';\nimport { RemotesGitSubProvider } from './providers/remotes.js';\nimport { RevisionGitSubProvider } from './providers/revision.js';\nimport { StagingGitSubProvider } from './providers/staging.js';\nimport { StashGitSubProvider } from './providers/stash.js';\nimport { StatusGitSubProvider } from './providers/status.js';\nimport { TagsGitSubProvider } from './providers/tags.js';\nimport { WorktreesGitSubProvider } from './providers/worktrees.js';\n\nexport interface CliGitProviderOptions {\n\t/** Use an existing Cache instance, or one will be created */\n\tcache?: Cache;\n\t/** Context providing config and event bus hooks */\n\tcontext: GitServiceContext;\n\t/** Function that resolves the git binary location (path + version) */\n\tlocator: () => Promise<GitLocation>;\n\t/** Pre-built Git executor — when provided, used instead of creating a new Git from locator/options */\n\tgit?: Git;\n\t/** Git execution options (timeout, trust, queue config, hooks, etc.) */\n\tgitOptions?: GitOptions;\n\t/**\n\t * Whether repositories reached through this provider are on the LOCAL filesystem. `false` disables the\n\t * maintenance sub-provider entirely (Live Share): its probes stat local paths, and its writes are\n\t * rejected by the host's command allowlist, so inheriting it yields empty reports and swallowed\n\t * failures rather than an honest \"unsupported here\". Defaults to `true`.\n\t */\n\tlocalRepositories?: boolean;\n}\n\n/**\n * Exposes `isTrackedWithDetails` as a callable method for sub-providers.\n * The class declares it as a regular method, but TypeScript's structural\n * typing makes it inaccessible through the class type alone when consumed\n * internally — this type re-maps it to ensure sub-providers can call it.\n */\nexport type CliGitProviderInternal = Omit<CliGitProvider, 'isTrackedWithDetails'> & {\n\tisTrackedWithDetails: CliGitProvider['isTrackedWithDetails'];\n};\n\n/**\n * A fully-wired CLI-based git provider that executes git commands via `child_process`.\n * Implements both `CliGitProviderInternal` (for internal sub-provider wiring)\n * and `GitProvider` (for registration in a provider registry).\n *\n * @example\n * ```typescript\n * const provider = new CliGitProvider({\n * context: { events: myEvents },\n * locator: () => findGitPath(null),\n * gitOptions: { gitTimeout: 30000 },\n * });\n *\n * const branches = await provider.branches.getBranches(repoPath);\n * const status = await provider.status.getStatus(repoPath);\n * ```\n */\nexport class CliGitProvider implements GitProvider {\n\treadonly descriptor: GitProviderDescriptor = { id: 'git', name: 'Git', virtual: false };\n\n\tprivate readonly _cache: Cache;\n\tprivate readonly _cacheOwned: boolean;\n\tprivate readonly _git: Git;\n\n\treadonly context: GitServiceContext;\n\t/** The host's own hooks, before the provider wraps `cache.onReset` with its own clearing */\n\tprivate readonly _hostHooks: GitServiceContext['hooks'];\n\tprivate readonly _localRepositories: boolean;\n\n\tconstructor(options: CliGitProviderOptions) {\n\t\t// Every typed write announces itself through `onReset`, so the provider clears its own state there\n\t\t// rather than trusting each host to: a host with no handler still reads fresh after a write. A write\n\t\t// hard-evicts, so a caller after it never joins a read that started before it; watcher-driven clears\n\t\t// reach `Cache.clearCaches` directly and keep sharing in-flight reads.\n\t\tconst hostHooks = options.context.hooks;\n\t\tthis._hostHooks = hostHooks;\n\t\tthis.context = {\n\t\t\t...options.context,\n\t\t\thooks: {\n\t\t\t\t...hostHooks,\n\t\t\t\tcache: {\n\t\t\t\t\t...hostHooks?.cache,\n\t\t\t\t\tonReset: (repoPath, ...types) => {\n\t\t\t\t\t\tthis._cache.evictCaches(repoPath, ...types);\n\t\t\t\t\t\tthis._git.clearPendingCommands(this.getRepositoryPaths(repoPath));\n\t\t\t\t\t\thostHooks?.cache?.onReset?.(repoPath, ...types);\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t\tthis._localRepositories = options.localRepositories ?? true;\n\t\tthis._git =\n\t\t\toptions.git ??\n\t\t\tnew Git(options.locator, {\n\t\t\t\t...options.gitOptions,\n\t\t\t\tisTrusted:\n\t\t\t\t\toptions.context.workspace?.isTrusted != null\n\t\t\t\t\t\t? () => options.context.workspace!.isTrusted!\n\t\t\t\t\t\t: undefined,\n\t\t\t});\n\t\tthis._cacheOwned = !(options.cache instanceof Cache);\n\t\tthis._cache = options.cache instanceof Cache ? options.cache : new Cache();\n\n\t\t// Wires a raw `git.run({ notify })` call back to this provider's own cache/host announcement —\n\t\t// unconditionally, so a host-supplied `options.git` gets bound exactly like one we construct here.\n\t\tthis._git.bindChangeNotifier((repoPaths, changes) => this.notifyChangedCore(repoPaths, changes));\n\t}\n\n\t/** The underlying cache instance (for repo path registration, etc.) */\n\tget cache(): Cache {\n\t\treturn this._cache;\n\t}\n\n\t/** The underlying git execution instance (for sub-providers that need direct exec/stream access) */\n\tget git(): Git {\n\t\treturn this._git;\n\t}\n\n\t/** Returns whether the installed git version supports the given feature. */\n\tsupports(feature: GitFeatures): boolean | Promise<boolean> {\n\t\treturn this._git.supports(feature);\n\t}\n\n\t/** Returns all features matching the prefix that the installed git version supports. */\n\tsupported<T extends GitFeatureOrPrefix>(feature: T): FilteredGitFeatures<T>[] | Promise<FilteredGitFeatures<T>[]> {\n\t\treturn this._git.supported(feature);\n\t}\n\n\t/** Throws if the installed git version does not support the given feature. */\n\tasync ensureSupports(feature: GitFeatures, prefix: string, suffix: string): Promise<void>;\n\tasync ensureSupports(feature: GitFeatures, message: GitFeatureUnsupportedMessage): Promise<void>;\n\tasync ensureSupports(\n\t\tfeature: GitFeatures,\n\t\tprefixOrMessage: string | GitFeatureUnsupportedMessage,\n\t\tsuffix?: string,\n\t): Promise<void> {\n\t\treturn typeof prefixOrMessage === 'function'\n\t\t\t? this._git.ensureSupports(feature, prefixOrMessage)\n\t\t\t: this._git.ensureSupports(feature, prefixOrMessage, suffix!);\n\t}\n\n\t/** Returns the installed git version string. */\n\tasync version(): Promise<string> {\n\t\treturn this._git.version();\n\t}\n\n\t/** Returns the resolved git binary path. */\n\tasync path(): Promise<string> {\n\t\treturn this._git.path();\n\t}\n\n\tasync clone(\n\t\turl: string,\n\t\tparentPath: string,\n\t\toptions?: { folderName?: string },\n\t\trunOptions?: GitOperationRunOptions,\n\t): Promise<string | undefined> {\n\t\tlet folderPath: string;\n\t\tif (options?.folderName) {\n\t\t\tfolderPath = joinPaths(parentPath, options.folderName);\n\t\t} else {\n\t\t\tconst [, , remotePath] = parseGitRemoteUrl(url);\n\t\t\tconst remoteName = remotePath.split('/').pop();\n\t\t\tif (!remoteName) return undefined;\n\n\t\t\tlet count = 0;\n\t\t\tfolderPath = joinPaths(parentPath, remoteName);\n\t\t\twhile ((await fsExists(folderPath)) && count < 20) {\n\t\t\t\tcount++;\n\t\t\t\tfolderPath = joinPaths(parentPath, `${remoteName}-${count}`);\n\t\t\t}\n\t\t}\n\n\t\t// `throw`: the default handler swallows `remoteConnectionError`, which would return a folder never cloned\n\t\tawait this._git.run({ cwd: parentPath, errors: 'throw', ...runOptions }, 'clone', url, folderPath);\n\n\t\treturn folderPath;\n\t}\n\n\t/** Creates a new repository at `targetPath` (`git init`), creating it first if it doesn't yet exist. */\n\tasync init(targetPath: string, options?: { defaultBranch?: string; bare?: boolean }): Promise<void> {\n\t\tawait fs.mkdir(targetPath, { recursive: true });\n\n\t\tconst args = ['init'];\n\t\tif (options?.defaultBranch) {\n\t\t\targs.push('-b', options.defaultBranch);\n\t\t}\n\t\tif (options?.bare) {\n\t\t\targs.push('--bare');\n\t\t}\n\n\t\t// Run inside the target rather than naming it from its parent: a relative `targetPath` would otherwise\n\t\t// be resolved against the parent a second time\n\t\tawait this._git.run({ cwd: targetPath }, ...args);\n\t}\n\n\t/**\n\t * Notifies the provider that `repoPath` was mutated outside of a typed sub-provider method — e.g. a\n\t * consumer that ran a command through the raw `git.run`/`provider.git.run` escape hatch. Fires the same\n\t * `cache.onReset`/`repository.onChanged` hooks a typed mutator would, so, exactly as after a typed write,\n\t * the provider hard-evicts its own caches for `repoPath` and drops its pending commands for the repository\n\t * (its sibling worktrees included) before the host's handlers run.\n\t *\n\t * What is reset: `options.cache` when given (`'all'` for everything, `[]` for nothing); otherwise the\n\t * cache types `changes` map to, the same mapping a file watcher's changes get, status clock included.\n\t * An empty `changes`, or one naming `'unknown'` or `'closed'`, resets everything. Changes that map to\n\t * no cache type (e.g. `'starred'`) reset nothing, and `onReset` doesn't fire; `onChanged` always fires.\n\t */\n\tnotifyChanged(\n\t\trepoPath: string,\n\t\tchanges: readonly RepositoryChange[],\n\t\toptions?: { cache?: readonly CachedGitTypes[] | 'all' },\n\t): void {\n\t\tthis.notifyChangedCore([repoPath], changes, options);\n\t}\n\n\t/**\n\t * {@link notifyChanged} for one change seen from several paths, e.g. a `-C` shared-state verb announced\n\t * for both its target and the caller's `cwd`. Each path's caches are reset and the host's `onReset` fires\n\t * for each, since a host may keep per-worktree state, but a repository's pending commands are dropped once\n\t * however many of its worktrees are named.\n\t */\n\tprivate notifyChangedCore(\n\t\trepoPaths: readonly string[],\n\t\tchanges: readonly RepositoryChange[],\n\t\toptions?: { cache?: readonly CachedGitTypes[] | 'all' },\n\t): void {\n\t\tconst resets: { repoPath: string; types: CachedGitTypes[] }[] = [];\n\t\tconst pendingPaths = new Set<string>();\n\t\tfor (const repoPath of repoPaths) {\n\t\t\tconst types = this.resetForChanges(repoPath, changes, options?.cache);\n\t\t\tif (types == null) {\n\t\t\t\t// A gk config change is reconciled outside the cache types, but its re-read must not join a pre-write run\n\t\t\t\tif (options?.cache == null && changes.includes('gkConfig')) {\n\t\t\t\t\tfor (const path of this.getRepositoryPaths(repoPath)) {\n\t\t\t\t\t\tpendingPaths.add(path);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tresets.push({ repoPath: repoPath, types: types });\n\t\t\tfor (const path of this.getRepositoryPaths(repoPath)) {\n\t\t\t\tpendingPaths.add(path);\n\t\t\t}\n\t\t}\n\n\t\tif (pendingPaths.size) {\n\t\t\tthis._git.clearPendingCommands([...pendingPaths]);\n\t\t}\n\t\tfor (const { repoPath, types } of resets) {\n\t\t\tthis._hostHooks?.cache?.onReset?.(repoPath, ...types);\n\t\t}\n\t\tfor (const repoPath of repoPaths) {\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, [...changes]);\n\t\t}\n\t}\n\n\t/** Evicts what a notified change reset for `repoPath`: the types reset (`[]` = all), or `undefined` for none. */\n\tprivate resetForChanges(\n\t\trepoPath: string,\n\t\tchanges: readonly RepositoryChange[],\n\t\tcache: readonly CachedGitTypes[] | 'all' | undefined,\n\t): CachedGitTypes[] | undefined {\n\t\tif (cache != null && cache !== 'all') {\n\t\t\tif (!cache.length) return undefined;\n\n\t\t\tthis._cache.evictCaches(repoPath, ...cache);\n\t\t\treturn [...cache];\n\t\t}\n\n\t\tif (cache === 'all' || !changes.length || changes.some(c => c === 'unknown' || c === 'closed')) {\n\t\t\tthis._cache.evictCaches(repoPath);\n\t\t\treturn [];\n\t\t}\n\n\t\tconst types = this._cache.applyRepositoryChanges(repoPath, changes, 'evict');\n\t\treturn types.length ? types : undefined;\n\t}\n\n\t/** `repoPath` and every worktree registered as sharing its repository, since a shared-ref write moves them all. */\n\tprivate getRepositoryPaths(repoPath: string): string[] {\n\t\tconst commonPath = this._cache.getCommonPath(repoPath);\n\t\treturn [...new Set([repoPath, commonPath, ...this._cache.getWorktreePaths(commonPath)])];\n\t}\n\n\tprivate _blame: BlameGitSubProvider | undefined;\n\tget blame(): BlameGitSubProvider {\n\t\treturn (this._blame ??= new BlameGitSubProvider(\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _branches: BranchesGitSubProvider | undefined;\n\tget branches(): BranchesGitSubProvider {\n\t\treturn (this._branches ??= new BranchesGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _commits: CommitsGitSubProvider | undefined;\n\tget commits(): CommitsGitSubProvider {\n\t\treturn (this._commits ??= new CommitsGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _config: ConfigGitSubProvider | undefined;\n\tget config(): ConfigGitSubProvider {\n\t\treturn (this._config ??= new ConfigGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _contributors: ContributorsGitSubProvider | undefined;\n\tget contributors(): ContributorsGitSubProvider {\n\t\treturn (this._contributors ??= new ContributorsGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _diff: DiffGitSubProvider | undefined;\n\tget diff(): DiffGitSubProvider {\n\t\treturn (this._diff ??= new DiffGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _graph: GraphGitSubProvider | undefined;\n\tget graph(): GraphGitSubProvider {\n\t\treturn (this._graph ??= new GraphGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _maintenance: MaintenanceGitSubProvider | undefined;\n\t// Optional so subclasses whose repos aren't local can report the capability as absent — see\n\t// `VslsGitProvider`. Consumers already treat `maintenance == null` as \"unsupported here\" (web builds\n\t// never register it at all).\n\tget maintenance(): MaintenanceGitSubProvider | undefined {\n\t\tif (!this._localRepositories) return undefined;\n\n\t\treturn (this._maintenance ??= new MaintenanceGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _ops: OperationsGitSubProvider | undefined;\n\tget ops(): OperationsGitSubProvider {\n\t\treturn (this._ops ??= new OperationsGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _patch: PatchGitSubProvider | undefined;\n\tget patch(): PatchGitSubProvider {\n\t\treturn (this._patch ??= new PatchGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _pausedOps: PausedOperationsGitSubProvider | undefined;\n\tget pausedOps(): PausedOperationsGitSubProvider {\n\t\treturn (this._pausedOps ??= new PausedOperationsGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _refs: RefsGitSubProvider | undefined;\n\tget refs(): RefsGitSubProvider {\n\t\treturn (this._refs ??= new RefsGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _remotes: RemotesGitSubProvider | undefined;\n\tget remotes(): RemotesGitSubProvider {\n\t\treturn (this._remotes ??= new RemotesGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _revision: RevisionGitSubProvider | undefined;\n\tget revision(): RevisionGitSubProvider {\n\t\treturn (this._revision ??= new RevisionGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _staging: StagingGitSubProvider | undefined;\n\tget staging(): StagingGitSubProvider {\n\t\treturn (this._staging ??= new StagingGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _stash: StashGitSubProvider | undefined;\n\tget stash(): StashGitSubProvider {\n\t\treturn (this._stash ??= new StashGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _status: StatusGitSubProvider | undefined;\n\tget status(): StatusGitSubProvider {\n\t\treturn (this._status ??= new StatusGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _tags: TagsGitSubProvider | undefined;\n\tget tags(): TagsGitSubProvider {\n\t\treturn (this._tags ??= new TagsGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tprivate _worktrees: WorktreesGitSubProvider | undefined;\n\tget worktrees(): WorktreesGitSubProvider {\n\t\treturn (this._worktrees ??= new WorktreesGitSubProvider(\n\t\t\tthis.context,\n\t\t\tthis._git,\n\t\t\tthis._cache,\n\t\t\tthis as unknown as CliGitProviderInternal,\n\t\t));\n\t}\n\n\tgetAbsoluteUri(pathOrUri: string | Uri, base: string | Uri): Uri {\n\t\tconst baseUri = typeof base !== 'string' ? base : fileUri(base);\n\t\tif (typeof pathOrUri !== 'string') return pathOrUri;\n\t\tif (maybeUri(pathOrUri)) return parseUri(pathOrUri);\n\t\tif (path.isAbsolute(pathOrUri)) return fileUri(pathOrUri);\n\t\treturn joinUriPath(baseUri, pathOrUri);\n\t}\n\n\tgetRelativePath(pathOrUri: string | Uri, base: string | Uri): string {\n\t\tconst [relativePath] = splitPath(toFsPath(pathOrUri), toFsPath(base));\n\t\treturn relativePath;\n\t}\n\n\tasync excludeIgnoredUris(repoPath: string, uris: Uri[]): Promise<Uri[]> {\n\t\tconst filter = this.getIgnoreFilter(repoPath);\n\t\tawait filter.ready();\n\t\treturn uris.filter(uri => {\n\t\t\tconst relativePath = normalizePath(path.relative(repoPath, toFsPath(uri)));\n\t\t\treturn !relativePath || !filter.isIgnored(relativePath);\n\t\t});\n\t}\n\n\tasync getIgnoredUrisFilter(repoPath: string): Promise<(uri: Uri) => boolean> {\n\t\tconst filter = this.getIgnoreFilter(repoPath);\n\t\tawait filter.ready();\n\t\treturn (uri: Uri) => {\n\t\t\tconst relativePath = normalizePath(path.relative(repoPath, toFsPath(uri)));\n\t\t\treturn relativePath ? filter.isIgnored(relativePath) : false;\n\t\t};\n\t}\n\n\tasync getLastFetchedTimestamp(repoPath: string): Promise<number | undefined> {\n\t\treturn this._cache.getLastFetchedTimestamp(repoPath, async (commonPath): Promise<number | undefined> => {\n\t\t\tconst gitDir = await this.config.getGitDir?.(commonPath);\n\t\t\tif (gitDir == null) return undefined;\n\n\t\t\tconst gitDirUri = gitDir.commonUri ?? gitDir.uri;\n\t\t\tconst fetchHeadUri = joinUriPath(gitDirUri, 'FETCH_HEAD');\n\t\t\tconst stats = await this.context.fs.stat(fetchHeadUri);\n\t\t\t// If the file is empty, assume the fetch failed, and don't update the timestamp\n\t\t\tif (stats != null && stats.size > 0) return stats.mtime;\n\n\t\t\treturn undefined;\n\t\t});\n\t}\n\n\tgetIgnoreFilter(repoPath: string): GitIgnoreFilter {\n\t\tlet filter = this._cache.gitIgnore.get(repoPath);\n\t\tif (filter == null) {\n\t\t\tconst gitDir = this._cache.gitDir.get(repoPath);\n\t\t\tconst gitDirPath = gitDir?.uri.fsPath ?? `${repoPath}/.git`;\n\t\t\tfilter = new GitIgnoreFilter({\n\t\t\t\trepoPath: repoPath,\n\t\t\t\tgitDirPath: gitDirPath,\n\t\t\t\tfs: this.context.fs,\n\t\t\t\tgetGlobalExcludesPath:\n\t\t\t\t\tthis.config.getConfig != null\n\t\t\t\t\t\t? async () => this.config.getConfig(repoPath, 'core.excludesFile')\n\t\t\t\t\t\t: undefined,\n\t\t\t});\n\t\t\tthis._cache.gitIgnore.set(repoPath, filter);\n\t\t}\n\t\treturn filter;\n\t}\n\n\tprivate async isTrackedWithDetails(\n\t\tfilePath: string,\n\t\trepoPath: string,\n\t\trev?: string,\n\t): Promise<{ path: string; status?: GitFileStatus; originalPath?: string } | undefined> {\n\t\tif (rev === deletedOrMissing) return undefined;\n\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst [relativePath, root] = splitPath(filePath, repoPath);\n\n\t\t\t// Check if the file exists in the working tree first (better cache reuse)\n\t\t\tlet tracked = await this.revision.exists(root, relativePath);\n\t\t\tif (tracked) return { path: relativePath };\n\n\t\t\t// If a specific revision was provided, check there too\n\t\t\tif (rev && !isUncommitted(rev)) {\n\t\t\t\ttracked = await this.revision.exists(root, relativePath, rev);\n\t\t\t\tif (!tracked) {\n\t\t\t\t\t// Check the parent revision (file might have been deleted in this rev)\n\t\t\t\t\ttracked = await this.revision.exists(root, relativePath, `${rev}^`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn tracked ? { path: relativePath } : undefined;\n\t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,UAAU,mBAAmB,IAC/D,KAAA;GACL,CAAC;GACD,KAAK,OAAO,UAAU,IAAI,UAAU,MAAM;EAC3C;EACA,OAAO;CACR;CAEA,MAAc,qBACb,UACA,UACA,KACuF;EACvF,IAAI,QAAA,6CAA0B,OAAO,KAAA;EAErC,MAAM,QAAQ,gBAAgB;EAE9B,IAAI;GACH,MAAM,CAAC,cAAc,QAAQ,UAAU,UAAU,QAAQ;GAGzD,IAAI,UAAU,MAAM,KAAK,SAAS,OAAO,MAAM,YAAY;GAC3D,IAAI,SAAS,OAAO,EAAE,MAAM,aAAa;GAGzC,IAAI,OAAO,CAAC,cAAc,GAAG,GAAG;IAC/B,UAAU,MAAM,KAAK,SAAS,OAAO,MAAM,cAAc,GAAG;IAC5D,IAAI,CAAC,SAEJ,UAAU,MAAM,KAAK,SAAS,OAAO,MAAM,cAAc,GAAG,IAAI,EAAE;GAEpE;GAEA,OAAO,UAAU,EAAE,MAAM,aAAa,IAAI,KAAA;EAC3C,SAAS,IAAI;GACZ,OAAO,MAAM,EAAE;GACf;EACD;CACD;CAEA,UAAgB;EACf,KAAK,KAAK,QAAQ;EAClB,IAAI,KAAK,aACR,KAAK,OAAO,QAAQ;CAEtB;AACD"}
@@ -0,0 +1,31 @@
1
+ import { RepositoryChange } from "../../git/models/repository.js";
2
+ //#region ../git-cli/src/exec/commandClassifier.d.ts
3
+ export interface LeadingCommand {
4
+ verb: string;
5
+ readOnly: boolean;
6
+ /** The first token after the verb, unresolved — used for subcommand-shaped decisions (`worktree add`). */
7
+ subcommand?: string;
8
+ /** The `-C <path>` target when the caller re-scopes the command to another working tree. */
9
+ pathOverride?: string;
10
+ }
11
+ /**
12
+ * Skips the global options (`-c key=val`, `-C path`) git accepts before the verb to find it, and notes a
13
+ * `-C` re-scope so notification targets that tree.
14
+ */
15
+ export declare function leadingCommand(args: readonly string[]): LeadingCommand;
16
+ export interface CommandChanges {
17
+ changes: readonly RepositoryChange[];
18
+ /** The `-C <path>` target when the caller re-scoped the command to another working tree. */
19
+ pathOverride?: string;
20
+ /** The subset of {@link changes} every worktree sharing the same `.git` sees, not just the tree the command ran in. */
21
+ sharedChanges: readonly RepositoryChange[];
22
+ }
23
+ /**
24
+ * Classifies a raw git argv for the notification `git.run`'s `notify: 'infer'` applies after the run
25
+ * settles. Returns `undefined` for a read-only or object-only command — nothing to announce — otherwise
26
+ * the {@link RepositoryChange} kinds the verb announces, the `-C` re-scope target (if any), and which of
27
+ * those kinds every worktree sees.
28
+ */
29
+ export declare function getChangesForCommand(args: readonly string[]): CommandChanges | undefined;
30
+ //#endregion
31
+ //# sourceMappingURL=commandClassifier.d.ts.map
@@ -0,0 +1,391 @@
1
+ import { isAbsolute, join } from "node:path";
2
+ //#region ../git-cli/src/exec/commandClassifier.ts
3
+ /**
4
+ * Verbs that never move a ref, the index or the working tree, so a raw run needs no notification.
5
+ * Anything not listed is treated as a mutation: a needless notification costs a full cache eviction, a
6
+ * missed one serves stale state. Object-writing plumbing (`hash-object -w`, `mktree`, `commit-tree`,
7
+ * `write-tree`) is listed too: it only adds loose objects nothing cached observes.
8
+ */
9
+ const readOnlyVerbs = /* @__PURE__ */ new Set([
10
+ "annotate",
11
+ "archive",
12
+ "blame",
13
+ "cat-file",
14
+ "check-attr",
15
+ "check-ignore",
16
+ "check-mailmap",
17
+ "check-ref-format",
18
+ "cherry",
19
+ "commit-tree",
20
+ "count-objects",
21
+ "describe",
22
+ "diff",
23
+ "diff-files",
24
+ "diff-index",
25
+ "diff-tree",
26
+ "for-each-ref",
27
+ "fsck",
28
+ "grep",
29
+ "hash-object",
30
+ "help",
31
+ "log",
32
+ "ls-files",
33
+ "ls-remote",
34
+ "ls-tree",
35
+ "merge-base",
36
+ "merge-tree",
37
+ "mktree",
38
+ "name-rev",
39
+ "patch-id",
40
+ "range-diff",
41
+ "rev-list",
42
+ "rev-parse",
43
+ "shortlog",
44
+ "show",
45
+ "show-branch",
46
+ "show-ref",
47
+ "status",
48
+ "var",
49
+ "verify-commit",
50
+ "verify-pack",
51
+ "verify-tag",
52
+ "version",
53
+ "whatchanged",
54
+ "write-tree"
55
+ ]);
56
+ const reflogWriteSubcommands = /* @__PURE__ */ new Set([
57
+ "expire",
58
+ "delete",
59
+ "drop"
60
+ ]);
61
+ /**
62
+ * Sub-commands of otherwise-mutating verbs that only list. `''` is the bare verb, which lists for `branch`,
63
+ * `tag`, `remote` and `notes`; `branch -v` and every `tag` filter imply git's own list mode.
64
+ */
65
+ const readOnlySubcommands = {
66
+ branch: /* @__PURE__ */ new Set([
67
+ "",
68
+ "-l",
69
+ "--list",
70
+ "--show-current",
71
+ "-a",
72
+ "-r",
73
+ "-v",
74
+ "-vv",
75
+ "--verbose",
76
+ "--contains",
77
+ "--no-contains",
78
+ "--merged",
79
+ "--no-merged",
80
+ "--points-at"
81
+ ]),
82
+ config: /* @__PURE__ */ new Set(["get", "list"]),
83
+ notes: /* @__PURE__ */ new Set([
84
+ "",
85
+ "list",
86
+ "show",
87
+ "get-ref"
88
+ ]),
89
+ stash: /* @__PURE__ */ new Set(["list", "show"]),
90
+ tag: /* @__PURE__ */ new Set([
91
+ "",
92
+ "-l",
93
+ "--list",
94
+ "-n",
95
+ "-v",
96
+ "--verify",
97
+ "--contains",
98
+ "--no-contains",
99
+ "--merged",
100
+ "--no-merged",
101
+ "--points-at"
102
+ ]),
103
+ worktree: /* @__PURE__ */ new Set(["list"]),
104
+ remote: /* @__PURE__ */ new Set([
105
+ "",
106
+ "-v",
107
+ "get-url",
108
+ "show"
109
+ ])
110
+ };
111
+ /**
112
+ * Options that make an argv write whatever else it contains, checked across the whole argv rather than
113
+ * only its first token: `branch -r -d origin/x` leads with a listing flag and still deletes.
114
+ */
115
+ const writeOptions = {
116
+ branch: [
117
+ "-d",
118
+ "-D",
119
+ "--delete",
120
+ "-m",
121
+ "-M",
122
+ "--move",
123
+ "-c",
124
+ "-C",
125
+ "--copy",
126
+ "-f",
127
+ "--force",
128
+ "-t",
129
+ "--track",
130
+ "--no-track",
131
+ "-u",
132
+ "--set-upstream-to",
133
+ "--unset-upstream",
134
+ "--edit-description"
135
+ ],
136
+ config: [
137
+ "--add",
138
+ "--replace-all",
139
+ "--unset",
140
+ "--unset-all",
141
+ "--rename-section",
142
+ "--remove-section",
143
+ "-e",
144
+ "--edit"
145
+ ]
146
+ };
147
+ const configReadOptions = /* @__PURE__ */ new Set([
148
+ "--get",
149
+ "--get-all",
150
+ "--get-regexp",
151
+ "--get-urlmatch",
152
+ "--get-color",
153
+ "--get-colorbool",
154
+ "--list",
155
+ "-l"
156
+ ]);
157
+ function hasWriteOption(verb, rest) {
158
+ const options = writeOptions[verb];
159
+ if (options == null) return false;
160
+ return rest.some((arg) => options.some((opt) => arg === opt || arg.startsWith(`${opt}=`)));
161
+ }
162
+ /**
163
+ * `config <key>` with nothing after the key is git's own read form, as is any `--get*`/`--list`. `config edit`
164
+ * (git 2.46's subcommand form of `--edit`) also has a single non-flag argument but writes.
165
+ */
166
+ function isConfigRead(rest) {
167
+ if (rest[0] === "edit") return false;
168
+ if (rest.some((arg) => configReadOptions.has(arg))) return true;
169
+ return rest.filter((arg) => !arg.startsWith("-")).length === 1;
170
+ }
171
+ /** Global options whose value is the next argument, so the verb scan must skip both. */
172
+ const globalOptionsWithValue = /* @__PURE__ */ new Set([
173
+ "-c",
174
+ "--config-env",
175
+ "--exec-path",
176
+ "--git-dir",
177
+ "--namespace",
178
+ "--super-prefix",
179
+ "--work-tree"
180
+ ]);
181
+ /**
182
+ * Skips the global options (`-c key=val`, `-C path`) git accepts before the verb to find it, and notes a
183
+ * `-C` re-scope so notification targets that tree.
184
+ */
185
+ function leadingCommand(args) {
186
+ let pathOverride;
187
+ let i = 0;
188
+ while (i < args.length) {
189
+ const arg = args[i];
190
+ if (arg === "-C") {
191
+ const path = args[i + 1];
192
+ if (path != null) pathOverride = pathOverride == null || isAbsolute(path) ? path : join(pathOverride, path);
193
+ i += 2;
194
+ continue;
195
+ }
196
+ if (globalOptionsWithValue.has(arg)) {
197
+ i += 2;
198
+ continue;
199
+ }
200
+ if (arg.startsWith("-")) {
201
+ i += 1;
202
+ continue;
203
+ }
204
+ break;
205
+ }
206
+ const verb = args[i] ?? "";
207
+ const rest = args.slice(i + 1);
208
+ return {
209
+ verb,
210
+ readOnly: !hasWriteOption(verb, rest) && (readOnlyVerbs.has(verb) || (readOnlySubcommands[verb]?.has(rest[0] ?? "") ?? false) || verb === "config" && isConfigRead(rest) || verb === "reflog" && !reflogWriteSubcommands.has(rest[0] ?? "") || verb === "symbolic-ref" && !rest.includes("-d") && !rest.includes("--delete") && rest.filter((a) => !a.startsWith("-")).length < 2),
211
+ subcommand: rest[0],
212
+ pathOverride
213
+ };
214
+ }
215
+ /**
216
+ * The change kinds every worktree sharing a `.git` sees: its refs, stash, worktree list and config. The rest a
217
+ * classified verb announces — HEAD, the index, a paused operation, FETCH_HEAD — belong to the one tree the
218
+ * command ran in, so a `-C`-scoped write tells the caller's own `cwd` only this subset of what it changed.
219
+ */
220
+ const worktreeSharedChanges = /* @__PURE__ */ new Set([
221
+ "heads",
222
+ "tags",
223
+ "stash",
224
+ "remotes",
225
+ "worktrees",
226
+ "config"
227
+ ]);
228
+ /**
229
+ * Verbs whose effect is confined to the object store that nothing cached observes — repacking or pruning
230
+ * `.git/objects` changes no cached read (branches, refs, status, worktrees, …). `init` and `clone` create a
231
+ * repository rather than mutate a registered one, so there is nothing yet registered to notify.
232
+ */
233
+ const objectOnlyVerbs = /* @__PURE__ */ new Set([
234
+ "gc",
235
+ "repack",
236
+ "prune",
237
+ "maintenance",
238
+ "commit-graph",
239
+ "multi-pack-index",
240
+ "init",
241
+ "clone"
242
+ ]);
243
+ /**
244
+ * The {@link RepositoryChange} kinds each mutating verb announces. A worktree subcommand other than a
245
+ * listing is handled separately (see {@link getChangesForCommand}), and any verb absent from both this
246
+ * table and {@link objectOnlyVerbs} announces `[]` — the conservative default for an unclassified
247
+ * mutation: the caller still learns something changed, just not what. An entry covers at least what the
248
+ * verb's typed mutator announces; `update-ref` and `symbolic-ref` name every kind their target ref could be.
249
+ * The kinds decide which caches the announcement resets, so a verb that can start or end a paused operation
250
+ * names `pausedOp`: `commit` concludes a merge, cherry-pick or revert, `reset` aborts one, and `am` runs in
251
+ * `rebase-apply`.
252
+ */
253
+ const changesByVerb = {
254
+ commit: [
255
+ "head",
256
+ "heads",
257
+ "index",
258
+ "pausedOp"
259
+ ],
260
+ am: [
261
+ "head",
262
+ "heads",
263
+ "index",
264
+ "pausedOp"
265
+ ],
266
+ bisect: ["head", "index"],
267
+ checkout: [
268
+ "head",
269
+ "heads",
270
+ "index"
271
+ ],
272
+ switch: [
273
+ "head",
274
+ "heads",
275
+ "index"
276
+ ],
277
+ reset: [
278
+ "head",
279
+ "heads",
280
+ "index",
281
+ "pausedOp"
282
+ ],
283
+ merge: [
284
+ "head",
285
+ "heads",
286
+ "index",
287
+ "pausedOp",
288
+ "merge"
289
+ ],
290
+ rebase: [
291
+ "head",
292
+ "heads",
293
+ "index",
294
+ "pausedOp",
295
+ "rebase"
296
+ ],
297
+ "cherry-pick": [
298
+ "head",
299
+ "heads",
300
+ "index",
301
+ "pausedOp",
302
+ "cherryPick"
303
+ ],
304
+ revert: [
305
+ "head",
306
+ "heads",
307
+ "index",
308
+ "pausedOp",
309
+ "revert"
310
+ ],
311
+ pull: [
312
+ "head",
313
+ "heads",
314
+ "index",
315
+ "remotes",
316
+ "tags",
317
+ "lastFetched",
318
+ "pausedOp",
319
+ "merge",
320
+ "rebase"
321
+ ],
322
+ add: ["index"],
323
+ rm: ["index"],
324
+ mv: ["index"],
325
+ restore: ["index"],
326
+ apply: ["index"],
327
+ "read-tree": ["index"],
328
+ "update-index": ["index"],
329
+ clean: ["index"],
330
+ stash: ["stash", "index"],
331
+ "update-ref": [
332
+ "head",
333
+ "heads",
334
+ "remotes",
335
+ "tags",
336
+ "stash"
337
+ ],
338
+ branch: [
339
+ "heads",
340
+ "remotes",
341
+ "tags"
342
+ ],
343
+ "symbolic-ref": [
344
+ "head",
345
+ "heads",
346
+ "remotes",
347
+ "tags"
348
+ ],
349
+ "pack-refs": [
350
+ "heads",
351
+ "remotes",
352
+ "tags"
353
+ ],
354
+ tag: ["tags"],
355
+ fetch: [
356
+ "heads",
357
+ "remotes",
358
+ "tags",
359
+ "lastFetched"
360
+ ],
361
+ push: ["remotes"],
362
+ remote: ["remotes", "config"],
363
+ config: [
364
+ "config",
365
+ "heads",
366
+ "remotes"
367
+ ],
368
+ notes: ["heads"]
369
+ };
370
+ const worktreeChanges = ["worktrees", "heads"];
371
+ const emptyChanges = [];
372
+ /**
373
+ * Classifies a raw git argv for the notification `git.run`'s `notify: 'infer'` applies after the run
374
+ * settles. Returns `undefined` for a read-only or object-only command — nothing to announce — otherwise
375
+ * the {@link RepositoryChange} kinds the verb announces, the `-C` re-scope target (if any), and which of
376
+ * those kinds every worktree sees.
377
+ */
378
+ function getChangesForCommand(args) {
379
+ const command = leadingCommand(args);
380
+ if (command.readOnly || objectOnlyVerbs.has(command.verb)) return void 0;
381
+ const changes = command.verb === "worktree" ? worktreeChanges : changesByVerb[command.verb] ?? emptyChanges;
382
+ return {
383
+ changes,
384
+ pathOverride: command.pathOverride,
385
+ sharedChanges: changes.filter((c) => worktreeSharedChanges.has(c))
386
+ };
387
+ }
388
+ //#endregion
389
+ export { getChangesForCommand, leadingCommand };
390
+
391
+ //# sourceMappingURL=commandClassifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commandClassifier.js","names":[],"sources":["../../../../git-cli/src/exec/commandClassifier.ts"],"sourcesContent":["import { isAbsolute, join } from 'node:path';\nimport type { RepositoryChange } from '@gitlens/git/models/repository.js';\n\n/**\n * Verbs that never move a ref, the index or the working tree, so a raw run needs no notification.\n * Anything not listed is treated as a mutation: a needless notification costs a full cache eviction, a\n * missed one serves stale state. Object-writing plumbing (`hash-object -w`, `mktree`, `commit-tree`,\n * `write-tree`) is listed too: it only adds loose objects nothing cached observes.\n */\nconst readOnlyVerbs = new Set([\n\t'annotate',\n\t'archive',\n\t'blame',\n\t'cat-file',\n\t'check-attr',\n\t'check-ignore',\n\t'check-mailmap',\n\t'check-ref-format',\n\t'cherry',\n\t'commit-tree',\n\t'count-objects',\n\t'describe',\n\t'diff',\n\t'diff-files',\n\t'diff-index',\n\t'diff-tree',\n\t'for-each-ref',\n\t'fsck',\n\t'grep',\n\t'hash-object',\n\t'help',\n\t'log',\n\t'ls-files',\n\t// Asks a remote what it has; nothing local moves.\n\t'ls-remote',\n\t'ls-tree',\n\t'merge-base',\n\t'merge-tree',\n\t'mktree',\n\t'name-rev',\n\t'patch-id',\n\t'range-diff',\n\t'rev-list',\n\t'rev-parse',\n\t'shortlog',\n\t'show',\n\t'show-branch',\n\t'show-ref',\n\t'status',\n\t'var',\n\t'verify-commit',\n\t'verify-pack',\n\t'verify-tag',\n\t'version',\n\t'whatchanged',\n\t'write-tree',\n]);\n\nconst reflogWriteSubcommands: ReadonlySet<string> = new Set(['expire', 'delete', 'drop']);\n\n/**\n * Sub-commands of otherwise-mutating verbs that only list. `''` is the bare verb, which lists for `branch`,\n * `tag`, `remote` and `notes`; `branch -v` and every `tag` filter imply git's own list mode.\n */\nconst readOnlySubcommands: Readonly<Record<string, ReadonlySet<string>>> = {\n\tbranch: new Set([\n\t\t'',\n\t\t'-l',\n\t\t'--list',\n\t\t'--show-current',\n\t\t'-a',\n\t\t'-r',\n\t\t'-v',\n\t\t'-vv',\n\t\t'--verbose',\n\t\t'--contains',\n\t\t'--no-contains',\n\t\t'--merged',\n\t\t'--no-merged',\n\t\t'--points-at',\n\t]),\n\tconfig: new Set(['get', 'list']),\n\tnotes: new Set(['', 'list', 'show', 'get-ref']),\n\tstash: new Set(['list', 'show']),\n\ttag: new Set([\n\t\t'',\n\t\t'-l',\n\t\t'--list',\n\t\t'-n',\n\t\t'-v',\n\t\t'--verify',\n\t\t'--contains',\n\t\t'--no-contains',\n\t\t'--merged',\n\t\t'--no-merged',\n\t\t'--points-at',\n\t]),\n\tworktree: new Set(['list']),\n\tremote: new Set(['', '-v', 'get-url', 'show']),\n};\n\n/**\n * Options that make an argv write whatever else it contains, checked across the whole argv rather than\n * only its first token: `branch -r -d origin/x` leads with a listing flag and still deletes.\n */\nconst writeOptions: Readonly<Record<string, readonly string[]>> = {\n\tbranch: [\n\t\t'-d',\n\t\t'-D',\n\t\t'--delete',\n\t\t'-m',\n\t\t'-M',\n\t\t'--move',\n\t\t'-c',\n\t\t'-C',\n\t\t'--copy',\n\t\t'-f',\n\t\t'--force',\n\t\t'-t',\n\t\t'--track',\n\t\t'--no-track',\n\t\t'-u',\n\t\t'--set-upstream-to',\n\t\t'--unset-upstream',\n\t\t'--edit-description',\n\t],\n\tconfig: [\n\t\t'--add',\n\t\t'--replace-all',\n\t\t'--unset',\n\t\t'--unset-all',\n\t\t'--rename-section',\n\t\t'--remove-section',\n\t\t'-e',\n\t\t'--edit',\n\t],\n};\n\nconst configReadOptions = new Set([\n\t'--get',\n\t'--get-all',\n\t'--get-regexp',\n\t'--get-urlmatch',\n\t'--get-color',\n\t'--get-colorbool',\n\t'--list',\n\t'-l',\n]);\n\nfunction hasWriteOption(verb: string, rest: readonly string[]): boolean {\n\tconst options = writeOptions[verb];\n\tif (options == null) return false;\n\treturn rest.some(arg => options.some(opt => arg === opt || arg.startsWith(`${opt}=`)));\n}\n\n/**\n * `config <key>` with nothing after the key is git's own read form, as is any `--get*`/`--list`. `config edit`\n * (git 2.46's subcommand form of `--edit`) also has a single non-flag argument but writes.\n */\nfunction isConfigRead(rest: readonly string[]): boolean {\n\tif (rest[0] === 'edit') return false;\n\tif (rest.some(arg => configReadOptions.has(arg))) return true;\n\n\treturn rest.filter(arg => !arg.startsWith('-')).length === 1;\n}\n\n/** Global options whose value is the next argument, so the verb scan must skip both. */\nconst globalOptionsWithValue = new Set([\n\t'-c',\n\t'--config-env',\n\t'--exec-path',\n\t'--git-dir',\n\t'--namespace',\n\t'--super-prefix',\n\t'--work-tree',\n]);\n\nexport interface LeadingCommand {\n\tverb: string;\n\treadOnly: boolean;\n\t/** The first token after the verb, unresolved — used for subcommand-shaped decisions (`worktree add`). */\n\tsubcommand?: string;\n\t/** The `-C <path>` target when the caller re-scopes the command to another working tree. */\n\tpathOverride?: string;\n}\n\n/**\n * Skips the global options (`-c key=val`, `-C path`) git accepts before the verb to find it, and notes a\n * `-C` re-scope so notification targets that tree.\n */\nexport function leadingCommand(args: readonly string[]): LeadingCommand {\n\tlet pathOverride: string | undefined;\n\tlet i = 0;\n\twhile (i < args.length) {\n\t\tconst arg = args[i];\n\t\tif (arg === '-C') {\n\t\t\t// git applies each `-C` relative to the one before it\n\t\t\tconst path = args[i + 1];\n\t\t\tif (path != null) {\n\t\t\t\tpathOverride = pathOverride == null || isAbsolute(path) ? path : join(pathOverride, path);\n\t\t\t}\n\t\t\ti += 2;\n\n\t\t\tcontinue;\n\t\t}\n\t\tif (globalOptionsWithValue.has(arg)) {\n\t\t\ti += 2;\n\n\t\t\tcontinue;\n\t\t}\n\t\tif (arg.startsWith('-')) {\n\t\t\ti += 1;\n\n\t\t\tcontinue;\n\t\t}\n\t\tbreak;\n\t}\n\tconst verb = args[i] ?? '';\n\tconst rest = args.slice(i + 1);\n\tconst readOnly =\n\t\t!hasWriteOption(verb, rest) &&\n\t\t(readOnlyVerbs.has(verb) ||\n\t\t\t(readOnlySubcommands[verb]?.has(rest[0] ?? '') ?? false) ||\n\t\t\t(verb === 'config' && isConfigRead(rest)) ||\n\t\t\t// Every `reflog` form reads (bare, `<ref>`, `show`, `list`, `exists`) except the three that rewrite\n\t\t\t// it. Base-branch detection answers \"none\" unless a branch's reflog has exactly one creation entry,\n\t\t\t// so a rewrite can make a cached \"none\" derivable; no change kind names a reflog, so it resets all.\n\t\t\t(verb === 'reflog' && !reflogWriteSubcommands.has(rest[0] ?? '')) ||\n\t\t\t// A bare `symbolic-ref <name>` reads; a second non-flag argument, or a delete, writes.\n\t\t\t(verb === 'symbolic-ref' &&\n\t\t\t\t!rest.includes('-d') &&\n\t\t\t\t!rest.includes('--delete') &&\n\t\t\t\trest.filter(a => !a.startsWith('-')).length < 2));\n\n\treturn { verb: verb, readOnly: readOnly, subcommand: rest[0], pathOverride: pathOverride };\n}\n\n/**\n * The change kinds every worktree sharing a `.git` sees: its refs, stash, worktree list and config. The rest a\n * classified verb announces — HEAD, the index, a paused operation, FETCH_HEAD — belong to the one tree the\n * command ran in, so a `-C`-scoped write tells the caller's own `cwd` only this subset of what it changed.\n */\nconst worktreeSharedChanges: ReadonlySet<RepositoryChange> = new Set([\n\t'heads',\n\t'tags',\n\t'stash',\n\t'remotes',\n\t'worktrees',\n\t'config',\n]);\n\n/**\n * Verbs whose effect is confined to the object store that nothing cached observes — repacking or pruning\n * `.git/objects` changes no cached read (branches, refs, status, worktrees, …). `init` and `clone` create a\n * repository rather than mutate a registered one, so there is nothing yet registered to notify.\n */\nconst objectOnlyVerbs = new Set([\n\t'gc',\n\t'repack',\n\t'prune',\n\t'maintenance',\n\t'commit-graph',\n\t'multi-pack-index',\n\t'init',\n\t'clone',\n]);\n\n/**\n * The {@link RepositoryChange} kinds each mutating verb announces. A worktree subcommand other than a\n * listing is handled separately (see {@link getChangesForCommand}), and any verb absent from both this\n * table and {@link objectOnlyVerbs} announces `[]` — the conservative default for an unclassified\n * mutation: the caller still learns something changed, just not what. An entry covers at least what the\n * verb's typed mutator announces; `update-ref` and `symbolic-ref` name every kind their target ref could be.\n * The kinds decide which caches the announcement resets, so a verb that can start or end a paused operation\n * names `pausedOp`: `commit` concludes a merge, cherry-pick or revert, `reset` aborts one, and `am` runs in\n * `rebase-apply`.\n */\nconst changesByVerb: Readonly<Record<string, readonly RepositoryChange[]>> = {\n\tcommit: ['head', 'heads', 'index', 'pausedOp'],\n\tam: ['head', 'heads', 'index', 'pausedOp'],\n\tbisect: ['head', 'index'],\n\tcheckout: ['head', 'heads', 'index'],\n\tswitch: ['head', 'heads', 'index'],\n\treset: ['head', 'heads', 'index', 'pausedOp'],\n\tmerge: ['head', 'heads', 'index', 'pausedOp', 'merge'],\n\trebase: ['head', 'heads', 'index', 'pausedOp', 'rebase'],\n\t'cherry-pick': ['head', 'heads', 'index', 'pausedOp', 'cherryPick'],\n\trevert: ['head', 'heads', 'index', 'pausedOp', 'revert'],\n\tpull: ['head', 'heads', 'index', 'remotes', 'tags', 'lastFetched', 'pausedOp', 'merge', 'rebase'],\n\tadd: ['index'],\n\trm: ['index'],\n\tmv: ['index'],\n\trestore: ['index'],\n\tapply: ['index'],\n\t'read-tree': ['index'],\n\t'update-index': ['index'],\n\tclean: ['index'],\n\tstash: ['stash', 'index'],\n\t'update-ref': ['head', 'heads', 'remotes', 'tags', 'stash'],\n\tbranch: ['heads', 'remotes', 'tags'],\n\t'symbolic-ref': ['head', 'heads', 'remotes', 'tags'],\n\t'pack-refs': ['heads', 'remotes', 'tags'],\n\ttag: ['tags'],\n\t// A refspec can write a local branch (`fetch origin main:main`), which only the typed fetch parses for\n\tfetch: ['heads', 'remotes', 'tags', 'lastFetched'],\n\tpush: ['remotes'],\n\tremote: ['remotes', 'config'],\n\tconfig: ['config', 'heads', 'remotes'],\n\tnotes: ['heads'],\n};\n\nconst worktreeChanges: readonly RepositoryChange[] = ['worktrees', 'heads'];\nconst emptyChanges: readonly RepositoryChange[] = [];\n\nexport interface CommandChanges {\n\tchanges: readonly RepositoryChange[];\n\t/** The `-C <path>` target when the caller re-scoped the command to another working tree. */\n\tpathOverride?: string;\n\t/** The subset of {@link changes} every worktree sharing the same `.git` sees, not just the tree the command ran in. */\n\tsharedChanges: readonly RepositoryChange[];\n}\n\n/**\n * Classifies a raw git argv for the notification `git.run`'s `notify: 'infer'` applies after the run\n * settles. Returns `undefined` for a read-only or object-only command — nothing to announce — otherwise\n * the {@link RepositoryChange} kinds the verb announces, the `-C` re-scope target (if any), and which of\n * those kinds every worktree sees.\n */\nexport function getChangesForCommand(args: readonly string[]): CommandChanges | undefined {\n\tconst command = leadingCommand(args);\n\tif (command.readOnly || objectOnlyVerbs.has(command.verb)) return undefined;\n\n\t// `worktree list` is read-only (filtered out above); every other subcommand adds, removes or\n\t// relocks a checkout, which is both a worktree-list change and, for `add`, a brand-new HEAD.\n\tconst changes = command.verb === 'worktree' ? worktreeChanges : (changesByVerb[command.verb] ?? emptyChanges);\n\treturn {\n\t\tchanges: changes,\n\t\tpathOverride: command.pathOverride,\n\t\tsharedChanges: changes.filter(c => worktreeSharedChanges.has(c)),\n\t};\n}\n"],"mappings":";;;;;;;;AASA,MAAM,gCAAgB,IAAI,IAAI;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;AAED,MAAM,yCAA8C,IAAI,IAAI;CAAC;CAAU;CAAU;AAAM,CAAC;;;;;AAMxF,MAAM,sBAAqE;CAC1E,wBAAQ,IAAI,IAAI;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,CAAC;CACD,wBAAQ,IAAI,IAAI,CAAC,OAAO,MAAM,CAAC;CAC/B,uBAAO,IAAI,IAAI;EAAC;EAAI;EAAQ;EAAQ;CAAS,CAAC;CAC9C,uBAAO,IAAI,IAAI,CAAC,QAAQ,MAAM,CAAC;CAC/B,qBAAK,IAAI,IAAI;EACZ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,CAAC;CACD,0BAAU,IAAI,IAAI,CAAC,MAAM,CAAC;CAC1B,wBAAQ,IAAI,IAAI;EAAC;EAAI;EAAM;EAAW;CAAM,CAAC;AAC9C;;;;;AAMA,MAAM,eAA4D;CACjE,QAAQ;EACP;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD;CACA,QAAQ;E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O;CACxB,cAAc;EAAC;EAAQ;EAAS;EAAW;EAAQ;CAAO;CAC1D,QAAQ;EAAC;EAAS;EAAW;CAAM;CACnC,gBAAgB;EAAC;EAAQ;EAAS;EAAW;CAAM;CACnD,aAAa;EAAC;EAAS;EAAW;CAAM;CACxC,KAAK,CAAC,MAAM;CAEZ,OAAO;EAAC;EAAS;EAAW;EAAQ;CAAa;CACjD,MAAM,CAAC,SAAS;CAChB,QAAQ,CAAC,WAAW,QAAQ;CAC5B,QAAQ;EAAC;EAAU;EAAS;CAAS;CACrC,OAAO,CAAC,OAAO;AAChB;AAEA,MAAM,kBAA+C,CAAC,aAAa,OAAO;AAC1E,MAAM,eAA4C,CAAC;;;;;;;AAgBnD,SAAgB,qBAAqB,MAAqD;CACzF,MAAM,UAAU,eAAe,IAAI;CACnC,IAAI,QAAQ,YAAY,gBAAgB,IAAI,QAAQ,IAAI,GAAG,OAAO,KAAA;CAIlE,MAAM,UAAU,QAAQ,SAAS,aAAa,kBAAmB,cAAc,QAAQ,SAAS;CAChG,OAAO;EACG;EACT,cAAc,QAAQ;EACtB,eAAe,QAAQ,QAAO,MAAK,sBAAsB,IAAI,CAAC,CAAC;CAChE;AACD"}
@@ -1,4 +1,5 @@
1
1
  import { BranchErrorReason, CheckoutErrorReason, CherryPickErrorReason, CommitErrorReason, FetchErrorReason, GitCommandError, GitSearchErrorReason, GitWarningKey, GitWarnings, MergeErrorReason, PausedOperationAbortErrorReason, PausedOperationContinueErrorReason, PullErrorReason, PushErrorReason, RebaseErrorReason, ReferenceUpdateErrorReason, ResetErrorReason, RevertErrorReason, ShowErrorReason, SigningErrorReason, StashApplyErrorReason, StashPushErrorReason, TagErrorReason, WorktreeCreateErrorReason, WorktreeDeleteErrorReason } from "../../git/errors.js";
2
+ import { RepositoryChange } from "../../git/models/repository.js";
2
3
  import { SigningFormat } from "../../git/models/signature.js";
3
4
  import { GitHealthSlownessCategory } from "../../git/gitHealth.js";
4
5
  import { GitCommandPriority, GitResult, GitRunOptions, GitSpawnOptions } from "../../git/run.types.js";
@@ -231,13 +232,23 @@ export declare class Git {
231
232
  private readonly _eventLoopMonitor;
232
233
  /** Count of git commands currently in flight, across both the exec and streaming paths */
233
234
  private _activeCommandCount;
234
- /** Cached base environment: process.env + static options.env + GCM/LC_ALL vars */
235
+ /** Cached base environment: process.env (minus {@link inheritedEnvKeysToDrop}) + static options.env + GCM/LC_ALL vars */
235
236
  private _baseEnv;
236
237
  /** Cached full environment: base + dynamic getEnvironment() result */
237
238
  private _fullEnv;
238
239
  /** Last dynamic env reference, used to detect when getEnvironment() returns a new object */
239
240
  private _lastDynamicEnv;
241
+ /** Bound via {@link bindChangeNotifier}; announces a `notify`-flagged run's changes. No-op until bound. */
242
+ private _changeNotifier;
240
243
  constructor(_locator: () => Promise<GitLocation>, options?: GitOptions);
244
+ /**
245
+ * Binds the callback a `notify`-flagged {@link run} calls once it settles. `CliGitProvider` wires this
246
+ * to its own `notifyChanged` from its constructor — including when it's handed a pre-built `Git` via
247
+ * `options.git`, so a host-supplied instance gets bound too. With nothing bound, `notify` is a no-op.
248
+ * `repoPaths` holds more than one path only for a `-C`-scoped shared-state verb: the `-C` target, then the
249
+ * caller's own `cwd`.
250
+ */
251
+ bindChangeNotifier(fn: (repoPaths: readonly string[], changes: readonly RepositoryChange[]) => void): void;
241
252
  /**
242
253
  * Returns the base environment for git commands. Cached to avoid spreading
243
254
  * process.env (30-100+ keys) on every call. Includes static options.env and
@@ -256,8 +267,12 @@ export declare class Git {
256
267
  */
257
268
  private buildEnv;
258
269
  dispose(): void;
259
- /** Clear pending commands (e.g. on cache reset) */
260
- clearPendingCommands(): void;
270
+ /**
271
+ * Drops in-flight commands so a later identical call spawns its own run instead of joining one that
272
+ * started before a change. With `repoPaths`, drops only runs whose `cwd` is one of them or inside one;
273
+ * without, drops every run.
274
+ */
275
+ clearPendingCommands(repoPaths?: readonly string[]): void;
261
276
  /** Marks one more git command as in flight; starts the event-loop monitor on the first. */
262
277
  private beginActiveCommand;
263
278
  /** Marks a git command as finished; stops the event-loop monitor once none remain. */
@@ -275,6 +290,12 @@ export declare class Git {
275
290
  ensureSupports(feature: GitFeatures, message: GitFeatureUnsupportedMessage): Promise<void>;
276
291
  run(options: ExitCodeOnlyGitCommandOptions, ...args: readonly (string | undefined)[]): Promise<GitResult<unknown>>;
277
292
  run<T extends string | Buffer = string>(options: GitRunOptions, ...args: readonly (string | undefined)[]): Promise<GitResult<T>>;
293
+ /**
294
+ * Applies `options.notify` once a {@link run} has settled — a no-op unless both `notify` and a
295
+ * {@link bindChangeNotifier bound} notifier are present, so an unflagged caller pays nothing.
296
+ */
297
+ private applyNotify;
298
+ private resolveNotifyPath;
278
299
  private runCore;
279
300
  stream(options: GitSpawnOptions, ...args: readonly (string | undefined)[]): AsyncGenerator<string>;
280
301
  rev_parse__git_dir(cwd: string): Promise<{