@gitkraken/core-gitlens 0.7.1 → 0.8.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.
Files changed (188) hide show
  1. package/CHANGELOG.md +48 -1
  2. package/dist/git/cache.d.ts +18 -5
  3. package/dist/git/cache.js +26 -8
  4. package/dist/git/cache.js.map +1 -1
  5. package/dist/git/context.d.ts +5 -1
  6. package/dist/git/context.js.map +1 -1
  7. package/dist/git/errors.d.ts +28 -1
  8. package/dist/git/errors.js +45 -1
  9. package/dist/git/errors.js.map +1 -1
  10. package/dist/git/providers/branches.d.ts +5 -1
  11. package/dist/git/providers/commits.d.ts +24 -1
  12. package/dist/git/providers/config.d.ts +7 -1
  13. package/dist/git/providers/operations.d.ts +6 -0
  14. package/dist/git/providers/provider.d.ts +17 -0
  15. package/dist/git/providers/refs.d.ts +38 -3
  16. package/dist/git/providers/revision.d.ts +5 -1
  17. package/dist/git/providers/staging.d.ts +12 -0
  18. package/dist/git/providers/worktrees.d.ts +23 -3
  19. package/dist/git/run.types.d.ts +6 -0
  20. package/dist/git-cli/cliGitProvider.d.ts +17 -1
  21. package/dist/git-cli/cliGitProvider.js +37 -1
  22. package/dist/git-cli/cliGitProvider.js.map +1 -1
  23. package/dist/git-cli/exec/git.d.ts +12 -2
  24. package/dist/git-cli/exec/git.js +48 -17
  25. package/dist/git-cli/exec/git.js.map +1 -1
  26. package/dist/git-cli/exec/gitQueue.d.ts +4 -1
  27. package/dist/git-cli/exec/gitQueue.js +1 -1
  28. package/dist/git-cli/exec/gitQueue.js.map +1 -1
  29. package/dist/git-cli/providers/branches.d.ts +10 -1
  30. package/dist/git-cli/providers/branches.js +15 -8
  31. package/dist/git-cli/providers/branches.js.map +1 -1
  32. package/dist/git-cli/providers/commits.d.ts +23 -1
  33. package/dist/git-cli/providers/commits.js +57 -8
  34. package/dist/git-cli/providers/commits.js.map +1 -1
  35. package/dist/git-cli/providers/config.js +4 -3
  36. package/dist/git-cli/providers/config.js.map +1 -1
  37. package/dist/git-cli/providers/operations.d.ts +1 -0
  38. package/dist/git-cli/providers/operations.js +39 -3
  39. package/dist/git-cli/providers/operations.js.map +1 -1
  40. package/dist/git-cli/providers/patch.js +20 -41
  41. package/dist/git-cli/providers/patch.js.map +1 -1
  42. package/dist/git-cli/providers/pausedOperations.js +2 -2
  43. package/dist/git-cli/providers/pausedOperations.js.map +1 -1
  44. package/dist/git-cli/providers/refs.d.ts +15 -3
  45. package/dist/git-cli/providers/refs.js +115 -10
  46. package/dist/git-cli/providers/refs.js.map +1 -1
  47. package/dist/git-cli/providers/revision.d.ts +3 -1
  48. package/dist/git-cli/providers/revision.js +9 -5
  49. package/dist/git-cli/providers/revision.js.map +1 -1
  50. package/dist/git-cli/providers/staging.d.ts +8 -0
  51. package/dist/git-cli/providers/staging.js +59 -7
  52. package/dist/git-cli/providers/staging.js.map +1 -1
  53. package/dist/git-cli/providers/worktrees.d.ts +31 -2
  54. package/dist/git-cli/providers/worktrees.js +75 -7
  55. package/dist/git-cli/providers/worktrees.js.map +1 -1
  56. package/dist/ipc/discovery.js +1 -1
  57. package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
  58. package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
  59. package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
  60. package/dist/plus/git-github/api/github.d.ts +64 -3
  61. package/dist/plus/git-github/api/github.js +237 -24
  62. package/dist/plus/git-github/api/github.js.map +1 -1
  63. package/dist/plus/git-github/providers/github/branches.d.ts +3 -1
  64. package/dist/plus/git-github/providers/github/branches.js +2 -1
  65. package/dist/plus/git-github/providers/github/branches.js.map +1 -1
  66. package/dist/plus/git-github/providers/github/refs.d.ts +10 -3
  67. package/dist/plus/git-github/providers/github/refs.js +4 -4
  68. package/dist/plus/git-github/providers/github/refs.js.map +1 -1
  69. package/dist/plus/git-github/providers/github/revision.d.ts +3 -1
  70. package/dist/plus/git-github/providers/github/revision.js +1 -1
  71. package/dist/plus/git-github/providers/github/revision.js.map +1 -1
  72. package/dist/plus/integrations/collectionMetadata.d.ts +48 -3
  73. package/dist/plus/integrations/collectionMetadata.js +138 -8
  74. package/dist/plus/integrations/collectionMetadata.js.map +1 -1
  75. package/dist/plus/integrations/errors.d.ts +3 -1
  76. package/dist/plus/integrations/errors.js +7 -3
  77. package/dist/plus/integrations/errors.js.map +1 -1
  78. package/dist/plus/integrations/index.d.ts +6 -3
  79. package/dist/plus/integrations/index.js.map +1 -1
  80. package/dist/plus/integrations/integrationService.d.ts +36 -10
  81. package/dist/plus/integrations/integrationService.js +16 -3
  82. package/dist/plus/integrations/integrationService.js.map +1 -1
  83. package/dist/plus/integrations/manager.d.ts +107 -37
  84. package/dist/plus/integrations/models/gitHostIntegration.d.ts +129 -14
  85. package/dist/plus/integrations/models/gitHostIntegration.js +142 -18
  86. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  87. package/dist/plus/integrations/models/integration.d.ts +117 -11
  88. package/dist/plus/integrations/models/integration.js +175 -13
  89. package/dist/plus/integrations/models/integration.js.map +1 -1
  90. package/dist/plus/integrations/models/issuesIntegration.d.ts +18 -5
  91. package/dist/plus/integrations/models/issuesIntegration.js +42 -10
  92. package/dist/plus/integrations/models/issuesIntegration.js.map +1 -1
  93. package/dist/plus/integrations/providers/azure/azure.d.ts +1 -1
  94. package/dist/plus/integrations/providers/azure/azure.js +14 -18
  95. package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
  96. package/dist/plus/integrations/providers/azure/models.d.ts +29 -0
  97. package/dist/plus/integrations/providers/azure/models.js +112 -1
  98. package/dist/plus/integrations/providers/azure/models.js.map +1 -1
  99. package/dist/plus/integrations/providers/azureDevOps.d.ts +73 -3
  100. package/dist/plus/integrations/providers/azureDevOps.js +117 -3
  101. package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
  102. package/dist/plus/integrations/providers/azureDevOpsServer.js +2 -1
  103. package/dist/plus/integrations/providers/azureDevOpsServer.js.map +1 -1
  104. package/dist/plus/integrations/providers/bitbucket/bitbucket.d.ts +61 -0
  105. package/dist/plus/integrations/providers/bitbucket/bitbucket.js +165 -23
  106. package/dist/plus/integrations/providers/bitbucket/bitbucket.js.map +1 -1
  107. package/dist/plus/integrations/providers/bitbucket/models.d.ts +6 -1
  108. package/dist/plus/integrations/providers/bitbucket/models.js +4 -3
  109. package/dist/plus/integrations/providers/bitbucket/models.js.map +1 -1
  110. package/dist/plus/integrations/providers/bitbucket-server/pullRequestSearch.js +2 -2
  111. package/dist/plus/integrations/providers/bitbucket-server/pullRequestSearch.js.map +1 -1
  112. package/dist/plus/integrations/providers/bitbucket-server.d.ts +48 -2
  113. package/dist/plus/integrations/providers/bitbucket-server.js +51 -1
  114. package/dist/plus/integrations/providers/bitbucket-server.js.map +1 -1
  115. package/dist/plus/integrations/providers/bitbucket.d.ts +45 -2
  116. package/dist/plus/integrations/providers/bitbucket.js +41 -2
  117. package/dist/plus/integrations/providers/bitbucket.js.map +1 -1
  118. package/dist/plus/integrations/providers/github.d.ts +49 -5
  119. package/dist/plus/integrations/providers/github.js +102 -7
  120. package/dist/plus/integrations/providers/github.js.map +1 -1
  121. package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +35 -0
  122. package/dist/plus/integrations/providers/gitlab/gitlab.js +132 -15
  123. package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
  124. package/dist/plus/integrations/providers/gitlab/models.d.ts +1 -0
  125. package/dist/plus/integrations/providers/gitlab/models.js +1 -1
  126. package/dist/plus/integrations/providers/gitlab/models.js.map +1 -1
  127. package/dist/plus/integrations/providers/gitlab.d.ts +49 -2
  128. package/dist/plus/integrations/providers/gitlab.js +80 -4
  129. package/dist/plus/integrations/providers/gitlab.js.map +1 -1
  130. package/dist/plus/integrations/providers/jira-server.d.ts +3 -3
  131. package/dist/plus/integrations/providers/jira-server.js +5 -8
  132. package/dist/plus/integrations/providers/jira-server.js.map +1 -1
  133. package/dist/plus/integrations/providers/jira.d.ts +9 -0
  134. package/dist/plus/integrations/providers/jira.js +13 -1
  135. package/dist/plus/integrations/providers/jira.js.map +1 -1
  136. package/dist/plus/integrations/providers/linear.js +1 -1
  137. package/dist/plus/integrations/providers/models.d.ts +13 -2
  138. package/dist/plus/integrations/providers/models.js +11 -1
  139. package/dist/plus/integrations/providers/models.js.map +1 -1
  140. package/dist/plus/integrations/providers/providerErrors.d.ts +9 -1
  141. package/dist/plus/integrations/providers/providerErrors.js +10 -1
  142. package/dist/plus/integrations/providers/providerErrors.js.map +1 -1
  143. package/dist/plus/integrations/providers/providersApi.d.ts +60 -1
  144. package/dist/plus/integrations/providers/providersApi.js +137 -2
  145. package/dist/plus/integrations/providers/providersApi.js.map +1 -1
  146. package/dist/plus/integrations/providers/utils/providerPaging.d.ts +42 -0
  147. package/dist/plus/integrations/providers/utils/providerPaging.js +58 -1
  148. package/dist/plus/integrations/providers/utils/providerPaging.js.map +1 -1
  149. package/dist/plus/integrations/providers/utils.d.ts +1 -1
  150. package/dist/plus/integrations/reads/broaden.js +1 -1
  151. package/dist/plus/integrations/reads/context.d.ts +1 -1
  152. package/dist/plus/integrations/reads/counts.js +1 -1
  153. package/dist/plus/integrations/reads/currentAccount.d.ts +35 -0
  154. package/dist/plus/integrations/reads/currentAccount.js +46 -0
  155. package/dist/plus/integrations/reads/currentAccount.js.map +1 -0
  156. package/dist/plus/integrations/reads/drains.d.ts +5 -2
  157. package/dist/plus/integrations/reads/drains.js +8 -4
  158. package/dist/plus/integrations/reads/drains.js.map +1 -1
  159. package/dist/plus/integrations/reads/hierarchy.js +1 -1
  160. package/dist/plus/integrations/reads/hierarchy.utils.js +1 -1
  161. package/dist/plus/integrations/reads/issueBatch.d.ts +72 -12
  162. package/dist/plus/integrations/reads/issueBatch.js +193 -48
  163. package/dist/plus/integrations/reads/issueBatch.js.map +1 -1
  164. package/dist/plus/integrations/reads/issueTracker.js +1 -1
  165. package/dist/plus/integrations/reads/issues.js +1 -1
  166. package/dist/plus/integrations/reads/pullRequestBatch.d.ts +57 -0
  167. package/dist/plus/integrations/reads/pullRequestBatch.js +80 -0
  168. package/dist/plus/integrations/reads/pullRequestBatch.js.map +1 -0
  169. package/dist/plus/integrations/reads/pullRequestBranches.d.ts +58 -0
  170. package/dist/plus/integrations/reads/pullRequestBranches.js +111 -0
  171. package/dist/plus/integrations/reads/pullRequestBranches.js.map +1 -0
  172. package/dist/plus/integrations/reads/pullRequests.js +3 -3
  173. package/dist/plus/integrations/reads/pullRequests.js.map +1 -1
  174. package/dist/plus/integrations/reads/resolveRepository.js +1 -1
  175. package/dist/plus/integrations/reads/sweeps.js +4 -4
  176. package/dist/plus/integrations/reads/sweeps.js.map +1 -1
  177. package/dist/plus/integrations/results.d.ts +87 -6
  178. package/dist/plus/integrations/results.js +9 -2
  179. package/dist/plus/integrations/results.js.map +1 -1
  180. package/dist/utils/env/node/exec.js +3 -3
  181. package/dist/utils/env/node/exec.js.map +1 -1
  182. package/docs/integrations.md +175 -35
  183. package/docs/kepler-git-write-api-parity.md +239 -0
  184. package/docs/kepler-read-api-parity.md +75 -28
  185. package/package.json +1 -1
  186. package/dist/plus/integrations/reads/trackerIssue.d.ts +0 -33
  187. package/dist/plus/integrations/reads/trackerIssue.js +0 -60
  188. package/dist/plus/integrations/reads/trackerIssue.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"revision.js","names":[],"sources":["../../../../git-cli/src/providers/revision.ts"],"sourcesContent":["import type { Cache } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport { ShowError } from '@gitlens/git/errors.js';\nimport type { GitFileStatus } from '@gitlens/git/models/fileStatus.js';\nimport { deletedOrMissing } from '@gitlens/git/models/revision.js';\nimport type { GitTreeEntry } from '@gitlens/git/models/tree.js';\nimport type { GitRevisionSubProvider, ResolvedRevision } from '@gitlens/git/providers/revision.js';\nimport {\n\tisRevisionWithSuffix,\n\tisSha,\n\tisUncommitted,\n\tisUncommittedStaged,\n\tisUncommittedWithParentSuffix,\n} from '@gitlens/git/utils/revision.utils.js';\nimport { gate } from '@gitlens/utils/decorators/gate.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport { first } from '@gitlens/utils/iterable.js';\nimport { splitPath } from '@gitlens/utils/path.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\nimport { toFsPath } from '@gitlens/utils/uri.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport type { GitErrorHandling, GitRunOptions } from '../exec/exec.types.js';\nimport type { Git } from '../exec/git.js';\nimport { defaultExceptionHandler, getGitCommandError, gitConfigsLog, GitErrors } from '../exec/git.js';\nimport { parseGitLsFilesStaged } from '../parsers/indexParser.js';\nimport { getShaAndFileSummaryLogParser } from '../parsers/logParser.js';\nimport { parseGitTree } from '../parsers/treeParser.js';\n\nconst emptyArray: readonly GitTreeEntry[] = Object.freeze([]);\n\nexport class RevisionGitSubProvider implements GitRevisionSubProvider {\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) {}\n\n\texists(\n\t\trepoPath: string,\n\t\tpath: string,\n\t\trevOrOptions?: string | { untracked?: 'only' | 'include' },\n\t): Promise<boolean> {\n\t\tlet rev: string | undefined;\n\t\tlet untracked: 'only' | 'include' | undefined;\n\t\tif (typeof revOrOptions === 'string') {\n\t\t\trev = revOrOptions;\n\t\t} else if (revOrOptions != null) {\n\t\t\tuntracked = revOrOptions.untracked;\n\t\t}\n\n\t\tconst cacheKey = `${path}\\0${rev ?? ''}\\0${untracked ?? ''}`;\n\t\treturn this.cache.fileExistence.getOrCreate(repoPath, cacheKey, async () => {\n\t\t\tconst args = ['ls-files'];\n\t\t\tif (rev) {\n\t\t\t\tif (!isUncommitted(rev)) {\n\t\t\t\t\targs.push(`--with-tree=${rev}`);\n\t\t\t\t} else if (isUncommittedStaged(rev)) {\n\t\t\t\t\targs.push('--stage');\n\t\t\t\t}\n\t\t\t} else if (untracked === 'only') {\n\t\t\t\targs.push('-o');\n\t\t\t} else if (untracked === 'include') {\n\t\t\t\t// Tracked (cached) OR untracked (others)\n\t\t\t\targs.push('-c', '-o');\n\t\t\t}\n\n\t\t\tconst result = await this.git.run({ cwd: repoPath, errors: 'ignore' }, ...args, '--', path);\n\t\t\treturn Boolean(result.stdout.trim());\n\t\t});\n\t}\n\n\t@gate()\n\t@debug()\n\tgetRevisionContent(repoPath: string, path: string, rev: string): Promise<Uint8Array | undefined> {\n\t\tconst [relativePath, root] = splitPath(path, repoPath);\n\t\treturn this.showContentCore<Buffer>(root, relativePath, rev, { encoding: 'buffer', errors: 'throw' });\n\t}\n\n\t@debug()\n\tasync getSubmoduleHead(repoPath: string, submodulePath: string): Promise<string | undefined> {\n\t\t// Verify the path is a submodule (gitlink commit) in the parent tree, not just a regular directory\n\t\tconst treeEntry = await this.getTreeEntryForRevision(repoPath, submodulePath, 'HEAD');\n\t\tif (treeEntry?.type !== 'commit') return undefined;\n\n\t\tconst [relativePath, root] = splitPath(submodulePath, repoPath);\n\t\tconst submoduleFullPath = this.provider.getAbsoluteUri(relativePath, root).fsPath;\n\n\t\tconst result = await this.git.run({ cwd: submoduleFullPath, errors: 'ignore' }, 'rev-parse', 'HEAD');\n\t\tconst sha = result.stdout.trim();\n\t\treturn sha || undefined;\n\t}\n\n\t@gate()\n\t@debug()\n\tasync getTreeEntryForRevision(repoPath: string, path: string, rev: string): Promise<GitTreeEntry | undefined> {\n\t\tif (!repoPath || !path) return undefined;\n\n\t\tconst [relativePath, root] = splitPath(path, repoPath);\n\n\t\tif (isUncommittedStaged(rev)) {\n\t\t\tlet result = await this.git.run(\n\t\t\t\t{ cwd: root, errors: 'ignore' },\n\t\t\t\t'ls-files',\n\t\t\t\t'-z',\n\t\t\t\t'--stage',\n\t\t\t\t'--',\n\t\t\t\trelativePath,\n\t\t\t);\n\n\t\t\tconst entries = parseGitLsFilesStaged(result.stdout, true);\n\t\t\tif (entries.length === 0) return undefined;\n\n\t\t\tconst entry = entries[0];\n\t\t\tresult = await this.git.run({ cwd: root }, 'cat-file', '-s', entry.oid);\n\t\t\tconst size = parseInt(result.stdout.trim(), 10) || 0;\n\n\t\t\treturn { ref: rev, oid: entry.oid, path: relativePath, size: size, type: 'blob' };\n\t\t}\n\n\t\tconst [entry] = await this.getTreeForRevisionCore(repoPath, rev, path);\n\t\treturn entry;\n\t}\n\n\t@debug()\n\tasync getTrackedFiles(repoPath: string): Promise<string[]> {\n\t\tif (!repoPath) return [];\n\n\t\tconst result = await this.git.run({ cwd: repoPath, errors: 'ignore' }, 'ls-files', '-z');\n\t\tconst data = result.stdout;\n\t\tif (!data) return [];\n\n\t\treturn [...new Set(data.split('\\0').filter(Boolean))];\n\t}\n\n\t@debug()\n\tasync getTreeForRevision(repoPath: string, rev: string): Promise<GitTreeEntry[]> {\n\t\treturn repoPath ? this.getTreeForRevisionCore(repoPath, rev) : [];\n\t}\n\n\t@gate()\n\tprivate async getTreeForRevisionCore(repoPath: string, rev: string, path?: string): Promise<GitTreeEntry[]> {\n\t\tconst hasPath = Boolean(path);\n\t\tconst args = hasPath ? ['ls-tree', '-l', rev, '--', path] : ['ls-tree', '-lrt', rev, '--'];\n\t\tconst result = await this.git.run({ cwd: repoPath, errors: 'ignore' }, ...args);\n\t\tconst data = result.stdout.trim();\n\t\tif (!data) return emptyArray as GitTreeEntry[];\n\n\t\treturn parseGitTree(data, rev, hasPath);\n\t}\n\n\tprivate async showContentCore<T extends string | Buffer>(\n\t\trepoPath: string | undefined,\n\t\tpath: string,\n\t\trev: string,\n\t\toptions?: {\n\t\t\tencoding?: string;\n\t\t\terrors?: GitErrorHandling;\n\t\t},\n\t): Promise<T | undefined> {\n\t\tconst [file, root] = splitPath(path, repoPath, true);\n\n\t\tif (isUncommittedStaged(rev)) {\n\t\t\trev = ':';\n\t\t}\n\t\tif (isUncommitted(rev)) throw new Error(`ref=${rev} is uncommitted`);\n\n\t\tconst opts: GitRunOptions = {\n\t\t\tconfigs: gitConfigsLog,\n\t\t\tcwd: root,\n\t\t\tencoding: options?.encoding ?? 'utf8',\n\t\t\terrors: 'throw',\n\t\t};\n\t\tconst args = rev.endsWith(':') ? `${rev}./${file}` : `${rev}:./${file}`;\n\t\tconst params = ['show', '--textconv', args, '--'];\n\n\t\ttry {\n\t\t\tconst result = await this.git.run<T>(opts, ...params);\n\t\t\treturn result.stdout;\n\t\t} catch (ex) {\n\t\t\tconst msg: string = ex?.toString() ?? '';\n\t\t\tif (rev === ':' && GitErrors.badRevision.test(msg)) {\n\t\t\t\treturn this.showContentCore<T>(repoPath, path, 'HEAD:', options);\n\t\t\t}\n\n\t\t\tconst error = getGitCommandError(\n\t\t\t\t'show',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew ShowError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason ?? 'other',\n\t\t\t\t\t\t\trev: rev,\n\t\t\t\t\t\t\tpath: path,\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath ?? '', args: params },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex,\n\t\t\t\t\t),\n\t\t\t);\n\t\t\tif (options?.errors === 'throw') throw error;\n\n\t\t\tif (\n\t\t\t\tShowError.is(error, 'invalidObject') ||\n\t\t\t\tShowError.is(error, 'invalidRevision') ||\n\t\t\t\tShowError.is(error, 'notFound') ||\n\t\t\t\tShowError.is(error, 'notInRevision')\n\t\t\t) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tdefaultExceptionHandler(ex, opts.cwd);\n\t\t\treturn '' as T;\n\t\t}\n\t}\n\n\t@debug({ args: (repoPath, shas) => ({ repoPath: repoPath, shas: `${shas.size} value(s)` }) })\n\tasync resolveShas(repoPath: string, shas: ReadonlySet<string>, cancellation?: AbortSignal): Promise<Set<string>> {\n\t\tconst resolved = new Set<string>();\n\t\tconst prefixes: string[] = [];\n\n\t\tfor (const value of shas) {\n\t\t\t// Pure hex 4-40 chars: resolve to full commit SHA(s) via disambiguation. Everything else\n\t\t\t// (refs, suffixed SHAs like `^`/`~1`/`:path`, non-hex, <4 hex) passes through unchanged.\n\t\t\tif (/^[0-9a-f]{4,40}$/i.test(value)) {\n\t\t\t\tprefixes.push(value);\n\t\t\t} else {\n\t\t\t\tresolved.add(value);\n\t\t\t}\n\t\t}\n\n\t\tif (prefixes.length) {\n\t\t\t// List every object (any type) whose id starts with any prefix (empty + exit 0 if none)\n\t\t\tconst rp = await this.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'ignore' },\n\t\t\t\t'rev-parse',\n\t\t\t\t...prefixes.map(p => `--disambiguate=${p}`),\n\t\t\t);\n\t\t\tconst oids = rp.stdout.split('\\n').filter(Boolean);\n\t\t\tif (oids.length) {\n\t\t\t\t// `--disambiguate` has no type filter, so keep only commit objects\n\t\t\t\tconst cf = await this.git.run(\n\t\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'ignore', stdin: `${oids.join('\\n')}\\n` },\n\t\t\t\t\t'cat-file',\n\t\t\t\t\t'--batch-check=%(objectname) %(objecttype)',\n\t\t\t\t);\n\t\t\t\tfor (const line of cf.stdout.split('\\n')) {\n\t\t\t\t\tconst [oid, type] = line.split(' ');\n\t\t\t\t\tif (type === 'commit') {\n\t\t\t\t\t\tresolved.add(oid);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn resolved;\n\t}\n\n\t@debug()\n\tasync resolveRevision(repoPath: string, ref: string, pathOrUri?: string | Uri): Promise<ResolvedRevision> {\n\t\tconst path = pathOrUri != null ? toFsPath(pathOrUri) : undefined;\n\t\tif (!ref || ref === deletedOrMissing) return { sha: ref, revision: ref };\n\n\t\tif (path == null) {\n\t\t\tif (isSha(ref)) return { sha: ref, revision: ref };\n\t\t\tif (ref.endsWith('^3')) return { sha: ref, revision: ref };\n\t\t} else if (isUncommitted(ref)) {\n\t\t\t// Uncommitted refs depend on index/working-tree state — resolve without caching\n\t\t\treturn this.resolveRevisionCore(repoPath, ref, path);\n\t\t}\n\n\t\tconst key = path != null ? `${ref}|${this.provider.getRelativePath(path, repoPath)}` : ref;\n\t\treturn this.cache.resolvedRevisions.getOrCreate(repoPath, key, () =>\n\t\t\tthis.resolveRevisionCore(repoPath, ref, path),\n\t\t);\n\t}\n\n\tprivate async resolveRevisionCore(\n\t\trepoPath: string,\n\t\tref: string,\n\t\tpath: string | undefined,\n\t): Promise<ResolvedRevision> {\n\t\tif (path == null) {\n\t\t\tconst sha = await this.provider.refs.validateReference(repoPath, ref);\n\t\t\tif (sha == null) return { sha: ref, revision: ref };\n\n\t\t\treturn {\n\t\t\t\tsha: sha,\n\t\t\t\t// If it looks like non-sha like then preserve it as the friendly name\n\t\t\t\trevision: isRevisionWithSuffix(ref) ? sha : ref,\n\t\t\t};\n\t\t}\n\n\t\tif (isUncommittedWithParentSuffix(ref)) {\n\t\t\tref = 'HEAD';\n\t\t}\n\t\tconst relativePath = this.provider.getRelativePath(path, repoPath);\n\n\t\tif (isUncommitted(ref)) {\n\t\t\tif (!isUncommittedStaged(ref)) {\n\t\t\t\treturn { sha: ref, revision: ref };\n\t\t\t}\n\n\t\t\t// Ensure that the file is actually staged\n\t\t\tconst status = await this.provider.status.getStatusForFile?.(repoPath, relativePath, { renames: false });\n\t\t\tif (status?.indexStatus) return { sha: ref, revision: ref };\n\n\t\t\tref = 'HEAD';\n\t\t}\n\n\t\tconst resolvedRevisionCaching = { cache: this.cache.gitResults, options: { accessTTL: 5 * 60 * 1000 } };\n\n\t\tconst parser = getShaAndFileSummaryLogParser();\n\t\tlet result = await this.git.run(\n\t\t\t{ cwd: repoPath, errors: 'ignore', caching: resolvedRevisionCaching },\n\t\t\t'log',\n\t\t\t...parser.arguments,\n\t\t\t'-n1',\n\t\t\tref,\n\t\t\t'--',\n\t\t\trelativePath,\n\t\t);\n\n\t\tlet commit = first(parser.parse(result.stdout));\n\t\tlet file = commit?.files.find(f => f.path === relativePath);\n\t\tif (file == null) {\n\t\t\treturn {\n\t\t\t\tsha: commit?.sha ?? deletedOrMissing,\n\t\t\t\t// If it looks like non-sha like then preserve it as the friendly name\n\t\t\t\trevision: isRevisionWithSuffix(ref) ? (commit?.sha ?? ref) : ref,\n\t\t\t};\n\t\t}\n\n\t\tif (file.status === 'A') {\n\t\t\treturn {\n\t\t\t\tsha: commit?.sha ?? deletedOrMissing,\n\t\t\t\t// If it looks like non-sha like then preserve it as the friendly name\n\t\t\t\trevision: isRevisionWithSuffix(ref) ? (commit?.sha ?? ref) : ref,\n\t\t\t\tstatus: file.status as GitFileStatus,\n\t\t\t\toriginalPath: file.originalPath,\n\t\t\t};\n\t\t}\n\n\t\tif (file.status === 'D') {\n\t\t\t// If the file was deleted, check if it was moved or renamed\n\t\t\tresult = await this.git.run(\n\t\t\t\t{ cwd: repoPath, errors: 'ignore', caching: resolvedRevisionCaching },\n\t\t\t\t'log',\n\t\t\t\t...parser.arguments,\n\t\t\t\t'-n1',\n\n\t\t\t\tcommit!.sha,\n\t\t\t\t'--',\n\t\t\t);\n\n\t\t\tcommit = first(parser.parse(result.stdout));\n\t\t\tfile = commit?.files.find(f => f.path === relativePath || f.originalPath === relativePath);\n\t\t\tif (file == null) {\n\t\t\t\treturn {\n\t\t\t\t\tsha: commit?.sha ?? deletedOrMissing,\n\t\t\t\t\t// If it looks like non-sha like then preserve it as the friendly name\n\t\t\t\t\trevision: isRevisionWithSuffix(ref) ? (commit?.sha ?? ref) : ref,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tsha: commit?.sha ?? deletedOrMissing,\n\t\t\t\t// If it looks like non-sha like without a suffix then preserve it as the friendly name\n\t\t\t\trevision: isRevisionWithSuffix(ref) ? (commit?.sha ?? ref) : ref,\n\t\t\t\tstatus: file.status as GitFileStatus,\n\t\t\t\tpath: file.path,\n\t\t\t\toriginalPath: file.originalPath,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tsha: commit?.sha ?? deletedOrMissing,\n\t\t\t// If it looks like non-sha like then preserve it as the friendly name\n\t\t\trevision: isRevisionWithSuffix(ref) ? (commit?.sha ?? ref) : ref,\n\t\t\tstatus: file.status as GitFileStatus,\n\t\t\toriginalPath: file.originalPath,\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AA4BA,MAAM,aAAsC,OAAO,OAAO,CAAC,CAAC;AAE5D,IAAa,yBAAb,MAAsE;CAEnD;CACA;CACA;CACA;CAJlB,YACC,SACA,KACA,OACA,UACC;EAJgB,KAAA,UAAA;EACA,KAAA,MAAA;EACA,KAAA,QAAA;EACA,KAAA,WAAA;CACf;CAEH,OACC,UACA,MACA,cACmB;EACnB,IAAI;EACJ,IAAI;EACJ,IAAI,OAAO,iBAAiB,UAC3B,MAAM;OACA,IAAI,gBAAgB,MAC1B,YAAY,aAAa;EAG1B,MAAM,WAAW,GAAG,KAAK,IAAI,OAAO,GAAG,IAAI,aAAa;EACxD,OAAO,KAAK,MAAM,cAAc,YAAY,UAAU,UAAU,YAAY;GAC3E,MAAM,OAAO,CAAC,UAAU;GACxB,IAAI,KAAK;IACR,IAAI,CAAC,cAAc,GAAG,GACrB,KAAK,KAAK,eAAe,KAAK;SACxB,IAAI,oBAAoB,GAAG,GACjC,KAAK,KAAK,SAAS;GAErB,OAAO,IAAI,cAAc,QACxB,KAAK,KAAK,IAAI;QACR,IAAI,cAAc,WAExB,KAAK,KAAK,MAAM,IAAI;GAGrB,MAAM,SAAS,MAAM,KAAK,IAAI,IAAI;IAAE,KAAK;IAAU,QAAQ;GAAS,GAAG,GAAG,MAAM,MAAM,IAAI;GAC1F,OAAO,QAAQ,OAAO,OAAO,KAAK,CAAC;EACpC,CAAC;CACF;CAEA,mBAEmB,UAAkB,MAAc,KAA8C;EAChG,MAAM,CAAC,cAAc,QAAQ,UAAU,MAAM,QAAQ;EACrD,OAAO,KAAK,gBAAwB,MAAM,cAAc,KAAK;GAAE,UAAU;GAAU,QAAQ;EAAQ,CAAC;C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AK,GACL,MAAM,CAAA,GAAA,uBAAA,WAAA,sBAAA,IAAA;AAMN,WAAA,CAAA,MAAM,CAAA,GAAA,uBAAA,WAAA,oBAAA,IAAA;AAcN,WAAA,CAAA,KAAK,GACL,MAAM,CAAA,GAAA,uBAAA,WAAA,2BAAA,IAAA;AA8BN,WAAA,CAAA,MAAM,CAAA,GAAA,uBAAA,WAAA,mBAAA,IAAA;AAWN,WAAA,CAAA,MAAM,CAAA,GAAA,uBAAA,WAAA,sBAAA,IAAA;AAKN,WAAA,CAAA,KAAK,CAAA,GAAA,uBAAA,WAAA,0BAAA,IAAA;AA2EL,WAAA,CAAA,MAAM,EAAE,OAAO,UAAU,UAAU;CAAY;CAAU,MAAM,GAAG,KAAK,KAAK;AAAW,GAAG,CAAC,CAAA,GAAA,uBAAA,WAAA,eAAA,IAAA;AA0C3F,WAAA,CAAA,MAAM,CAAA,GAAA,uBAAA,WAAA,mBAAA,IAAA"}
1
+ {"version":3,"file":"revision.js","names":[],"sources":["../../../../git-cli/src/providers/revision.ts"],"sourcesContent":["import type { Cache } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport { ShowError } from '@gitlens/git/errors.js';\nimport type { GitFileStatus } from '@gitlens/git/models/fileStatus.js';\nimport { deletedOrMissing } from '@gitlens/git/models/revision.js';\nimport type { GitTreeEntry } from '@gitlens/git/models/tree.js';\nimport type { GitRevisionSubProvider, ResolvedRevision } from '@gitlens/git/providers/revision.js';\nimport {\n\tisRevisionWithSuffix,\n\tisSha,\n\tisUncommitted,\n\tisUncommittedStaged,\n\tisUncommittedWithParentSuffix,\n} from '@gitlens/git/utils/revision.utils.js';\nimport { gate } from '@gitlens/utils/decorators/gate.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport { first } from '@gitlens/utils/iterable.js';\nimport { splitPath } from '@gitlens/utils/path.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\nimport { toFsPath } from '@gitlens/utils/uri.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport type { GitErrorHandling, GitRunOptions } from '../exec/exec.types.js';\nimport type { Git } from '../exec/git.js';\nimport { defaultExceptionHandler, getGitCommandError, gitConfigsLog, GitErrors } from '../exec/git.js';\nimport { parseGitLsFilesStaged } from '../parsers/indexParser.js';\nimport { getShaAndFileSummaryLogParser } from '../parsers/logParser.js';\nimport { parseGitTree } from '../parsers/treeParser.js';\n\nconst emptyArray: readonly GitTreeEntry[] = Object.freeze([]);\n\nexport class RevisionGitSubProvider implements GitRevisionSubProvider {\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) {}\n\n\texists(\n\t\trepoPath: string,\n\t\tpath: string,\n\t\trevOrOptions?: string | { untracked?: 'only' | 'include' },\n\t): Promise<boolean> {\n\t\tlet rev: string | undefined;\n\t\tlet untracked: 'only' | 'include' | undefined;\n\t\tif (typeof revOrOptions === 'string') {\n\t\t\trev = revOrOptions;\n\t\t} else if (revOrOptions != null) {\n\t\t\tuntracked = revOrOptions.untracked;\n\t\t}\n\n\t\tconst cacheKey = `${path}\\0${rev ?? ''}\\0${untracked ?? ''}`;\n\t\treturn this.cache.fileExistence.getOrCreate(repoPath, cacheKey, async () => {\n\t\t\tconst args = ['ls-files'];\n\t\t\tif (rev) {\n\t\t\t\tif (!isUncommitted(rev)) {\n\t\t\t\t\targs.push(`--with-tree=${rev}`);\n\t\t\t\t} else if (isUncommittedStaged(rev)) {\n\t\t\t\t\targs.push('--stage');\n\t\t\t\t}\n\t\t\t} else if (untracked === 'only') {\n\t\t\t\targs.push('-o');\n\t\t\t} else if (untracked === 'include') {\n\t\t\t\t// Tracked (cached) OR untracked (others)\n\t\t\t\targs.push('-c', '-o');\n\t\t\t}\n\n\t\t\tconst result = await this.git.run({ cwd: repoPath, errors: 'ignore' }, ...args, '--', path);\n\t\t\treturn Boolean(result.stdout.trim());\n\t\t});\n\t}\n\n\t@gate()\n\t@debug()\n\tgetRevisionContent(repoPath: string, path: string, rev: string): Promise<Uint8Array | undefined> {\n\t\tconst [relativePath, root] = splitPath(path, repoPath);\n\t\treturn this.showContentCore<Buffer>(root, relativePath, rev, { encoding: 'buffer', errors: 'throw' });\n\t}\n\n\t@debug()\n\tasync getSubmoduleHead(repoPath: string, submodulePath: string): Promise<string | undefined> {\n\t\t// Verify the path is a submodule (gitlink commit) in the parent tree, not just a regular directory\n\t\tconst treeEntry = await this.getTreeEntryForRevision(repoPath, submodulePath, 'HEAD');\n\t\tif (treeEntry?.type !== 'commit') return undefined;\n\n\t\tconst [relativePath, root] = splitPath(submodulePath, repoPath);\n\t\tconst submoduleFullPath = this.provider.getAbsoluteUri(relativePath, root).fsPath;\n\n\t\tconst result = await this.git.run({ cwd: submoduleFullPath, errors: 'ignore' }, 'rev-parse', 'HEAD');\n\t\tconst sha = result.stdout.trim();\n\t\treturn sha || undefined;\n\t}\n\n\t@gate()\n\t@debug()\n\tasync getTreeEntryForRevision(repoPath: string, path: string, rev: string): Promise<GitTreeEntry | undefined> {\n\t\tif (!repoPath || !path) return undefined;\n\n\t\tconst [relativePath, root] = splitPath(path, repoPath);\n\n\t\tif (isUncommittedStaged(rev)) {\n\t\t\tlet result = await this.git.run(\n\t\t\t\t{ cwd: root, errors: 'ignore' },\n\t\t\t\t'ls-files',\n\t\t\t\t'-z',\n\t\t\t\t'--stage',\n\t\t\t\t'--',\n\t\t\t\trelativePath,\n\t\t\t);\n\n\t\t\tconst entries = parseGitLsFilesStaged(result.stdout, true);\n\t\t\tif (entries.length === 0) return undefined;\n\n\t\t\tconst entry = entries[0];\n\t\t\tresult = await this.git.run({ cwd: root }, 'cat-file', '-s', entry.oid);\n\t\t\tconst size = parseInt(result.stdout.trim(), 10) || 0;\n\n\t\t\treturn { ref: rev, oid: entry.oid, path: relativePath, size: size, type: 'blob' };\n\t\t}\n\n\t\tconst [entry] = await this.getTreeForRevisionCore(repoPath, rev, path);\n\t\treturn entry;\n\t}\n\n\t@debug()\n\tasync getTrackedFiles(repoPath: string): Promise<string[]> {\n\t\tif (!repoPath) return [];\n\n\t\tconst result = await this.git.run({ cwd: repoPath, errors: 'ignore' }, 'ls-files', '-z');\n\t\tconst data = result.stdout;\n\t\tif (!data) return [];\n\n\t\treturn [...new Set(data.split('\\0').filter(Boolean))];\n\t}\n\n\t@debug()\n\tasync getTreeForRevision(repoPath: string, rev: string): Promise<GitTreeEntry[]> {\n\t\treturn repoPath ? this.getTreeForRevisionCore(repoPath, rev) : [];\n\t}\n\n\t@gate()\n\tprivate async getTreeForRevisionCore(repoPath: string, rev: string, path?: string): Promise<GitTreeEntry[]> {\n\t\tconst hasPath = Boolean(path);\n\t\tconst args = hasPath ? ['ls-tree', '-l', rev, '--', path] : ['ls-tree', '-lrt', rev, '--'];\n\t\tconst result = await this.git.run({ cwd: repoPath, errors: 'ignore' }, ...args);\n\t\tconst data = result.stdout.trim();\n\t\tif (!data) return emptyArray as GitTreeEntry[];\n\n\t\treturn parseGitTree(data, rev, hasPath);\n\t}\n\n\tprivate async showContentCore<T extends string | Buffer>(\n\t\trepoPath: string | undefined,\n\t\tpath: string,\n\t\trev: string,\n\t\toptions?: {\n\t\t\tencoding?: string;\n\t\t\terrors?: GitErrorHandling;\n\t\t},\n\t): Promise<T | undefined> {\n\t\tconst [file, root] = splitPath(path, repoPath, true);\n\n\t\tif (isUncommittedStaged(rev)) {\n\t\t\trev = ':';\n\t\t}\n\t\tif (isUncommitted(rev)) throw new Error(`ref=${rev} is uncommitted`);\n\n\t\tconst opts: GitRunOptions = {\n\t\t\tconfigs: gitConfigsLog,\n\t\t\tcwd: root,\n\t\t\tencoding: options?.encoding ?? 'utf8',\n\t\t\terrors: 'throw',\n\t\t};\n\t\tconst args = rev.endsWith(':') ? `${rev}./${file}` : `${rev}:./${file}`;\n\t\tconst params = ['show', '--textconv', args, '--'];\n\n\t\ttry {\n\t\t\tconst result = await this.git.run<T>(opts, ...params);\n\t\t\treturn result.stdout;\n\t\t} catch (ex) {\n\t\t\tconst msg: string = ex?.toString() ?? '';\n\t\t\tif (rev === ':' && GitErrors.badRevision.test(msg)) {\n\t\t\t\treturn this.showContentCore<T>(repoPath, path, 'HEAD:', options);\n\t\t\t}\n\n\t\t\tconst error = getGitCommandError(\n\t\t\t\t'show',\n\t\t\t\tex,\n\t\t\t\treason =>\n\t\t\t\t\tnew ShowError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treason: reason ?? 'other',\n\t\t\t\t\t\t\trev: rev,\n\t\t\t\t\t\t\tpath: path,\n\t\t\t\t\t\t\tgitCommand: { repoPath: repoPath ?? '', args: params },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tex,\n\t\t\t\t\t),\n\t\t\t);\n\t\t\tif (options?.errors === 'throw') throw error;\n\n\t\t\tif (\n\t\t\t\tShowError.is(error, 'invalidObject') ||\n\t\t\t\tShowError.is(error, 'invalidRevision') ||\n\t\t\t\tShowError.is(error, 'notFound') ||\n\t\t\t\tShowError.is(error, 'notInRevision')\n\t\t\t) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tdefaultExceptionHandler(ex, opts.cwd);\n\t\t\treturn '' as T;\n\t\t}\n\t}\n\n\t@debug({ args: (repoPath, shas) => ({ repoPath: repoPath, shas: `${shas.size} value(s)` }) })\n\tasync resolveShas(repoPath: string, shas: ReadonlySet<string>, cancellation?: AbortSignal): Promise<Set<string>> {\n\t\tconst resolved = new Set<string>();\n\t\tconst prefixes: string[] = [];\n\n\t\tfor (const value of shas) {\n\t\t\t// Pure hex 4-40 chars: resolve to full commit SHA(s) via disambiguation. Everything else\n\t\t\t// (refs, suffixed SHAs like `^`/`~1`/`:path`, non-hex, <4 hex) passes through unchanged.\n\t\t\tif (/^[0-9a-f]{4,40}$/i.test(value)) {\n\t\t\t\tprefixes.push(value);\n\t\t\t} else {\n\t\t\t\tresolved.add(value);\n\t\t\t}\n\t\t}\n\n\t\tif (prefixes.length) {\n\t\t\t// List every object (any type) whose id starts with any prefix (empty + exit 0 if none)\n\t\t\tconst rp = await this.git.run(\n\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'ignore' },\n\t\t\t\t'rev-parse',\n\t\t\t\t...prefixes.map(p => `--disambiguate=${p}`),\n\t\t\t);\n\t\t\tconst oids = rp.stdout.split('\\n').filter(Boolean);\n\t\t\tif (oids.length) {\n\t\t\t\t// `--disambiguate` has no type filter, so keep only commit objects\n\t\t\t\tconst cf = await this.git.run(\n\t\t\t\t\t{ cwd: repoPath, cancellation: cancellation, errors: 'ignore', stdin: `${oids.join('\\n')}\\n` },\n\t\t\t\t\t'cat-file',\n\t\t\t\t\t'--batch-check=%(objectname) %(objecttype)',\n\t\t\t\t);\n\t\t\t\tfor (const line of cf.stdout.split('\\n')) {\n\t\t\t\t\tconst [oid, type] = line.split(' ');\n\t\t\t\t\tif (type === 'commit') {\n\t\t\t\t\t\tresolved.add(oid);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn resolved;\n\t}\n\n\t@debug()\n\tasync resolveRevision(\n\t\trepoPath: string,\n\t\tref: string,\n\t\tpathOrUri?: string | Uri,\n\t\toptions?: { force?: boolean },\n\t): Promise<ResolvedRevision> {\n\t\tconst path = pathOrUri != null ? toFsPath(pathOrUri) : undefined;\n\t\tif (!ref || ref === deletedOrMissing) return { sha: ref, revision: ref };\n\n\t\tif (path == null) {\n\t\t\tif (isSha(ref)) return { sha: ref, revision: ref };\n\t\t\tif (ref.endsWith('^3')) return { sha: ref, revision: ref };\n\t\t} else if (isUncommitted(ref)) {\n\t\t\t// Uncommitted refs depend on index/working-tree state — resolve without caching\n\t\t\treturn this.resolveRevisionCore(repoPath, ref, path);\n\t\t}\n\n\t\tconst key = path != null ? `${ref}|${this.provider.getRelativePath(path, repoPath)}` : ref;\n\t\tif (options?.force) {\n\t\t\t// Hard-delete first: a later caller must never join a read that started before this one.\n\t\t\tthis.cache.resolvedRevisions.delete(repoPath, key);\n\t\t}\n\n\t\treturn this.cache.resolvedRevisions.getOrCreate(repoPath, key, () =>\n\t\t\tthis.resolveRevisionCore(repoPath, ref, path, options?.force),\n\t\t);\n\t}\n\n\tprivate async resolveRevisionCore(\n\t\trepoPath: string,\n\t\tref: string,\n\t\tpath: string | undefined,\n\t\tforce?: boolean,\n\t): Promise<ResolvedRevision> {\n\t\tif (path == null) {\n\t\t\tconst sha = await this.provider.refs.validateReference(repoPath, ref, force ? { force: true } : undefined);\n\t\t\tif (sha == null) return { sha: ref, revision: ref };\n\n\t\t\treturn {\n\t\t\t\tsha: sha,\n\t\t\t\t// If it looks like non-sha like then preserve it as the friendly name\n\t\t\t\trevision: isRevisionWithSuffix(ref) ? sha : ref,\n\t\t\t};\n\t\t}\n\n\t\tif (isUncommittedWithParentSuffix(ref)) {\n\t\t\tref = 'HEAD';\n\t\t}\n\t\tconst relativePath = this.provider.getRelativePath(path, repoPath);\n\n\t\tif (isUncommitted(ref)) {\n\t\t\tif (!isUncommittedStaged(ref)) {\n\t\t\t\treturn { sha: ref, revision: ref };\n\t\t\t}\n\n\t\t\t// Ensure that the file is actually staged\n\t\t\tconst status = await this.provider.status.getStatusForFile?.(repoPath, relativePath, { renames: false });\n\t\t\tif (status?.indexStatus) return { sha: ref, revision: ref };\n\n\t\t\tref = 'HEAD';\n\t\t}\n\n\t\tconst resolvedRevisionCaching = { cache: this.cache.gitResults, options: { accessTTL: 5 * 60 * 1000 } };\n\n\t\tconst parser = getShaAndFileSummaryLogParser();\n\t\tlet result = await this.git.run(\n\t\t\t// Forced here only: this read is keyed by `ref`, which can move; the follow-up below is keyed by a sha\n\t\t\t{ cwd: repoPath, errors: 'ignore', caching: { ...resolvedRevisionCaching, force: force } },\n\t\t\t'log',\n\t\t\t...parser.arguments,\n\t\t\t'-n1',\n\t\t\tref,\n\t\t\t'--',\n\t\t\trelativePath,\n\t\t);\n\n\t\tlet commit = first(parser.parse(result.stdout));\n\t\tlet file = commit?.files.find(f => f.path === relativePath);\n\t\tif (file == null) {\n\t\t\treturn {\n\t\t\t\tsha: commit?.sha ?? deletedOrMissing,\n\t\t\t\t// If it looks like non-sha like then preserve it as the friendly name\n\t\t\t\trevision: isRevisionWithSuffix(ref) ? (commit?.sha ?? ref) : ref,\n\t\t\t};\n\t\t}\n\n\t\tif (file.status === 'A') {\n\t\t\treturn {\n\t\t\t\tsha: commit?.sha ?? deletedOrMissing,\n\t\t\t\t// If it looks like non-sha like then preserve it as the friendly name\n\t\t\t\trevision: isRevisionWithSuffix(ref) ? (commit?.sha ?? ref) : ref,\n\t\t\t\tstatus: file.status as GitFileStatus,\n\t\t\t\toriginalPath: file.originalPath,\n\t\t\t};\n\t\t}\n\n\t\tif (file.status === 'D') {\n\t\t\t// If the file was deleted, check if it was moved or renamed\n\t\t\tresult = await this.git.run(\n\t\t\t\t{ cwd: repoPath, errors: 'ignore', caching: resolvedRevisionCaching },\n\t\t\t\t'log',\n\t\t\t\t...parser.arguments,\n\t\t\t\t'-n1',\n\n\t\t\t\tcommit!.sha,\n\t\t\t\t'--',\n\t\t\t);\n\n\t\t\tcommit = first(parser.parse(result.stdout));\n\t\t\tfile = commit?.files.find(f => f.path === relativePath || f.originalPath === relativePath);\n\t\t\tif (file == null) {\n\t\t\t\treturn {\n\t\t\t\t\tsha: commit?.sha ?? deletedOrMissing,\n\t\t\t\t\t// If it looks like non-sha like then preserve it as the friendly name\n\t\t\t\t\trevision: isRevisionWithSuffix(ref) ? (commit?.sha ?? ref) : ref,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tsha: commit?.sha ?? deletedOrMissing,\n\t\t\t\t// If it looks like non-sha like without a suffix then preserve it as the friendly name\n\t\t\t\trevision: isRevisionWithSuffix(ref) ? (commit?.sha ?? ref) : ref,\n\t\t\t\tstatus: file.status as GitFileStatus,\n\t\t\t\tpath: file.path,\n\t\t\t\toriginalPath: file.originalPath,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tsha: commit?.sha ?? deletedOrMissing,\n\t\t\t// If it looks like non-sha like then preserve it as the friendly name\n\t\t\trevision: isRevisionWithSuffix(ref) ? (commit?.sha ?? ref) : ref,\n\t\t\tstatus: file.status as GitFileStatus,\n\t\t\toriginalPath: file.originalPath,\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AA4BA,MAAM,aAAsC,OAAO,OAAO,CAAC,CAAC;AAE5D,IAAa,yBAAb,MAAsE;CAEnD;CACA;CACA;CACA;CAJlB,YACC,SACA,KACA,OACA,UACC;EAJgB,KAAA,UAAA;EACA,KAAA,MAAA;EACA,KAAA,QAAA;EACA,KAAA,WAAA;CACf;CAEH,OACC,UACA,MACA,cACmB;EACnB,IAAI;EACJ,IAAI;EACJ,IAAI,OAAO,iBAAiB,UAC3B,MAAM;OACA,IAAI,gBAAgB,MAC1B,YAAY,aAAa;EAG1B,MAAM,WAAW,GAAG,KAAK,IAAI,OAAO,GAAG,IAAI,aAAa;EACxD,OAAO,KAAK,MAAM,cAAc,YAAY,UAAU,UAAU,YAAY;GAC3E,MAAM,OAAO,CAAC,UAAU;GACxB,IAAI,KAAK;IACR,IAAI,CAAC,cAAc,GAAG,GACrB,KAAK,KAAK,eAAe,KAAK;SACxB,IAAI,oBAAoB,GAAG,GACjC,KAAK,KAAK,SAAS;GAErB,OAAO,IAAI,cAAc,QACxB,KAAK,KAAK,IAAI;QACR,IAAI,cAAc,WAExB,KAAK,KAAK,MAAM,IAAI;GAGrB,MAAM,SAAS,MAAM,KAAK,IAAI,IAAI;IAAE,KAAK;IAAU,QAAQ;GAAS,GAAG,GAAG,MAAM,MAAM,IAAI;GAC1F,OAAO,QAAQ,OAAO,OAAO,KAAK,CAAC;EACpC,CAAC;CACF;CAEA,mBAEmB,UAAkB,MAAc,KAA8C;EAChG,MAAM,CAAC,cAAc,QAAQ,UAAU,MAAM,QAAQ;EACrD,OAAO,KAAK,gBAAwB,MAAM,cAAc,KAAK;GAAE,UAAU;GAA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GACpB;EACD;EAEA,OAAO;GACN,KAAK,QAAQ,OAAA;GAEb,UAAU,qBAAqB,GAAG,IAAK,QAAQ,OAAO,MAAO;GAC7D,QAAQ,KAAK;GACb,cAAc,KAAK;EACpB;CACD;AACD;AAlUE,WAAA,CAAA,KAAK,GACL,MAAM,CAAA,GAAA,uBAAA,WAAA,sBAAA,IAAA;AAMN,WAAA,CAAA,MAAM,CAAA,GAAA,uBAAA,WAAA,oBAAA,IAAA;AAcN,WAAA,CAAA,KAAK,GACL,MAAM,CAAA,GAAA,uBAAA,WAAA,2BAAA,IAAA;AA8BN,WAAA,CAAA,MAAM,CAAA,GAAA,uBAAA,WAAA,mBAAA,IAAA;AAWN,WAAA,CAAA,MAAM,CAAA,GAAA,uBAAA,WAAA,sBAAA,IAAA;AAKN,WAAA,CAAA,KAAK,CAAA,GAAA,uBAAA,WAAA,0BAAA,IAAA;AA2EL,WAAA,CAAA,MAAM,EAAE,OAAO,UAAU,UAAU;CAAY;CAAU,MAAM,GAAG,KAAK,KAAK;AAAW,GAAG,CAAC,CAAA,GAAA,uBAAA,WAAA,eAAA,IAAA;AA0C3F,WAAA,CAAA,MAAM,CAAA,GAAA,uBAAA,WAAA,mBAAA,IAAA"}
@@ -29,6 +29,14 @@ export declare class StagingGitSubProvider implements GitStagingSubProvider {
29
29
  }): Promise<void>;
30
30
  stageAll(repoPath: string): Promise<void>;
31
31
  unstageAll(repoPath: string): Promise<void>;
32
+ clean(repoPath: string, options?: {
33
+ paths?: (string | Uri)[];
34
+ directories?: boolean;
35
+ force?: boolean;
36
+ ignored?: boolean;
37
+ }): Promise<void>;
38
+ /** What every index or working-tree mutation announces, so cached status is re-read and hosts are told. */
39
+ private announceIndexChanged;
32
40
  }
33
41
  //#endregion
34
42
  //# sourceMappingURL=staging.d.ts.map
@@ -8,8 +8,8 @@ import __decorate from "../../_virtual/@oxc-project+runtime/helpers/esm/decorate
8
8
  import { mixinAsyncDisposable } from "../../utils/disposable.js";
9
9
  import { maxGitCliLength } from "../exec/git.js";
10
10
  import * as l10n from "@vscode/l10n";
11
- import { tmpdir } from "os";
12
11
  import { promises } from "fs";
12
+ import { tmpdir } from "os";
13
13
  //#region ../git-cli/src/providers/staging.ts
14
14
  var StagingGitSubProvider = class {
15
15
  context;
@@ -72,6 +72,7 @@ var StagingGitSubProvider = class {
72
72
  }
73
73
  async stageFile(repoPath, pathOrUri) {
74
74
  await this.git.run({ cwd: repoPath }, "add", "-A", "--", toFsPath(pathOrUri));
75
+ this.announceIndexChanged(repoPath);
75
76
  }
76
77
  async stageFiles(repoPath, pathsOrUris, options) {
77
78
  const paths = pathsOrUris.map(toFsPath);
@@ -79,16 +80,22 @@ var StagingGitSubProvider = class {
79
80
  const avgPathLength = countStringLength(paths) / paths.length;
80
81
  const batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));
81
82
  const batches = chunk(paths, batchSize);
82
- for (const batch of batches) await this.git.run({
83
- cwd: repoPath,
84
- env: options?.index?.env
85
- }, "add", options?.intentToAdd ? "-N" : "-A", "--", ...batch);
83
+ try {
84
+ for (const batch of batches) await this.git.run({
85
+ cwd: repoPath,
86
+ env: options?.index?.env
87
+ }, "add", options?.intentToAdd ? "-N" : "-A", "--", ...batch);
88
+ } finally {
89
+ if (options?.index == null) this.announceIndexChanged(repoPath);
90
+ }
86
91
  }
87
92
  async stageDirectory(repoPath, directoryOrUri) {
88
93
  await this.git.run({ cwd: repoPath }, "add", "-A", "--", toFsPath(directoryOrUri));
94
+ this.announceIndexChanged(repoPath);
89
95
  }
90
96
  async unstageFile(repoPath, pathOrUri) {
91
97
  await this.git.run({ cwd: repoPath }, "reset", "-q", "--", toFsPath(pathOrUri));
98
+ this.announceIndexChanged(repoPath);
92
99
  }
93
100
  async unstageFiles(repoPath, pathsOrUris) {
94
101
  const paths = pathsOrUris.map(toFsPath);
@@ -96,16 +103,22 @@ var StagingGitSubProvider = class {
96
103
  const avgPathLength = countStringLength(paths) / paths.length;
97
104
  const batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));
98
105
  const batches = chunk(paths, batchSize);
99
- for (const batch of batches) await this.git.run({ cwd: repoPath }, "reset", "-q", "--", ...batch);
106
+ try {
107
+ for (const batch of batches) await this.git.run({ cwd: repoPath }, "reset", "-q", "--", ...batch);
108
+ } finally {
109
+ this.announceIndexChanged(repoPath);
110
+ }
100
111
  }
101
112
  async unstageDirectory(repoPath, directoryOrUri) {
102
113
  await this.git.run({ cwd: repoPath }, "reset", "-q", "--", toFsPath(directoryOrUri));
114
+ this.announceIndexChanged(repoPath);
103
115
  }
104
116
  async removeFile(repoPath, pathOrUri, options) {
105
117
  const args = ["rm"];
106
118
  if (options?.force) args.push("-f");
107
119
  args.push("--", toFsPath(pathOrUri));
108
120
  await this.git.run({ cwd: repoPath }, ...args);
121
+ this.announceIndexChanged(repoPath);
109
122
  }
110
123
  async removeFiles(repoPath, pathsOrUris, options) {
111
124
  const paths = pathsOrUris.map(toFsPath);
@@ -116,13 +129,51 @@ var StagingGitSubProvider = class {
116
129
  const avgPathLength = countStringLength(paths) / paths.length;
117
130
  const batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));
118
131
  const batches = chunk(paths, batchSize);
119
- for (const batch of batches) await this.git.run({ cwd: repoPath }, ...args, ...batch);
132
+ try {
133
+ for (const batch of batches) await this.git.run({ cwd: repoPath }, ...args, ...batch);
134
+ } finally {
135
+ this.announceIndexChanged(repoPath);
136
+ }
120
137
  }
121
138
  async stageAll(repoPath) {
122
139
  await this.git.run({ cwd: repoPath }, "add", "-A");
140
+ this.announceIndexChanged(repoPath);
123
141
  }
124
142
  async unstageAll(repoPath) {
125
143
  await this.git.run({ cwd: repoPath }, "reset", "-q");
144
+ this.announceIndexChanged(repoPath);
145
+ }
146
+ async clean(repoPath, options) {
147
+ const args = ["clean"];
148
+ if (options?.force ?? true) args.push("-f");
149
+ if (options?.directories) args.push("-d");
150
+ if (options?.ignored) args.push("-x");
151
+ if (options?.paths == null) {
152
+ await this.git.run({
153
+ cwd: repoPath,
154
+ errors: "throw"
155
+ }, ...args);
156
+ this.announceIndexChanged(repoPath);
157
+ return;
158
+ }
159
+ const paths = options.paths.map(toFsPath);
160
+ if (!paths.length) return;
161
+ const avgPathLength = countStringLength(paths) / paths.length;
162
+ const batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));
163
+ const batches = chunk(paths, batchSize);
164
+ try {
165
+ for (const batch of batches) await this.git.run({
166
+ cwd: repoPath,
167
+ errors: "throw"
168
+ }, ...args, "--", ...batch);
169
+ } finally {
170
+ this.announceIndexChanged(repoPath);
171
+ }
172
+ }
173
+ /** What every index or working-tree mutation announces, so cached status is re-read and hosts are told. */
174
+ announceIndexChanged(repoPath) {
175
+ this.context.hooks?.cache?.onReset?.(repoPath, "status", "diff", "tracking");
176
+ this.context.hooks?.repository?.onChanged?.(repoPath, ["index"]);
126
177
  }
127
178
  };
128
179
  __decorate([debug()], StagingGitSubProvider.prototype, "createTemporaryIndex", null);
@@ -136,6 +187,7 @@ __decorate([debug()], StagingGitSubProvider.prototype, "removeFile", null);
136
187
  __decorate([debug()], StagingGitSubProvider.prototype, "removeFiles", null);
137
188
  __decorate([debug()], StagingGitSubProvider.prototype, "stageAll", null);
138
189
  __decorate([debug()], StagingGitSubProvider.prototype, "unstageAll", null);
190
+ __decorate([debug()], StagingGitSubProvider.prototype, "clean", null);
139
191
  //#endregion
140
192
  export { StagingGitSubProvider };
141
193
 
@@ -1 +1 @@
1
- {"version":3,"file":"staging.js","names":["fs"],"sources":["../../../../git-cli/src/providers/staging.ts"],"sourcesContent":["import { promises as fs } from 'fs';\nimport { tmpdir } from 'os';\nimport * as l10n from '@vscode/l10n';\nimport type { Cache } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport type { DisposableTemporaryGitIndex, GitStagingSubProvider } from '@gitlens/git/providers/staging.js';\nimport { countStringLength } from '@gitlens/utils/array.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport { mixinAsyncDisposable } from '@gitlens/utils/disposable.js';\nimport { chunk } from '@gitlens/utils/iterable.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { joinPaths } from '@gitlens/utils/path.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\nimport { toFsPath } from '@gitlens/utils/uri.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport type { Git } from '../exec/git.js';\nimport { maxGitCliLength } from '../exec/git.js';\n\nexport class StagingGitSubProvider implements GitStagingSubProvider {\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) {}\n\n\t@debug()\n\tasync createTemporaryIndex(\n\t\trepoPath: string,\n\t\tfrom: 'empty' | 'current' | 'ref',\n\t\tref?: string,\n\t): Promise<DisposableTemporaryGitIndex> {\n\t\tconst scope = getScopedLogger();\n\n\t\t// Create a temporary index file\n\t\tconst tempDir = await fs.mkdtemp(joinPaths(tmpdir(), 'gl-'));\n\t\tconst tempIndex = joinPaths(tempDir, 'index');\n\n\t\tasync function dispose() {\n\t\t\t// Delete the temporary index file\n\t\t\ttry {\n\t\t\t\tawait fs.rm(tempDir, { recursive: true });\n\t\t\t} catch {\n\t\t\t\t// ignore cleanup errors\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\t// Tell Git to use our soon to be created index file\n\t\t\tconst env = { GIT_INDEX_FILE: tempIndex };\n\n\t\t\tswitch (from) {\n\t\t\t\tcase 'empty':\n\t\t\t\t\t// Leave the temp index empty\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'current': {\n\t\t\t\t\t// Copy the current index to preserve staged state\n\t\t\t\t\tconst gitDir = await this.provider.config.getGitDir?.(repoPath);\n\t\t\t\t\tif (gitDir == null) throw new Error(l10n.t('Unable to determine git directory for {0}', repoPath));\n\n\t\t\t\t\tconst currentIndex = joinPaths(gitDir.uri.fsPath, 'index');\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait fs.copyFile(currentIndex, tempIndex);\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\t// A repo that has never staged anything has no index file yet; git reads a missing\n\t\t\t\t\t\t// `GIT_INDEX_FILE` as an empty index, which is what 'current' means there. Any other\n\t\t\t\t\t\t// failure is real — don't silently hand back an index claiming everything is deleted.\n\t\t\t\t\t\tif ((ex as NodeJS.ErrnoException)?.code !== 'ENOENT') throw ex;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 'ref': {\n\t\t\t\t\tif (ref == null) throw new Error(l10n.t(\"ref is required when from is 'ref'\"));\n\n\t\t\t\t\t// Create the temp index file from a base ref/sha\n\t\t\t\t\tconst newIndexResult = await this.git.run(\n\t\t\t\t\t\t{ cwd: repoPath, env: env },\n\t\t\t\t\t\t'ls-tree',\n\t\t\t\t\t\t'-z',\n\t\t\t\t\t\t'-r',\n\t\t\t\t\t\t'--full-name',\n\t\t\t\t\t\tref,\n\t\t\t\t\t);\n\n\t\t\t\t\tif (newIndexResult.stdout.trim()) {\n\t\t\t\t\t\t// Write the tree to our temp index\n\t\t\t\t\t\tawait this.git.run(\n\t\t\t\t\t\t\t{ cwd: repoPath, env: env, stdin: newIndexResult.stdout },\n\t\t\t\t\t\t\t'update-index',\n\t\t\t\t\t\t\t'-z',\n\t\t\t\t\t\t\t'--index-info',\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn mixinAsyncDisposable({ path: tempIndex, env: { GIT_INDEX_FILE: tempIndex } }, dispose);\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\n\t\t\tvoid dispose();\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t@debug()\n\tasync stageFile(repoPath: string, pathOrUri: string | Uri): Promise<void> {\n\t\tawait this.git.run({ cwd: repoPath }, 'add', '-A', '--', toFsPath(pathOrUri));\n\t}\n\n\t@debug()\n\tasync stageFiles(\n\t\trepoPath: string,\n\t\tpathsOrUris: (string | Uri)[],\n\t\toptions?: { intentToAdd?: boolean; index?: DisposableTemporaryGitIndex },\n\t): Promise<void> {\n\t\tconst paths = pathsOrUris.map(toFsPath);\n\t\tif (!paths.length) return;\n\n\t\t// Calculate a safe batch size based on average path length\n\t\tconst avgPathLength = countStringLength(paths) / paths.length;\n\t\tconst batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));\n\n\t\t// Process files in batches (will be a single batch if under the limit)\n\t\tconst batches = chunk(paths, batchSize);\n\t\tfor (const batch of batches) {\n\t\t\tawait this.git.run(\n\t\t\t\t{ cwd: repoPath, env: options?.index?.env },\n\t\t\t\t'add',\n\t\t\t\toptions?.intentToAdd ? '-N' : '-A',\n\t\t\t\t'--',\n\t\t\t\t...batch,\n\t\t\t);\n\t\t}\n\t}\n\n\t@debug()\n\tasync stageDirectory(repoPath: string, directoryOrUri: string | Uri): Promise<void> {\n\t\tawait this.git.run({ cwd: repoPath }, 'add', '-A', '--', toFsPath(directoryOrUri));\n\t}\n\n\t@debug()\n\tasync unstageFile(repoPath: string, pathOrUri: string | Uri): Promise<void> {\n\t\tawait this.git.run({ cwd: repoPath }, 'reset', '-q', '--', toFsPath(pathOrUri));\n\t}\n\n\t@debug()\n\tasync unstageFiles(repoPath: string, pathsOrUris: (string | Uri)[]): Promise<void> {\n\t\tconst paths = pathsOrUris.map(toFsPath);\n\t\tif (!paths.length) return;\n\n\t\t// Calculate a safe batch size based on average path length\n\t\tconst avgPathLength = countStringLength(paths) / paths.length;\n\t\tconst batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));\n\n\t\t// Process files in batches (will be a single batch if under the limit)\n\t\tconst batches = chunk(paths, batchSize);\n\t\tfor (const batch of batches) {\n\t\t\tawait this.git.run({ cwd: repoPath }, 'reset', '-q', '--', ...batch);\n\t\t}\n\t}\n\n\t@debug()\n\tasync unstageDirectory(repoPath: string, directoryOrUri: string | Uri): Promise<void> {\n\t\tawait this.git.run({ cwd: repoPath }, 'reset', '-q', '--', toFsPath(directoryOrUri));\n\t}\n\n\t@debug()\n\tasync removeFile(repoPath: string, pathOrUri: string | Uri, options?: { force?: boolean }): Promise<void> {\n\t\tconst args = ['rm'];\n\t\tif (options?.force) {\n\t\t\targs.push('-f');\n\t\t}\n\t\targs.push('--', toFsPath(pathOrUri));\n\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t}\n\n\t@debug()\n\tasync removeFiles(repoPath: string, pathsOrUris: (string | Uri)[], options?: { force?: boolean }): Promise<void> {\n\t\tconst paths = pathsOrUris.map(toFsPath);\n\t\tif (!paths.length) return;\n\n\t\tconst args: string[] = ['rm'];\n\t\tif (options?.force) {\n\t\t\targs.push('-f');\n\t\t}\n\t\targs.push('--');\n\n\t\t// Calculate a safe batch size based on average path length\n\t\tconst avgPathLength = countStringLength(paths) / paths.length;\n\t\tconst batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));\n\n\t\t// Process files in batches (will be a single batch if under the limit)\n\t\tconst batches = chunk(paths, batchSize);\n\t\tfor (const batch of batches) {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args, ...batch);\n\t\t}\n\t}\n\n\t@debug()\n\tasync stageAll(repoPath: string): Promise<void> {\n\t\tawait this.git.run({ cwd: repoPath }, 'add', '-A');\n\t}\n\n\t@debug()\n\tasync unstageAll(repoPath: string): Promise<void> {\n\t\tawait this.git.run({ cwd: repoPath }, 'reset', '-q');\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAkBA,IAAa,wBAAb,MAAoE;CAEjD;CACA;CACA;CACA;CAJlB,YACC,SACA,KACA,OACA,UACC;EAJgB,KAAA,UAAA;EACA,KAAA,MAAA;EACA,KAAA,QAAA;EACA,KAAA,WAAA;CACf;CAEH,MACM,qBACL,UACA,MACA,KACuC;EACvC,MAAM,QAAQ,gBAAgB;EAG9B,MAAM,UAAU,MAAMA,SAAG,QAAQ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A,IAAA;AAKN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,cAAA,IAAA;AAUN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,eAAA,IAAA;AAsBN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,YAAA,IAAA;AAKN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,cAAA,IAAA"}
1
+ {"version":3,"file":"staging.js","names":["fs"],"sources":["../../../../git-cli/src/providers/staging.ts"],"sourcesContent":["import { promises as fs } from 'fs';\nimport { tmpdir } from 'os';\nimport * as l10n from '@vscode/l10n';\nimport type { Cache } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport type { DisposableTemporaryGitIndex, GitStagingSubProvider } from '@gitlens/git/providers/staging.js';\nimport { countStringLength } from '@gitlens/utils/array.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport { mixinAsyncDisposable } from '@gitlens/utils/disposable.js';\nimport { chunk } from '@gitlens/utils/iterable.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { joinPaths } from '@gitlens/utils/path.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\nimport { toFsPath } from '@gitlens/utils/uri.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport type { Git } from '../exec/git.js';\nimport { maxGitCliLength } from '../exec/git.js';\n\nexport class StagingGitSubProvider implements GitStagingSubProvider {\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) {}\n\n\t@debug()\n\tasync createTemporaryIndex(\n\t\trepoPath: string,\n\t\tfrom: 'empty' | 'current' | 'ref',\n\t\tref?: string,\n\t): Promise<DisposableTemporaryGitIndex> {\n\t\tconst scope = getScopedLogger();\n\n\t\t// Create a temporary index file\n\t\tconst tempDir = await fs.mkdtemp(joinPaths(tmpdir(), 'gl-'));\n\t\tconst tempIndex = joinPaths(tempDir, 'index');\n\n\t\tasync function dispose() {\n\t\t\t// Delete the temporary index file\n\t\t\ttry {\n\t\t\t\tawait fs.rm(tempDir, { recursive: true });\n\t\t\t} catch {\n\t\t\t\t// ignore cleanup errors\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\t// Tell Git to use our soon to be created index file\n\t\t\tconst env = { GIT_INDEX_FILE: tempIndex };\n\n\t\t\tswitch (from) {\n\t\t\t\tcase 'empty':\n\t\t\t\t\t// Leave the temp index empty\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'current': {\n\t\t\t\t\t// Copy the current index to preserve staged state\n\t\t\t\t\tconst gitDir = await this.provider.config.getGitDir?.(repoPath);\n\t\t\t\t\tif (gitDir == null) throw new Error(l10n.t('Unable to determine git directory for {0}', repoPath));\n\n\t\t\t\t\tconst currentIndex = joinPaths(gitDir.uri.fsPath, 'index');\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait fs.copyFile(currentIndex, tempIndex);\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\t// A repo that has never staged anything has no index file yet; git reads a missing\n\t\t\t\t\t\t// `GIT_INDEX_FILE` as an empty index, which is what 'current' means there. Any other\n\t\t\t\t\t\t// failure is real — don't silently hand back an index claiming everything is deleted.\n\t\t\t\t\t\tif ((ex as NodeJS.ErrnoException)?.code !== 'ENOENT') throw ex;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 'ref': {\n\t\t\t\t\tif (ref == null) throw new Error(l10n.t(\"ref is required when from is 'ref'\"));\n\n\t\t\t\t\t// Create the temp index file from a base ref/sha\n\t\t\t\t\tconst newIndexResult = await this.git.run(\n\t\t\t\t\t\t{ cwd: repoPath, env: env },\n\t\t\t\t\t\t'ls-tree',\n\t\t\t\t\t\t'-z',\n\t\t\t\t\t\t'-r',\n\t\t\t\t\t\t'--full-name',\n\t\t\t\t\t\tref,\n\t\t\t\t\t);\n\n\t\t\t\t\tif (newIndexResult.stdout.trim()) {\n\t\t\t\t\t\t// Write the tree to our temp index\n\t\t\t\t\t\tawait this.git.run(\n\t\t\t\t\t\t\t{ cwd: repoPath, env: env, stdin: newIndexResult.stdout },\n\t\t\t\t\t\t\t'update-index',\n\t\t\t\t\t\t\t'-z',\n\t\t\t\t\t\t\t'--index-info',\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn mixinAsyncDisposable({ path: tempIndex, env: { GIT_INDEX_FILE: tempIndex } }, dispose);\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\n\t\t\tvoid dispose();\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t@debug()\n\tasync stageFile(repoPath: string, pathOrUri: string | Uri): Promise<void> {\n\t\tawait this.git.run({ cwd: repoPath }, 'add', '-A', '--', toFsPath(pathOrUri));\n\t\tthis.announceIndexChanged(repoPath);\n\t}\n\n\t@debug()\n\tasync stageFiles(\n\t\trepoPath: string,\n\t\tpathsOrUris: (string | Uri)[],\n\t\toptions?: { intentToAdd?: boolean; index?: DisposableTemporaryGitIndex },\n\t): Promise<void> {\n\t\tconst paths = pathsOrUris.map(toFsPath);\n\t\tif (!paths.length) return;\n\n\t\t// Calculate a safe batch size based on average path length\n\t\tconst avgPathLength = countStringLength(paths) / paths.length;\n\t\tconst batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));\n\n\t\t// Process files in batches (will be a single batch if under the limit)\n\t\tconst batches = chunk(paths, batchSize);\n\t\ttry {\n\t\t\tfor (const batch of batches) {\n\t\t\t\tawait this.git.run(\n\t\t\t\t\t{ cwd: repoPath, env: options?.index?.env },\n\t\t\t\t\t'add',\n\t\t\t\t\toptions?.intentToAdd ? '-N' : '-A',\n\t\t\t\t\t'--',\n\t\t\t\t\t...batch,\n\t\t\t\t);\n\t\t\t}\n\t\t} finally {\n\t\t\t// Announced even when a later batch fails, since the earlier ones already changed the index. A\n\t\t\t// temporary index (used for partial-stage previews / diff building) is not the repository's real\n\t\t\t// index — firing repo-change hooks for it would invalidate status caches for a mutation nothing\n\t\t\t// else can observe.\n\t\t\tif (options?.index == null) {\n\t\t\t\tthis.announceIndexChanged(repoPath);\n\t\t\t}\n\t\t}\n\t}\n\n\t@debug()\n\tasync stageDirectory(repoPath: string, directoryOrUri: string | Uri): Promise<void> {\n\t\tawait this.git.run({ cwd: repoPath }, 'add', '-A', '--', toFsPath(directoryOrUri));\n\t\tthis.announceIndexChanged(repoPath);\n\t}\n\n\t@debug()\n\tasync unstageFile(repoPath: string, pathOrUri: string | Uri): Promise<void> {\n\t\tawait this.git.run({ cwd: repoPath }, 'reset', '-q', '--', toFsPath(pathOrUri));\n\t\tthis.announceIndexChanged(repoPath);\n\t}\n\n\t@debug()\n\tasync unstageFiles(repoPath: string, pathsOrUris: (string | Uri)[]): Promise<void> {\n\t\tconst paths = pathsOrUris.map(toFsPath);\n\t\tif (!paths.length) return;\n\n\t\t// Calculate a safe batch size based on average path length\n\t\tconst avgPathLength = countStringLength(paths) / paths.length;\n\t\tconst batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));\n\n\t\t// Process files in batches (will be a single batch if under the limit)\n\t\tconst batches = chunk(paths, batchSize);\n\t\ttry {\n\t\t\tfor (const batch of batches) {\n\t\t\t\tawait this.git.run({ cwd: repoPath }, 'reset', '-q', '--', ...batch);\n\t\t\t}\n\t\t} finally {\n\t\t\t// Even when a later batch fails, the earlier ones already changed the index\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync unstageDirectory(repoPath: string, directoryOrUri: string | Uri): Promise<void> {\n\t\tawait this.git.run({ cwd: repoPath }, 'reset', '-q', '--', toFsPath(directoryOrUri));\n\t\tthis.announceIndexChanged(repoPath);\n\t}\n\n\t@debug()\n\tasync removeFile(repoPath: string, pathOrUri: string | Uri, options?: { force?: boolean }): Promise<void> {\n\t\tconst args = ['rm'];\n\t\tif (options?.force) {\n\t\t\targs.push('-f');\n\t\t}\n\t\targs.push('--', toFsPath(pathOrUri));\n\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\t\tthis.announceIndexChanged(repoPath);\n\t}\n\n\t@debug()\n\tasync removeFiles(repoPath: string, pathsOrUris: (string | Uri)[], options?: { force?: boolean }): Promise<void> {\n\t\tconst paths = pathsOrUris.map(toFsPath);\n\t\tif (!paths.length) return;\n\n\t\tconst args: string[] = ['rm'];\n\t\tif (options?.force) {\n\t\t\targs.push('-f');\n\t\t}\n\t\targs.push('--');\n\n\t\t// Calculate a safe batch size based on average path length\n\t\tconst avgPathLength = countStringLength(paths) / paths.length;\n\t\tconst batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));\n\n\t\t// Process files in batches (will be a single batch if under the limit)\n\t\tconst batches = chunk(paths, batchSize);\n\t\ttry {\n\t\t\tfor (const batch of batches) {\n\t\t\t\tawait this.git.run({ cwd: repoPath }, ...args, ...batch);\n\t\t\t}\n\t\t} finally {\n\t\t\t// Even when a later batch fails, the earlier ones already changed the index\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync stageAll(repoPath: string): Promise<void> {\n\t\tawait this.git.run({ cwd: repoPath }, 'add', '-A');\n\t\tthis.announceIndexChanged(repoPath);\n\t}\n\n\t@debug()\n\tasync unstageAll(repoPath: string): Promise<void> {\n\t\tawait this.git.run({ cwd: repoPath }, 'reset', '-q');\n\t\tthis.announceIndexChanged(repoPath);\n\t}\n\n\t@debug()\n\tasync clean(\n\t\trepoPath: string,\n\t\toptions?: {\n\t\t\tpaths?: (string | Uri)[];\n\t\t\tdirectories?: boolean;\n\t\t\tforce?: boolean;\n\t\t\tignored?: boolean;\n\t\t},\n\t): Promise<void> {\n\t\tconst args = ['clean'];\n\t\tif (options?.force ?? true) {\n\t\t\targs.push('-f');\n\t\t}\n\t\tif (options?.directories) {\n\t\t\targs.push('-d');\n\t\t}\n\t\tif (options?.ignored) {\n\t\t\targs.push('-x');\n\t\t}\n\n\t\tif (options?.paths == null) {\n\t\t\tawait this.git.run({ cwd: repoPath, errors: 'throw' }, ...args);\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t\treturn;\n\t\t}\n\n\t\tconst paths = options.paths.map(toFsPath);\n\t\tif (!paths.length) return;\n\n\t\t// Calculate a safe batch size based on average path length\n\t\tconst avgPathLength = countStringLength(paths) / paths.length;\n\t\tconst batchSize = Math.max(1, Math.floor(maxGitCliLength / avgPathLength));\n\n\t\t// Process paths in batches (will be a single batch if under the limit)\n\t\tconst batches = chunk(paths, batchSize);\n\t\ttry {\n\t\t\tfor (const batch of batches) {\n\t\t\t\tawait this.git.run({ cwd: repoPath, errors: 'throw' }, ...args, '--', ...batch);\n\t\t\t}\n\t\t} finally {\n\t\t\t// Even when a later batch fails, the earlier ones already removed files\n\t\t\tthis.announceIndexChanged(repoPath);\n\t\t}\n\t}\n\n\t/** What every index or working-tree mutation announces, so cached status is re-read and hosts are told. */\n\tprivate announceIndexChanged(repoPath: string): void {\n\t\t// `diff` and `tracking` too, as a watcher-observed index change clears them: a file's working-vs-index\n\t\t// diff and whether it is tracked both change when it is staged, unstaged or removed\n\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'status', 'diff', 'tracking');\n\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['index']);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAkBA,IAAa,wBAAb,MAAoE;CAEjD;CACA;CACA;CACA;CAJlB,YACC,SACA,KACA,OACA,UACC;EAJgB,KAAA,UAAA;EACA,KAAA,MAAA;EACA,KAAA,QAAA;EACA,KAAA,WAAA;CACf;CAEH,MACM,qBACL,UACA,MACA,KACuC;EACvC,MAAM,QAAQ,gBAAgB;EAG9B,MAAM,UAAU,MAAMA,SAAG,QAAQ,UAAU,OAAO,GAAG,KAAK,CAAC;EAC3D,MAAM,YAAY,UAAU,SAAS,OAAO;EAE5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N,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,cAAA,IAAA;AAWN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,eAAA,IAAA;AA2BN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,YAAA,IAAA;AAMN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,cAAA,IAAA;AAMN,WAAA,CAAA,MAAM,CAAA,GAAA,sBAAA,WAAA,SAAA,IAAA"}
@@ -2,6 +2,7 @@ import { Uri } from "../../utils/uri.js";
2
2
  import { GitServiceContext } from "../../git/context.js";
3
3
  import { GitWorktree } from "../../git/models/worktree.js";
4
4
  import { Cache } from "../../git/cache.js";
5
+ import { GitOperationRunOptions } from "../../git/providers/operations.js";
5
6
  import { GitWorktreesSubProvider } from "../../git/providers/worktrees.js";
6
7
  import { Git } from "../exec/git.js";
7
8
  import { CliGitProviderInternal } from "../cliGitProvider.js";
@@ -12,25 +13,53 @@ export declare class WorktreesGitSubProvider implements GitWorktreesSubProvider
12
13
  private readonly cache;
13
14
  private readonly provider;
14
15
  constructor(context: GitServiceContext, git: Git, cache: Cache, provider: CliGitProviderInternal);
16
+ /**
17
+ * Creates a worktree (`git worktree add`). `runOptions` are spread into the underlying `git.run` call, so a
18
+ * large checkout can run without the default command timeout (`{ timeout: 0 }`) and still be cancelled.
19
+ */
15
20
  createWorktree(repoPath: string, path: string, options?: {
16
21
  commitish?: string;
17
22
  createBranch?: string;
18
23
  detach?: boolean;
19
24
  force?: boolean;
20
25
  noTracking?: boolean;
21
- }): Promise<void>;
26
+ }, runOptions?: GitOperationRunOptions): Promise<void>;
22
27
  createWorktreeWithResult(repoPath: string, path: string, options?: {
23
28
  commitish?: string;
24
29
  createBranch?: string;
25
30
  detach?: boolean;
26
31
  force?: boolean;
27
32
  noTracking?: boolean;
28
- }): Promise<GitWorktree | undefined>;
33
+ }, runOptions?: GitOperationRunOptions): Promise<GitWorktree | undefined>;
29
34
  getWorktree(repoPath: string, predicate: (w: GitWorktree) => boolean, cancellation?: AbortSignal): Promise<GitWorktree | undefined>;
30
35
  getWorktrees(repoPath: string, cancellation?: AbortSignal): Promise<GitWorktree[]>;
31
36
  getWorktreesDefaultUri(repoPath: string): Uri | undefined;
37
+ /**
38
+ * Deletes a worktree (`git worktree remove`). Pass `force: 'locked'` to also override a locked worktree.
39
+ *
40
+ * `runOptions` are spread into the underlying `git.run` call (e.g. `{ timeout: 0 }` for a large worktree
41
+ * whose removal may exceed the default command timeout).
42
+ *
43
+ * On failure, the thrown {@link WorktreeDeleteError}'s `original` property carries the raw
44
+ * {@link GitError} (stderr/stdout/exit code) untouched — a caller that needs to classify a
45
+ * platform-specific failure (e.g. a Windows file-lock retry) can read it directly rather than parsing
46
+ * the typed error's message.
47
+ */
32
48
  deleteWorktree(repoPath: string, path: string | Uri, options?: {
33
49
  force?: boolean | 'locked';
50
+ }, runOptions?: GitOperationRunOptions): Promise<void>;
51
+ pruneWorktrees(repoPath: string, options?: {
52
+ expire?: string;
53
+ }): Promise<void>;
54
+ /**
55
+ * Raw worktree paths currently known to git (`worktree <path>` lines from `--porcelain`), normalized the
56
+ * same way {@link deleteWorktree} does. A failed listing (`errors: 'ignore'`) yields an empty set rather
57
+ * than throwing — used by `pruneWorktrees` to diff before/after, where a transient read failure must not
58
+ * be mistaken for every worktree having vanished.
59
+ */
60
+ private listWorktreePaths;
61
+ lockWorktree(repoPath: string, path: string | Uri, options?: {
62
+ reason?: string;
34
63
  }): Promise<void>;
35
64
  unlockWorktree(repoPath: string, path: string | Uri): Promise<void>;
36
65
  }
@@ -1,3 +1,4 @@
1
+ import { isCancellationError } from "../../utils/cancellation.js";
1
2
  import { getScopedLogger } from "../../utils/logger.scoped.js";
2
3
  import { getSettledValue } from "../../utils/promise.js";
3
4
  import { debug } from "../../utils/decorators/log.js";
@@ -27,7 +28,11 @@ var WorktreesGitSubProvider = class {
27
28
  this.cache = cache;
28
29
  this.provider = provider;
29
30
  }
30
- async createWorktree(repoPath, path, options) {
31
+ /**
32
+ * Creates a worktree (`git worktree add`). `runOptions` are spread into the underlying `git.run` call, so a
33
+ * large checkout can run without the default command timeout (`{ timeout: 0 }`) and still be cancelled.
34
+ */
35
+ async createWorktree(repoPath, path, options, runOptions) {
31
36
  const scope = getScopedLogger();
32
37
  const args = ["worktree", "add"];
33
38
  if (options?.force) args.push("--force");
@@ -37,12 +42,16 @@ var WorktreesGitSubProvider = class {
37
42
  args.push(path);
38
43
  if (options?.commitish) args.push(options.commitish);
39
44
  try {
40
- await this.git.run({ cwd: repoPath }, ...args);
45
+ await this.git.run({
46
+ cwd: repoPath,
47
+ ...runOptions
48
+ }, ...args);
41
49
  if (options?.createBranch) this.cache.deleteBaseBranchName(repoPath, options.createBranch);
42
50
  this.context.hooks?.cache?.onReset?.(repoPath, ...options?.createBranch ? ["branches", "worktrees"] : ["worktrees"]);
43
51
  this.context.hooks?.repository?.onChanged?.(repoPath, options?.createBranch ? ["worktrees", "heads"] : ["worktrees"]);
44
52
  } catch (ex) {
45
53
  scope?.error(ex);
54
+ if (isCancellationError(ex)) throw ex;
46
55
  throw getGitCommandError("worktree-create", ex, (reason) => new WorktreeCreateError({
47
56
  reason,
48
57
  gitCommand: {
@@ -52,10 +61,10 @@ var WorktreesGitSubProvider = class {
52
61
  }, ex));
53
62
  }
54
63
  }
55
- async createWorktreeWithResult(repoPath, path, options) {
56
- await this.createWorktree(repoPath, path, options);
64
+ async createWorktreeWithResult(repoPath, path, options, runOptions) {
65
+ await this.createWorktree(repoPath, path, options, runOptions);
57
66
  const normalized = normalizePath(path);
58
- return this.getWorktree(repoPath, (w) => normalizePath(w.path) === normalized);
67
+ return this.getWorktree(repoPath, (w) => normalizePath(w.path) === normalized, runOptions?.cancellation);
59
68
  }
60
69
  async getWorktree(repoPath, predicate, cancellation) {
61
70
  return (await this.getWorktrees(repoPath, cancellation)).find(predicate);
@@ -83,7 +92,18 @@ var WorktreesGitSubProvider = class {
83
92
  getWorktreesDefaultUri(repoPath) {
84
93
  return this.context.workspace?.getWorktreeDefaultUri?.(repoPath);
85
94
  }
86
- async deleteWorktree(repoPath, path, options) {
95
+ /**
96
+ * Deletes a worktree (`git worktree remove`). Pass `force: 'locked'` to also override a locked worktree.
97
+ *
98
+ * `runOptions` are spread into the underlying `git.run` call (e.g. `{ timeout: 0 }` for a large worktree
99
+ * whose removal may exceed the default command timeout).
100
+ *
101
+ * On failure, the thrown {@link WorktreeDeleteError}'s `original` property carries the raw
102
+ * {@link GitError} (stderr/stdout/exit code) untouched — a caller that needs to classify a
103
+ * platform-specific failure (e.g. a Windows file-lock retry) can read it directly rather than parsing
104
+ * the typed error's message.
105
+ */
106
+ async deleteWorktree(repoPath, path, options, runOptions) {
87
107
  const scope = getScopedLogger();
88
108
  await this.git.ensureSupports("git:worktrees", (requiredVersion, installedVersion) => l10n.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.", requiredVersion, installedVersion));
89
109
  const args = ["worktree", "remove"];
@@ -97,11 +117,13 @@ var WorktreesGitSubProvider = class {
97
117
  try {
98
118
  await this.git.run({
99
119
  cwd: repoPath,
100
- errors: "throw"
120
+ errors: "throw",
121
+ ...runOptions
101
122
  }, ...args);
102
123
  deleted = true;
103
124
  } catch (ex) {
104
125
  scope?.error(ex);
126
+ if (isCancellationError(ex)) throw ex;
105
127
  const gitError = getGitCommandError("worktree-delete", ex, (reason) => new WorktreeDeleteError({
106
128
  reason,
107
129
  lockReason: reason === "locked" ? getLockReason(ex) : void 0,
@@ -160,6 +182,50 @@ var WorktreesGitSubProvider = class {
160
182
  }
161
183
  }
162
184
  }
185
+ async pruneWorktrees(repoPath, options) {
186
+ await this.git.ensureSupports("git:worktrees", (requiredVersion, installedVersion) => l10n.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.", requiredVersion, installedVersion));
187
+ const before = await this.listWorktreePaths(repoPath);
188
+ const args = ["worktree", "prune"];
189
+ if (options?.expire) args.push("--expire", options.expire);
190
+ await this.git.run({
191
+ cwd: repoPath,
192
+ errors: "throw"
193
+ }, ...args);
194
+ const after = await this.listWorktreePaths(repoPath);
195
+ if (before != null && after != null) {
196
+ for (const path of before) if (!after.has(path)) this.cache.unregisterRepoPath(path);
197
+ }
198
+ this.context.hooks?.cache?.onReset?.(repoPath, "worktrees");
199
+ this.context.hooks?.repository?.onChanged?.(repoPath, ["worktrees"]);
200
+ }
201
+ /**
202
+ * Raw worktree paths currently known to git (`worktree <path>` lines from `--porcelain`), normalized the
203
+ * same way {@link deleteWorktree} does. A failed listing (`errors: 'ignore'`) yields an empty set rather
204
+ * than throwing — used by `pruneWorktrees` to diff before/after, where a transient read failure must not
205
+ * be mistaken for every worktree having vanished.
206
+ */
207
+ async listWorktreePaths(repoPath) {
208
+ const result = await this.git.run({
209
+ cwd: repoPath,
210
+ errors: "ignore"
211
+ }, "worktree", "list", "--porcelain");
212
+ if (result.completion.status !== "exited" || result.exitCode !== 0) return void 0;
213
+ const paths = /* @__PURE__ */ new Set();
214
+ for (const line of result.stdout.split("\n")) if (line.startsWith("worktree ")) paths.add(normalizePath(toFsPath(line.slice(9).trim())));
215
+ return paths;
216
+ }
217
+ async lockWorktree(repoPath, path, options) {
218
+ await this.git.ensureSupports("git:worktrees", (requiredVersion, installedVersion) => l10n.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.", requiredVersion, installedVersion));
219
+ const args = ["worktree", "lock"];
220
+ if (options?.reason) args.push("--reason", options.reason);
221
+ args.push(normalizePath(toFsPath(path)));
222
+ await this.git.run({
223
+ cwd: repoPath,
224
+ errors: "throw"
225
+ }, ...args);
226
+ this.context.hooks?.cache?.onReset?.(repoPath, "worktrees");
227
+ this.context.hooks?.repository?.onChanged?.(repoPath, ["worktrees"]);
228
+ }
163
229
  async unlockWorktree(repoPath, path) {
164
230
  await this.git.ensureSupports("git:worktrees", (requiredVersion, installedVersion) => l10n.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.", requiredVersion, installedVersion));
165
231
  await this.git.run({
@@ -175,6 +241,8 @@ __decorate([debug()], WorktreesGitSubProvider.prototype, "getWorktree", null);
175
241
  __decorate([debug()], WorktreesGitSubProvider.prototype, "getWorktrees", null);
176
242
  __decorate([debug()], WorktreesGitSubProvider.prototype, "getWorktreesDefaultUri", null);
177
243
  __decorate([debug()], WorktreesGitSubProvider.prototype, "deleteWorktree", null);
244
+ __decorate([debug()], WorktreesGitSubProvider.prototype, "pruneWorktrees", null);
245
+ __decorate([debug()], WorktreesGitSubProvider.prototype, "lockWorktree", null);
178
246
  __decorate([debug()], WorktreesGitSubProvider.prototype, "unlockWorktree", null);
179
247
  //#endregion
180
248
  export { WorktreesGitSubProvider };
@@ -1 +1 @@
1
- {"version":3,"file":"worktrees.js","names":["fs"],"sources":["../../../../git-cli/src/providers/worktrees.ts"],"sourcesContent":["import { exec } from 'child_process';\nimport { promises as fs } from 'fs';\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 { GitWorktree, WorkspaceFolderResolver } from '@gitlens/git/models/worktree.js';\nimport type { GitWorktreesSubProvider } from '@gitlens/git/providers/worktrees.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, normalizePath } from '@gitlens/utils/path.js';\nimport { getSettledValue } from '@gitlens/utils/promise.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\nimport { fileUri, toFsPath } from '@gitlens/utils/uri.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport type { Git, GitError } from '../exec/git.js';\nimport { getGitCommandError, GitErrors } from '../exec/git.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\nexport class WorktreesGitSubProvider implements GitWorktreesSubProvider {\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) {}\n\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): 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\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, ...args);\n\n\t\t\tif (options?.createBranch) {\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, options.createBranch);\n\t\t\t}\n\n\t\t\tthis.context.hooks?.cache?.onReset?.(\n\t\t\t\trepoPath,\n\t\t\t\t...(options?.createBranch ? (['branches', 'worktrees'] as const) : (['worktrees'] as const)),\n\t\t\t);\n\t\t\tthis.context.hooks?.repository?.onChanged?.(\n\t\t\t\trepoPath,\n\t\t\t\toptions?.createBranch ? ['worktrees', 'heads'] : ['worktrees'],\n\t\t\t);\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\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}\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): Promise<GitWorktree | undefined> {\n\t\tawait this.createWorktree(repoPath, path, options);\n\t\tconst normalized = normalizePath(path);\n\t\treturn this.getWorktree(repoPath, w => normalizePath(w.path) === normalized);\n\t}\n\n\t@debug()\n\tasync getWorktree(\n\t\trepoPath: string,\n\t\tpredicate: (w: GitWorktree) => boolean,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitWorktree | undefined> {\n\t\treturn (await this.getWorktrees(repoPath, cancellation)).find(predicate);\n\t}\n\n\t@debug()\n\tasync getWorktrees(repoPath: string, cancellation?: AbortSignal): Promise<GitWorktree[]> {\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\treturn this.cache.getWorktrees(\n\t\t\trepoPath,\n\t\t\tasync (commonPath, cacheable, signal) => {\n\t\t\t\t// Prefer the aggregate signal from the cache; fall back to the caller's cancellation.\n\t\t\t\tsignal ??= cancellation;\n\t\t\t\tconst [dataResult, branchesResult] = await Promise.allSettled([\n\t\t\t\t\tthis.git.run({ cwd: commonPath, cancellation: signal }, 'worktree', 'list', '--porcelain'),\n\t\t\t\t\tthis.provider.branches.getBranches(commonPath, undefined, signal),\n\t\t\t\t]);\n\n\t\t\t\tif (dataResult.status === 'rejected') {\n\t\t\t\t\t// Don't cache a bogus empty result for a transient command failure — retry on next access.\n\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t}\n\n\t\t\t\tconst getWorkspaceFolder: WorkspaceFolderResolver | undefined = this.context.workspace\n\t\t\t\t\t? uri => {\n\t\t\t\t\t\t\tconst folder = this.context.workspace!.getFolder(uri.fsPath);\n\t\t\t\t\t\t\tif (folder == null) return undefined;\n\t\t\t\t\t\t\treturn { uri: fileUri(folder.path), name: basename(folder.path) };\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined;\n\n\t\t\t\treturn parseGitWorktrees(\n\t\t\t\t\tgetSettledValue(dataResult)?.stdout,\n\t\t\t\t\tcommonPath,\n\t\t\t\t\tgetSettledValue(branchesResult)?.values ?? [],\n\t\t\t\t\tgetWorkspaceFolder,\n\t\t\t\t);\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\t@debug()\n\tgetWorktreesDefaultUri(repoPath: string): Uri | undefined {\n\t\treturn this.context.workspace?.getWorktreeDefaultUri?.(repoPath);\n\t}\n\n\t@debug()\n\tasync deleteWorktree(\n\t\trepoPath: string,\n\t\tpath: string | Uri,\n\t\toptions?: { force?: boolean | 'locked' },\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' }, ...args);\n\t\t\tdeleted = true;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\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\tthis.context.hooks?.cache?.onReset?.(repoPath, 'worktrees');\n\t\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['worktrees']);\n\t\t\t}\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\tawait this.git.run({ cwd: repoPath, errors: 'throw' }, 'worktree', 'unlock', normalizePath(toFsPath(path)));\n\n\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'worktrees');\n\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['worktrees']);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,SAAS,cAAc,IAAkC;CACxD,OAAO,UAAU,qBAAqB,KAAK,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,KAAK,KAAA;AACvG;AAEA,IAAa,0BAAb,MAAwE;CAErD;CACA;CACA;CACA;CAJlB,YACC,SACA,KACA,OACA,UACC;EAJgB,KAAA,UAAA;EACA,KAAA,MAAA;EACA,KAAA,QAAA;EACA,KAAA,WAAA;CACf;CAEH,MACM,eACL,UACA,MACA,SAOgB;EAChB,MAAM,QAAQ,gBAAgB;EAE9B,MAAM,OAAO,CAAC,YAAY,KAAK;EAC/B,IAAI,SAAS,OACZ,KAAK,KAAK,SAAS;EAEpB,IAAI,SAAS,cACZ,KAAK,KAAK,MAAM,QAAQ,YAAY;EAErC,IAAI,SAAS,gBAAgB,QAAQ,YACpC,KAAK,KAAK,YAAY;EAEvB,IAAI,SAAS,QACZ,KAAK,KAAK,UAAU;EAErB,KAAK,KAAK,IAAI;EACd,IAAI,SAAS,WACZ,KAAK,KAAK,QAAQ,SAAS;EAG5B,IAAI;GACH,MAAM,KAAK,IAAI,IAAI,EAAE,KAAK,SAAS,GAAG,GAAG,IAAI;GAE7C,IAAI,SAAS,cAEZ,KAAK,MAAM,qBAAqB,UAA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A;AA8EN,WAAA,CAAA,MAAM,CAAA,GAAA,wBAAA,WAAA,eAAA,IAAA;AASN,WAAA,CAAA,MAAM,CAAA,GAAA,wBAAA,WAAA,gBAAA,IAAA;AA4CN,WAAA,CAAA,MAAM,CAAA,GAAA,wBAAA,WAAA,0BAAA,IAAA;AAKN,WAAA,CAAA,MAAM,CAAA,GAAA,wBAAA,WAAA,kBAAA,IAAA;AA2GN,WAAA,CAAA,MAAM,CAAA,GAAA,wBAAA,WAAA,kBAAA,IAAA"}
1
+ {"version":3,"file":"worktrees.js","names":["fs"],"sources":["../../../../git-cli/src/providers/worktrees.ts"],"sourcesContent":["import { exec } from 'child_process';\nimport { promises as fs } from 'fs';\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 { GitWorktree, WorkspaceFolderResolver } 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, normalizePath } from '@gitlens/utils/path.js';\nimport { getSettledValue } from '@gitlens/utils/promise.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\nimport { fileUri, toFsPath } from '@gitlens/utils/uri.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport type { Git, GitError } from '../exec/git.js';\nimport { getGitCommandError, GitErrors } from '../exec/git.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\nexport class WorktreesGitSubProvider implements GitWorktreesSubProvider {\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) {}\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\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath, ...runOptions }, ...args);\n\n\t\t\tif (options?.createBranch) {\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, options.createBranch);\n\t\t\t}\n\n\t\t\tthis.context.hooks?.cache?.onReset?.(\n\t\t\t\trepoPath,\n\t\t\t\t...(options?.createBranch ? (['branches', 'worktrees'] as const) : (['worktrees'] as const)),\n\t\t\t);\n\t\t\tthis.context.hooks?.repository?.onChanged?.(\n\t\t\t\trepoPath,\n\t\t\t\toptions?.createBranch ? ['worktrees', 'heads'] : ['worktrees'],\n\t\t\t);\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\t// A cancelled or timed-out checkout is not git refusing the worktree\n\t\t\tif (isCancellationError(ex)) throw ex;\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}\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(repoPath, w => normalizePath(w.path) === normalized, runOptions?.cancellation);\n\t}\n\n\t@debug()\n\tasync getWorktree(\n\t\trepoPath: string,\n\t\tpredicate: (w: GitWorktree) => boolean,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitWorktree | undefined> {\n\t\treturn (await this.getWorktrees(repoPath, cancellation)).find(predicate);\n\t}\n\n\t@debug()\n\tasync getWorktrees(repoPath: string, cancellation?: AbortSignal): Promise<GitWorktree[]> {\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\treturn this.cache.getWorktrees(\n\t\t\trepoPath,\n\t\t\tasync (commonPath, cacheable, signal) => {\n\t\t\t\t// Prefer the aggregate signal from the cache; fall back to the caller's cancellation.\n\t\t\t\tsignal ??= cancellation;\n\t\t\t\tconst [dataResult, branchesResult] = await Promise.allSettled([\n\t\t\t\t\tthis.git.run({ cwd: commonPath, cancellation: signal }, 'worktree', 'list', '--porcelain'),\n\t\t\t\t\tthis.provider.branches.getBranches(commonPath, undefined, signal),\n\t\t\t\t]);\n\n\t\t\t\tif (dataResult.status === 'rejected') {\n\t\t\t\t\t// Don't cache a bogus empty result for a transient command failure — retry on next access.\n\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t}\n\n\t\t\t\tconst getWorkspaceFolder: WorkspaceFolderResolver | undefined = this.context.workspace\n\t\t\t\t\t? uri => {\n\t\t\t\t\t\t\tconst folder = this.context.workspace!.getFolder(uri.fsPath);\n\t\t\t\t\t\t\tif (folder == null) return undefined;\n\t\t\t\t\t\t\treturn { uri: fileUri(folder.path), name: basename(folder.path) };\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined;\n\n\t\t\t\treturn parseGitWorktrees(\n\t\t\t\t\tgetSettledValue(dataResult)?.stdout,\n\t\t\t\t\tcommonPath,\n\t\t\t\t\tgetSettledValue(branchesResult)?.values ?? [],\n\t\t\t\t\tgetWorkspaceFolder,\n\t\t\t\t);\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\t@debug()\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`) is not git refusing it, and\n\t\t\t// wrapping it would hand the caller a `WorktreeDeleteError` whose `original` is no `GitError` at all\n\t\t\tif (isCancellationError(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\tthis.context.hooks?.cache?.onReset?.(repoPath, 'worktrees');\n\t\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['worktrees']);\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\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\tawait this.git.run({ cwd: repoPath, errors: 'throw' }, ...args);\n\n\t\tconst after = await this.listWorktreePaths(repoPath);\n\n\t\t// Order matters (see `deleteWorktree`): unregister before emitting the repo-level change so any\n\t\t// listener that re-queries worktree-aware state sees the registry already updated.\n\t\tif (before != null && after != null) {\n\t\t\tfor (const path of before) {\n\t\t\t\tif (!after.has(path)) {\n\t\t\t\t\tthis.cache.unregisterRepoPath(path);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'worktrees');\n\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['worktrees']);\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\tawait this.git.run({ cwd: repoPath, errors: 'throw' }, ...args);\n\n\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'worktrees');\n\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['worktrees']);\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\tawait this.git.run({ cwd: repoPath, errors: 'throw' }, 'worktree', 'unlock', normalizePath(toFsPath(path)));\n\n\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'worktrees');\n\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['worktrees']);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAuBA,SAAS,cAAc,IAAkC;CACxD,OAAO,UAAU,qBAAqB,KAAK,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,KAAK,KAAA;AACvG;AAEA,IAAa,0BAAb,MAAwE;CAErD;CACA;CACA;CACA;CAJlB,YACC,SACA,KACA,OACA,UACC;EAJgB,KAAA,UAAA;EACA,KAAA,MAAA;EACA,KAAA,QAAA;EACA,KAAA,WAAA;CACf;;;;;CAMH,MACM,eACL,UACA,MACA,SAOA,YACgB;EAChB,MAAM,QAAQ,gBAAgB;EAE9B,MAAM,OAAO,CAAC,YAAY,KAAK;EAC/B,IAAI,SAAS,OACZ,KAAK,KAAK,SAAS;EAEpB,IAAI,SAAS,cACZ,KAAK,KAAK,MAAM,QAAQ,YAAY;EAErC,IAAI,SAAS,gBAAgB,QAAQ,YACpC,KAAK,KAAK,YAAY;EAEvB,IAAI,SAAS,QACZ,KAAK,KAAK,UAAU;EAErB,KAAK,KAAK,IAAI;EACd,IAAI,SAAS,WACZ,KAAK,KAAK,QAAQ,SAAS;EAG5B,IAAI;GACH,MAAM,KAAK,IAAI,IAAI;IAAE,KAAK;I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AAO,OAAO,UAAU,UAAU,WAAW;EAC1D,KAAK,QAAQ,OAAO,YAAY,YAAY,UAAU,CAAC,WAAW,CAAC;CACpE;CAEA,MACM,eAAe,UAAkB,MAAmC;EACzE,MAAM,KAAK,IAAI,eAAe,kBAAkB,iBAAiB,qBAChE,KAAK,EACJ,8JACA,iBACA,gBACD,CACD;EAEA,MAAM,KAAK,IAAI,IAAI;GAAE,KAAK;GAAU,QAAQ;EAAQ,GAAG,YAAY,UAAU,cAAc,SAAS,IAAI,CAAC,CAAC;EAE1G,KAAK,QAAQ,OAAO,OAAO,UAAU,UAAU,WAAW;EAC1D,KAAK,QAAQ,OAAO,YAAY,YAAY,UAAU,CAAC,WAAW,CAAC;CACpE;AACD;AApWE,WAAA,CAAA,MAAM,CAAA,GAAA,wBAAA,WAAA,kBAAA,IAAA;AAmFN,WAAA,CAAA,MAAM,CAAA,GAAA,wBAAA,WAAA,eAAA,IAAA;AASN,WAAA,CAAA,MAAM,CAAA,GAAA,wBAAA,WAAA,gBAAA,IAAA;AA4CN,WAAA,CAAA,MAAM,CAAA,GAAA,wBAAA,WAAA,0BAAA,IAAA;AAgBN,WAAA,CAAA,MAAM,CAAA,GAAA,wBAAA,WAAA,kBAAA,IAAA;AAgHN,WAAA,CAAA,MAAM,CAAA,GAAA,wBAAA,WAAA,kBAAA,IAAA;AAuDN,WAAA,CAAA,MAAM,CAAA,GAAA,wBAAA,WAAA,gBAAA,IAAA;AAsBN,WAAA,CAAA,MAAM,CAAA,GAAA,wBAAA,WAAA,kBAAA,IAAA"}
@@ -1,7 +1,7 @@
1
1
  import { join } from "path";
2
2
  import { mkdir, readFile, readdir, unlink, writeFile } from "fs/promises";
3
- import { tmpdir } from "os";
4
3
  import { kill, ppid } from "process";
4
+ import { tmpdir } from "os";
5
5
  //#region ../ipc/src/discovery.ts
6
6
  /**
7
7
  * Directory scanned by `gk` binaries (and `@gitkraken/core-gitlens` consumers) for the