@gitkraken/core-gitlens 0.10.6 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -1
- package/dist/git/cache.d.ts +34 -2
- package/dist/git/cache.js +53 -7
- package/dist/git/cache.js.map +1 -1
- package/dist/git/context.d.ts +1 -1
- package/dist/git/models/repository.d.ts +3 -2
- package/dist/git/models/repository.js +5 -4
- package/dist/git/models/repository.js.map +1 -1
- package/dist/git/providers/branches.d.ts +22 -0
- package/dist/git/providers/config.d.ts +3 -1
- package/dist/git/providers/diff.d.ts +1 -0
- package/dist/git/providers/provider.d.ts +13 -1
- package/dist/git/providers/staging.d.ts +1 -1
- package/dist/git/service.d.ts +17 -1
- package/dist/git/service.js +59 -8
- package/dist/git/service.js.map +1 -1
- package/dist/git/watching/changeEvent.d.ts +48 -5
- package/dist/git/watching/changeEvent.js +82 -7
- package/dist/git/watching/changeEvent.js.map +1 -1
- package/dist/git/watching/classifyChange.d.ts +13 -2
- package/dist/git/watching/classifyChange.js +40 -5
- package/dist/git/watching/classifyChange.js.map +1 -1
- package/dist/git/watching/gitIgnoreFilter.d.ts +57 -10
- package/dist/git/watching/gitIgnoreFilter.js +186 -29
- package/dist/git/watching/gitIgnoreFilter.js.map +1 -1
- package/dist/git/watching/initWatcher.d.ts +5 -1
- package/dist/git/watching/initWatcher.js +1 -1
- package/dist/git/watching/initWatcher.js.map +1 -1
- package/dist/git/watching/provider.d.ts +33 -8
- package/dist/git/watching/watchGroup.d.ts +13 -2
- package/dist/git/watching/watchGroup.js +60 -14
- package/dist/git/watching/watchGroup.js.map +1 -1
- package/dist/git/watching/watchService.d.ts +42 -1
- package/dist/git/watching/watchService.js +172 -20
- package/dist/git/watching/watchService.js.map +1 -1
- package/dist/git/watching/watchSession.d.ts +50 -17
- package/dist/git/watching/watchSession.js +274 -83
- package/dist/git/watching/watchSession.js.map +1 -1
- package/dist/git/watching/watcherPatterns.d.ts +13 -2
- package/dist/git/watching/watcherPatterns.js +22 -2
- package/dist/git/watching/watcherPatterns.js.map +1 -1
- package/dist/git/watching/worktreeSummary.d.ts +121 -0
- package/dist/git/watching/worktreeSummary.js +427 -0
- package/dist/git/watching/worktreeSummary.js.map +1 -0
- package/dist/git-cli/cliGitProvider.d.ts +6 -1
- package/dist/git-cli/cliGitProvider.js +87 -2
- package/dist/git-cli/cliGitProvider.js.map +1 -1
- package/dist/git-cli/exec/git.js +1 -1
- package/dist/git-cli/providers/blame.js +1 -1
- package/dist/git-cli/providers/branches.d.ts +32 -1
- package/dist/git-cli/providers/branches.js +195 -0
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/dist/git-cli/providers/commits.js +1 -1
- package/dist/git-cli/providers/config.d.ts +3 -0
- package/dist/git-cli/providers/config.js +14 -8
- package/dist/git-cli/providers/config.js.map +1 -1
- package/dist/git-cli/providers/contributors.js +1 -1
- package/dist/git-cli/providers/diff.d.ts +3 -0
- package/dist/git-cli/providers/diff.js +3 -2
- package/dist/git-cli/providers/diff.js.map +1 -1
- package/dist/git-cli/providers/graph.js +1 -1
- package/dist/git-cli/providers/maintenance.js +1 -1
- package/dist/git-cli/providers/pausedOperations.js +2 -2
- package/dist/git-cli/providers/pausedOperations.js.map +1 -1
- package/dist/git-cli/providers/refs.js +1 -1
- package/dist/git-cli/providers/staging.js +2 -2
- package/dist/git-cli/providers/status.js +1 -1
- package/dist/git-cli/service.js +1 -0
- package/dist/git-cli/service.js.map +1 -1
- package/dist/ipc/discovery.js +1 -1
- package/dist/ipc/ipcServer.js +1 -1
- package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
- package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
- package/dist/plus/agents/providers/gkAgentProvider.js +2 -2
- package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
- package/dist/plus/git-github/api/github.d.ts +1 -1
- package/dist/plus/git-github/api/github.js +2 -1
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/providers/github/blame.js +1 -1
- package/dist/plus/integrations/authentication/integrationAuthenticationProvider.js +1 -1
- package/dist/plus/integrations/context.d.ts +1 -1
- package/dist/plus/integrations/integrationService.js +1 -1
- package/dist/plus/integrations/models/integration.d.ts +1 -1
- package/dist/plus/integrations/models/integration.js +2 -2
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/providers/azure/azure.js +1 -1
- package/dist/plus/integrations/providers/bitbucket-server.d.ts +1 -1
- package/dist/plus/integrations/providers/jira.d.ts +2 -0
- package/dist/plus/integrations/providers/jira.js +5 -0
- package/dist/plus/integrations/providers/jira.js.map +1 -1
- package/dist/plus/integrations/providers/linear.d.ts +7 -0
- package/dist/plus/integrations/providers/linear.js +19 -0
- package/dist/plus/integrations/providers/linear.js.map +1 -1
- package/dist/plus/integrations/providers/trello.d.ts +8 -0
- package/dist/plus/integrations/providers/trello.js +22 -0
- package/dist/plus/integrations/providers/trello.js.map +1 -1
- package/dist/plus/integrations/reads/currentAccount.d.ts +1 -1
- package/dist/plus/integrations/reads/currentAccount.js +1 -1
- package/dist/plus/integrations/reads/currentAccount.js.map +1 -1
- package/dist/plus/integrations/reads/issueTracker.js +1 -0
- package/dist/plus/integrations/reads/issueTracker.js.map +1 -1
- package/dist/utils/env/node/exec.js +2 -2
- package/dist/utils/event.d.ts +1 -1
- package/docs/integrations.md +6 -6
- package/docs/kepler-read-api-parity.md +2 -2
- package/package.json +1 -1
|
@@ -8,9 +8,9 @@ import __decorate from "../../_virtual/@oxc-project+runtime/helpers/esm/decorate
|
|
|
8
8
|
import { WorkspaceUntrustedError } from "../../git/errors.js";
|
|
9
9
|
import { fsExists } from "../../utils/env/node/exec.js";
|
|
10
10
|
import { gate } from "../../utils/decorators/gate.js";
|
|
11
|
-
import { hostname, userInfo } from "os";
|
|
12
|
-
import { env } from "process";
|
|
13
11
|
import { promises } from "fs";
|
|
12
|
+
import { env } from "process";
|
|
13
|
+
import { hostname, userInfo } from "os";
|
|
14
14
|
//#region ../git-cli/src/providers/config.ts
|
|
15
15
|
const mappedAuthorRegex = /(.+)\s<(.+)>/;
|
|
16
16
|
const emptyArray = Object.freeze([]);
|
|
@@ -289,11 +289,11 @@ var ConfigGitSubProvider = class {
|
|
|
289
289
|
this.cache.recordGkConfigWrite(repoPath, key, value);
|
|
290
290
|
}
|
|
291
291
|
async removeGkConfigBranchSection(repoPath, ref) {
|
|
292
|
-
await this.runGkConfigSectionCommand(repoPath, ref, "--remove-section", `branch.${ref}`);
|
|
292
|
+
if (await this.runGkConfigSectionCommand(repoPath, ref, "--remove-section", `branch.${ref}`)) this.cache.recordGkConfigSectionWrite(repoPath, ref);
|
|
293
293
|
}
|
|
294
294
|
async renameGkConfigBranchSection(repoPath, oldRef, newRef) {
|
|
295
295
|
await this.removeGkConfigBranchSection(repoPath, newRef);
|
|
296
|
-
await this.runGkConfigSectionCommand(repoPath, oldRef, "--rename-section", `branch.${oldRef}`, `branch.${newRef}`);
|
|
296
|
+
if (await this.runGkConfigSectionCommand(repoPath, oldRef, "--rename-section", `branch.${oldRef}`, `branch.${newRef}`)) this.cache.recordGkConfigSectionWrite(repoPath, oldRef, newRef);
|
|
297
297
|
}
|
|
298
298
|
/**
|
|
299
299
|
* Runs a section-level `git config` against `.git/gk/config` for `ref`'s section, skipping the
|
|
@@ -303,25 +303,31 @@ var ConfigGitSubProvider = class {
|
|
|
303
303
|
* Never throws: callers invoke this as bookkeeping after a branch op has already succeeded, so a
|
|
304
304
|
* failure here must not be reported as (or roll back) the branch/checkout/worktree operation itself.
|
|
305
305
|
* The worst case is metadata that stays behind until the next op on that name.
|
|
306
|
+
*
|
|
307
|
+
* Returns whether `.git/gk/config` now reflects the command (it ran, or there was nothing to do), so the
|
|
308
|
+
* caller can record its own write in the merge-key snapshot only when it actually landed.
|
|
306
309
|
*/
|
|
307
310
|
async runGkConfigSectionCommand(repoPath, ref, ...args) {
|
|
308
311
|
const scope = getScopedLogger();
|
|
309
312
|
try {
|
|
310
313
|
const prefix = `branch.${ref}.`;
|
|
311
314
|
const map = await this.getGkConfigMap(repoPath);
|
|
312
|
-
if (map.size && !some(map.keys(), (k) => k.startsWith(prefix))) return;
|
|
315
|
+
if (map.size && !some(map.keys(), (k) => k.startsWith(prefix))) return true;
|
|
313
316
|
const gkConfigPath = await this.getGkConfigPath(repoPath);
|
|
314
|
-
if (!gkConfigPath) return;
|
|
315
|
-
if (!await fsExists(gkConfigPath)) return;
|
|
317
|
+
if (!gkConfigPath) return false;
|
|
318
|
+
if (!await fsExists(gkConfigPath)) return true;
|
|
316
319
|
const result = await this.git.run({
|
|
317
320
|
cwd: repoPath,
|
|
318
321
|
runLocally: true,
|
|
319
322
|
errors: "ignore"
|
|
320
323
|
}, "config", "-f", gkConfigPath, ...args);
|
|
321
|
-
|
|
324
|
+
const succeeded = result.completion.status === "exited" && result.exitCode === 0;
|
|
325
|
+
if (!succeeded) scope?.warn(`Failed to update gk config section for '${ref}' in '${repoPath}': ${result.completion.status === "exited" ? `git config exited ${result.exitCode}` : `${result.completion.status} · ${result.completion.error.message}`}`);
|
|
322
326
|
this.cache.deleteGkConfigMap(repoPath);
|
|
327
|
+
return succeeded;
|
|
323
328
|
} catch (ex) {
|
|
324
329
|
scope?.error(ex, `Failed to update gk config section for '${ref}' in '${repoPath}'`);
|
|
330
|
+
return false;
|
|
325
331
|
}
|
|
326
332
|
}
|
|
327
333
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","names":["process_env","fs"],"sources":["../../../../git-cli/src/providers/config.ts"],"sourcesContent":["import { promises as fs } from 'fs';\nimport { hostname, userInfo } from 'os';\nimport { env as process_env } from 'process';\nimport type { Cache, GkConfigInvalidationTarget, GkReconcileOutcome } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport { WorkspaceUntrustedError } from '@gitlens/git/errors.js';\nimport type { GitDir } from '@gitlens/git/models/repository.js';\nimport type { SigningConfig, SigningFormat, ValidationResult } from '@gitlens/git/models/signature.js';\nimport type { GitUser } from '@gitlens/git/models/user.js';\nimport type {\n\tDeprecatedGkConfigKeys,\n\tGitConfigKeys,\n\tGitConfigSubProvider,\n\tGitConfigType,\n\tGkConfigKeys,\n} from '@gitlens/git/providers/config.js';\nimport { gate } from '@gitlens/utils/decorators/gate.js';\nimport { debug, trace } from '@gitlens/utils/decorators/log.js';\nimport { first, some } from '@gitlens/utils/iterable.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { dirname, getBestPath, isAbsolute, joinPaths, normalizePath } from '@gitlens/utils/path.js';\nimport { fileUri } from '@gitlens/utils/uri.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport { fsExists } from '../exec/exec.js';\nimport type { Git } from '../exec/git.js';\n\nconst mappedAuthorRegex = /(.+)\\s<(.+)>/;\nconst emptyArray: readonly never[] = Object.freeze([]);\n\n/** Catch-all pattern matching every key in `.git/gk/config` for the one-shot bulk read. */\nconst gkConfigAllPattern = '.';\n\n/**\n * Canonicalizes a git config key for lookup against `--get-regexp` output, which git emits with the\n * section and variable-name lowercased and only the subsection case-preserved. Without this a\n * subsection-less key like `gk.defaultRemote` would miss the lowercased `gk.defaultremote` in the map.\n */\nexport function canonicalizeGitConfigKey(key: string): string {\n\tconst first = key.indexOf('.');\n\tif (first === -1) return key.toLowerCase();\n\n\tconst last = key.lastIndexOf('.');\n\t// `section.name` (no subsection) → fully lowercased; `section.subsection.name` → lowercase\n\t// section + name, preserve the case-sensitive subsection in the middle.\n\tif (first === last) return key.toLowerCase();\n\treturn `${key.slice(0, first).toLowerCase()}${key.slice(first, last)}${key.slice(last).toLowerCase()}`;\n}\n\n/**\n * Parses git config --get-regex output into a Map.\n * The output format is \"key value\" per line, where key and value are space-separated.\n *\n * A line with NO space at all is git's rendering of a bareword/valueless entry (`key`, no `=`) — git's\n * OWN config parser reads that as boolean TRUE (git-config(1): \"a variable defined without `= <value>`\n * is taken as true\"), confirmed against git's `format_config` (builtin/config.c): the key-delimiter is\n * appended unconditionally, then backed out ONLY when the stored value is NULL (the bareword case) —\n * an explicit empty value (`key =`) is a real, non-NULL empty string, so its line KEEPS the trailing\n * space and is already handled by the branch below, byte-distinct from a bareword line.\n *\n * By default a bareword line is skipped (the historical behavior, which reads as \"unset\" — wrong, but\n * safe); pass `includeValueless` to map it to the literal string `'true'` instead, so `parseGitBoolean`\n * and callers checking `.has()` for \"configured\" both read it correctly.\n */\nexport function parseConfigRegexOutput(\n\tdata: string | undefined,\n\toptions?: { includeValueless?: boolean },\n): Map<string, string> {\n\tconst configMap = new Map<string, string>();\n\tif (!data) return configMap;\n\n\tfor (const line of data.split('\\n')) {\n\t\tif (!line) continue;\n\n\t\tconst spaceIndex = line.indexOf(' ');\n\t\tif (spaceIndex === -1) {\n\t\t\tif (options?.includeValueless) {\n\t\t\t\tconfigMap.set(line, 'true');\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tconfigMap.set(line.substring(0, spaceIndex), line.substring(spaceIndex + 1));\n\t}\n\n\treturn configMap;\n}\n\nexport function parseGitBoolean(value: string | undefined): boolean {\n\tif (value == null) return false;\n\n\tconst normalized = value.toLowerCase().trim();\n\treturn normalized === 'true' || normalized === 'yes' || normalized === 'on' || normalized === '1';\n}\n\n/** Whether a git config value spells boolean-false (`false`/`no`/`off`/`0`/empty), per git's maybe-bool parsing. */\nexport function isGitBooleanFalse(value: string): boolean {\n\tconst normalized = value.toLowerCase().trim();\n\treturn (\n\t\tnormalized === '' || normalized === 'false' || normalized === 'no' || normalized === 'off' || normalized === '0'\n\t);\n}\n\nexport class ConfigGitSubProvider implements GitConfigSubProvider {\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\t\tthis.cache.setGkConfigReconciler((repoPath, priorSnapshot) => this.reconcileGkConfig(repoPath, priorSnapshot));\n\t}\n\n\t/**\n\t * In-flight gk-config reconciles keyed by commonPath. `pending` records that another `'gkConfig'`\n\t * event landed mid-pass, so one trailing pass runs after the current one settles. `paths` holds every\n\t * worktree path that reported the change, mapped to its close generation at that moment — the pass\n\t * reads through one that's still open and notifies all of them.\n\t */\n\tprivate readonly _gkConfigReconciles = new Map<string, { pending: boolean; paths: Map<string, number> }>();\n\n\t/**\n\t * Pending `setGkConfig` writes keyed by `(commonPath, key, value, skip-option)`. Concurrent\n\t * callers writing the same `(key, value)` pair share the in-flight Promise so only one\n\t * `git config --set` subprocess actually runs. Cleared on settle.\n\t */\n\tprivate readonly _pendingGkConfigWrites = new Map<string, Promise<void>>();\n\n\t@trace()\n\tgetConfig(\n\t\trepoPath: string | undefined,\n\t\tkey: GitConfigKeys,\n\t\toptions?: { global?: boolean; runGitLocally?: boolean; type?: GitConfigType },\n\t): Promise<string | undefined> {\n\t\tconst global = options?.global || repoPath == null;\n\t\treturn this.cache.getConfig(global ? undefined : repoPath, key, () =>\n\t\t\tthis.getConfigCore(repoPath, key, options),\n\t\t);\n\t}\n\n\tprivate async getConfigCore(\n\t\trepoPath: string | undefined,\n\t\tkey: string,\n\t\toptions?: { file?: string; global?: boolean; runGitLocally?: boolean; type?: GitConfigType },\n\t): Promise<string | undefined> {\n\t\tconst args = ['config', '--get'];\n\t\tif (options?.file) {\n\t\t\targs.push('-f', options.file);\n\t\t} else if (options?.global || repoPath == null) {\n\t\t\targs.push('--global');\n\t\t}\n\t\tif (options?.type) {\n\t\t\targs.push(`--type=${options.type}`);\n\t\t}\n\t\targs.push(key);\n\n\t\tconst result = await this.git.run(\n\t\t\t{ cwd: repoPath ?? '', errors: 'ignore', runLocally: options?.runGitLocally },\n\t\t\t...args,\n\t\t);\n\t\treturn result.stdout.trim() || undefined;\n\t}\n\n\t@trace()\n\tgetConfigRegex(\n\t\trepoPath: string | undefined,\n\t\tpattern: string,\n\t\toptions?: { global?: boolean; runGitLocally?: boolean },\n\t): Promise<Map<string, string>> {\n\t\tconst global = options?.global || repoPath == null;\n\t\treturn this.cache.getConfigRegex(global ? undefined : repoPath, pattern, () =>\n\t\t\tthis.getConfigRegexCore(repoPath, pattern, options),\n\t\t);\n\t}\n\n\tprivate async getConfigRegexCore(\n\t\trepoPath: string | undefined,\n\t\tpattern: string,\n\t\toptions?: { file?: string; global?: boolean; runGitLocally?: boolean },\n\t): Promise<Map<string, string>> {\n\t\tconst args = ['config', '--get-regex'];\n\t\tif (options?.file) {\n\t\t\targs.push('-f', options.file);\n\t\t} else if (options?.global || repoPath == null) {\n\t\t\targs.push('--global');\n\t\t}\n\t\targs.push(pattern);\n\n\t\tconst result = await this.git.run(\n\t\t\t{ cwd: repoPath ?? '', errors: 'ignore', runLocally: options?.runGitLocally },\n\t\t\t...args,\n\t\t);\n\t\t// Deliberately NOT `.trim()`-ed: an explicit-empty value's LAST line ends in a meaningful trailing\n\t\t// space, and `.trim()`-ing the whole (possibly multi-line) buffer strips it — `parseConfigRegexOutput`\n\t\t// already skips the blank line a trailing newline produces, so no trim is needed.\n\t\treturn parseConfigRegexOutput(result.stdout);\n\t}\n\n\t@debug()\n\tasync setConfig(\n\t\trepoPath: string | undefined,\n\t\tkey: GitConfigKeys,\n\t\tvalue: string | undefined,\n\t\toptions?: { file?: string; global?: boolean },\n\t): Promise<void> {\n\t\tawait this.setConfigCore(repoPath, key, value, options);\n\n\t\t// A branch's upstream (`remote`/`merge`) is read back through the cached branch list, which a\n\t\t// `'config'` reset alone leaves serving the old tracking info.\n\t\tif (repoPath != null && !options?.file && /^branch\\..+\\.(?:remote|merge)$/i.test(key)) {\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t}\n\t}\n\n\tprivate async setConfigCore(\n\t\trepoPath: string | undefined,\n\t\tkey: string,\n\t\tvalue: string | undefined,\n\t\toptions?: { file?: string; global?: boolean },\n\t): Promise<void> {\n\t\tconst args: string[] = ['config'];\n\n\t\tif (options?.file) {\n\t\t\targs.push('-f', options.file);\n\t\t} else {\n\t\t\tconst global = options?.global || repoPath == null;\n\t\t\targs.push(global ? '--global' : '--local');\n\t\t}\n\n\t\tif (value == null) {\n\t\t\targs.push('--unset', key);\n\t\t} else {\n\t\t\targs.push(key, value);\n\t\t}\n\n\t\tawait this.git.run({ cwd: repoPath ?? '', runLocally: true }, ...args);\n\n\t\t// Only invalidate cache when not using a custom file (custom files aren't cached)\n\t\tif (!options?.file) {\n\t\t\tconst global = options?.global || repoPath == null;\n\t\t\t// Invalidate the cached value for this key and clear all regex patterns for this scope\n\t\t\tthis.cache.deleteConfig(global ? undefined : repoPath, key);\n\t\t}\n\t}\n\n\t@gate()\n\t@debug()\n\tasync getCurrentUser(repoPath: string): Promise<GitUser | undefined> {\n\t\tif (!repoPath) return undefined;\n\n\t\tconst scope = getScopedLogger();\n\n\t\tconst cached = this.cache.currentUser.get(repoPath);\n\t\tif (cached != null) return cached;\n\t\t// If we found null, user data was not found - don't bother trying again\n\t\tif (cached === null) return undefined;\n\n\t\tconst user: GitUser = { name: undefined, email: undefined };\n\n\t\ttry {\n\t\t\tconst configMap = await this.getConfigRegex(repoPath, '^user\\\\.(name|email)$', {\n\t\t\t\trunGitLocally: true,\n\t\t\t});\n\t\t\tif (configMap.size) {\n\t\t\t\tuser.name = configMap.get('user.name');\n\t\t\t\tuser.email = configMap.get('user.email');\n\t\t\t} else {\n\t\t\t\tuser.name =\n\t\t\t\t\tprocess_env.GIT_AUTHOR_NAME || process_env.GIT_COMMITTER_NAME || userInfo()?.username || undefined;\n\t\t\t\tif (!user.name) {\n\t\t\t\t\t// If we found no user data, mark it so we won't bother trying again\n\t\t\t\t\tthis.cache.currentUser.set(repoPath, null);\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tuser.email =\n\t\t\t\t\tprocess_env.GIT_AUTHOR_EMAIL ||\n\t\t\t\t\tprocess_env.GIT_COMMITTER_EMAIL ||\n\t\t\t\t\tprocess_env.EMAIL ||\n\t\t\t\t\t`${user.name}@${hostname()}`;\n\t\t\t}\n\n\t\t\tconst author = `${user.name} <${user.email}>`;\n\t\t\t// Check if there is a mailmap for the current user\n\t\t\tconst result = await this.git.run({ cwd: repoPath, errors: 'ignore' }, 'check-mailmap', author);\n\n\t\t\tif (result.stdout && result.stdout !== author) {\n\t\t\t\tconst match = mappedAuthorRegex.exec(result.stdout);\n\t\t\t\tif (match != null) {\n\t\t\t\t\t[, user.name, user.email] = match;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.cache.currentUser.set(repoPath, user);\n\t\t\treturn user;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\n\t\t\t// Mark it so we won't bother trying again\n\t\t\tthis.cache.currentUser.set(repoPath, null);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@gate()\n\t@trace({ exit: r => `returned ${r}` })\n\tasync getDefaultWorktreePath(repoPath: string): Promise<string | undefined> {\n\t\tconst gitDir = await this.getGitDir(repoPath);\n\t\tif (gitDir == null) return undefined;\n\n\t\tconst basePath = (gitDir.commonUri ?? gitDir.uri).fsPath;\n\t\treturn getBestPath(normalizePath(joinPaths(basePath, '..')));\n\t}\n\n\t@gate()\n\t@trace({\n\t\texit: r =>\n\t\t\t`returned ${r.uri.toString(true)}, commonUri=${r.commonUri?.toString(true)}, parentUri=${r.parentUri?.toString(true)}`,\n\t})\n\tasync getGitDir(repoPath: string): Promise<GitDir> {\n\t\tconst cached = this.cache.gitDir.get(repoPath);\n\t\tif (cached != null) return cached;\n\n\t\tconst scope = getScopedLogger();\n\t\tconst repoInfo = await this.getRepositoryInfo(repoPath);\n\n\t\tlet gitDir: GitDir;\n\t\tif (!Array.isArray(repoInfo) && repoInfo != null) {\n\t\t\tgitDir = {\n\t\t\t\turi: fileUri(repoInfo.gitDir),\n\t\t\t\tcommonUri: repoInfo.commonGitDir ? fileUri(repoInfo.commonGitDir) : undefined,\n\t\t\t\tparentUri: repoInfo.superprojectPath ? fileUri(repoInfo.superprojectPath) : undefined,\n\t\t\t};\n\t\t} else {\n\t\t\tgitDir = {\n\t\t\t\turi: this.provider.getAbsoluteUri(joinPaths(repoPath, '.git'), repoPath),\n\t\t\t};\n\n\t\t\tconst gitDirPath = gitDir.uri.toString(true);\n\t\t\tscope?.warn(`rev-parse failed for '${repoPath}'; falling back to '${gitDirPath}'`);\n\t\t\tthis.context.hooks?.operations?.onGitDirResolveFailed?.(\n\t\t\t\trepoPath,\n\t\t\t\tgitDirPath,\n\t\t\t\t`rev_parse returned ${JSON.stringify(repoInfo)}`,\n\t\t\t);\n\t\t}\n\t\tthis.cache.gitDir.set(repoPath, gitDir);\n\n\t\treturn gitDir;\n\t}\n\n\t/**\n\t * Gets the path to the .git/gk/config file for storing GitKraken-specific metadata.\n\t * Uses commonPath for worktrees so all worktrees share the same data.\n\t */\n\tprivate async getGkConfigPath(repoPath: string): Promise<string | undefined> {\n\t\tconst gitDir = await this.getGitDir(repoPath);\n\t\tif (gitDir == null) return undefined;\n\n\t\t// Use commonUri (main .git dir) for worktrees, otherwise use uri\n\t\tconst basePath = (gitDir.commonUri ?? gitDir.uri).fsPath;\n\t\treturn joinPaths(basePath, 'gk', 'config');\n\t}\n\n\t@debug()\n\tasync getGkConfig(repoPath: string, key: GkConfigKeys | DeprecatedGkConfigKeys): Promise<string | undefined> {\n\t\t// Served in-memory from a single bulk read of the whole `.git/gk/config` (no gk read needs `--type`).\n\t\t// Canonicalize the key the way git does for `--get-regexp` output so subsection-less keys\n\t\t// (e.g. `gk.defaultRemote`) match, and coerce an empty value to undefined to match the old\n\t\t// `git config --get` (`.trim() || undefined`) contract.\n\t\treturn (await this.getGkConfigMap(repoPath)).get(canonicalizeGitConfigKey(key)) || undefined;\n\t}\n\n\t@debug()\n\tasync getGkConfigRegex(repoPath: string, pattern: string): Promise<Map<string, string>> {\n\t\tconst all = await this.getGkConfigMap(repoPath);\n\n\t\t// Filter the bulk map in-memory. The old path passed `pattern` to `git config --get-regex`\n\t\t// (errors ignored → empty result on a bad pattern); preserve that no-throw contract here\n\t\t// rather than letting an invalid-JS pattern reject the read.\n\t\tlet re: RegExp;\n\t\ttry {\n\t\t\tre = new RegExp(pattern);\n\t\t} catch {\n\t\t\treturn new Map();\n\t\t}\n\n\t\tconst result = new Map<string, string>();\n\t\tfor (const [k, v] of all) {\n\t\t\tif (re.test(k)) {\n\t\t\t\tresult.set(k, v);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Reads the entire `.git/gk/config` in one `git config --get-regexp` and caches the parsed map\n\t * per commonPath. Per-key (getGkConfig) and per-namespace (getGkConfigRegex) lookups are served\n\t * from this single cached read — so a branch-overview render that fans out across several gk\n\t * namespaces costs one `git config` call instead of one per namespace.\n\t */\n\tprivate async getGkConfigMap(repoPath: string): Promise<Map<string, string>> {\n\t\t// Migrate BEFORE populating the cache, not inside the factory: a first-time migration calls\n\t\t// clearCaches('gkConfig'), which would otherwise evict the in-flight gkConfigMap entry the\n\t\t// cache wrapper synchronously stored and force a redundant bulk re-read.\n\t\tawait this.migrateGkConfigFromGitConfig(this.cache.getCommonPath(repoPath));\n\t\treturn this.cache.getGkConfigMap(repoPath, async cacheable => {\n\t\t\tconst { map, failed } = await this.getGkConfigRegexCore(repoPath, gkConfigAllPattern);\n\t\t\t// This map has no TTL and everything gk-related reads through it, so a failed read cached as an\n\t\t\t// empty map would report every branch as having no stored base or merge target for the session —\n\t\t\t// and would make the section-cleanup pre-checks skip real work. Only cache a read that happened.\n\t\t\tif (failed) {\n\t\t\t\tcacheable.invalidate();\n\t\t\t}\n\t\t\treturn map;\n\t\t});\n\t}\n\n\tprivate async getGkConfigRegexCore(\n\t\trepoPath: string,\n\t\tpattern: string,\n\t): Promise<{ map: Map<string, string>; failed: boolean }> {\n\t\tconst gkConfigPath = await this.getGkConfigPath(repoPath);\n\t\t// No `.git/gk/config` yet is a real answer, not a failure — a repo GitLens has never written to.\n\t\tif (!gkConfigPath) return { map: new Map(), failed: false };\n\n\t\tconst result = await this.git.run(\n\t\t\t{ cwd: repoPath, errors: 'ignore', runLocally: true },\n\t\t\t'config',\n\t\t\t'--get-regex',\n\t\t\t'-f',\n\t\t\tgkConfigPath,\n\t\t\tpattern,\n\t\t);\n\t\t// `--get-regex` exits 1 when nothing matches, which IS an answer (an empty gk config).\n\t\tconst exited = result.completion.status === 'exited';\n\t\treturn {\n\t\t\t// Deliberately NOT `.trim()`-ed — see `getConfigRegexCore`'s comment: it strips the trailing\n\t\t\t// space that marks an explicit-empty value's LAST line, silently dropping it from the map.\n\t\t\tmap: parseConfigRegexOutput(result.stdout),\n\t\t\tfailed: !exited || (result.exitCode !== 0 && result.exitCode !== 1),\n\t\t};\n\t}\n\n\t@debug()\n\tasync setGkConfig(\n\t\trepoPath: string,\n\t\tkey: GkConfigKeys | DeprecatedGkConfigKeys,\n\t\tvalue: string | undefined,\n\t\toptions?: { skipInvalidation?: readonly GkConfigInvalidationTarget[] },\n\t): Promise<void> {\n\t\t// Encode the skip-invalidation option in the dedup key: a self-write (with skip targets)\n\t\t// and a user-driven write of the same `(key, value)` (no skip targets) have different\n\t\t// cache-invalidation semantics, so sharing their Promise would silently let the user-driven\n\t\t// write skip invalidation. Sort the array so callers passing the same targets in different\n\t\t// orders share a single in-flight write.\n\t\tconst commonPath = this.cache.getCommonPath(repoPath);\n\t\tconst skipKey = options?.skipInvalidation?.length ? options.skipInvalidation.toSorted().join(',') : '';\n\t\tconst dedupKey = `${commonPath}\\0${key}\\0${value ?? ''}\\0${skipKey}`;\n\n\t\tconst pending = this._pendingGkConfigWrites.get(dedupKey);\n\t\tif (pending != null) return pending;\n\n\t\tconst promise = this.setGkConfigCore(repoPath, key, value, options);\n\t\tthis._pendingGkConfigWrites.set(dedupKey, promise);\n\t\t// Swallow the cleanup chain's rejection so a failed write doesn't surface as an unhandled\n\t\t// rejection separate from the caller's own handling of the returned promise.\n\t\tvoid promise.finally(() => this._pendingGkConfigWrites.delete(dedupKey)).catch(() => {});\n\t\treturn promise;\n\t}\n\n\tprivate async setGkConfigCore(\n\t\trepoPath: string,\n\t\tkey: GkConfigKeys | DeprecatedGkConfigKeys,\n\t\tvalue: string | undefined,\n\t\toptions?: { skipInvalidation?: readonly GkConfigInvalidationTarget[] },\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst gkConfigPath = await this.getGkConfigPath(repoPath);\n\t\tif (!gkConfigPath) return;\n\n\t\tconst gkConfigFolder = joinPaths(gkConfigPath, '..');\n\n\t\tif (!(await this.ensureGkConfigFolder(gkConfigFolder, scope))) return;\n\n\t\tawait this.setConfigCore(repoPath, key, value, { file: gkConfigPath });\n\n\t\t// Invalidate the bulk map (so the next read re-fetches) and the derived caches for this key's\n\t\t// ref. The `.git/gk/config` file-watcher also fires `'gkConfig'` shortly after, which reconciles\n\t\t// the same change (see `reconcileGkConfig`) — recording our own write here keeps that later\n\t\t// reconcile from re-diffing this key as an external change.\n\t\tthis.cache.deleteGkConfig(repoPath, key, options);\n\t\tthis.cache.recordGkConfigWrite(repoPath, key, value);\n\t}\n\n\t@debug()\n\tasync removeGkConfigBranchSection(repoPath: string, ref: string): Promise<void> {\n\t\tawait this.runGkConfigSectionCommand(repoPath, ref, '--remove-section', `branch.${ref}`);\n\t}\n\n\t@debug()\n\tasync renameGkConfigBranchSection(repoPath: string, oldRef: string, newRef: string): Promise<void> {\n\t\t// Clear the destination first, unconditionally. `--rename-section` onto a section that already\n\t\t// exists APPENDS rather than replaces, leaving duplicate keys — and git resolves a duplicated key\n\t\t// to its LAST value, so the orphan left by an earlier branch of this name would win over the\n\t\t// metadata being moved. Doing this outside `runGkConfigSectionCommand` also covers the case where\n\t\t// the source has no gk keys at all, where its pre-check would otherwise skip the whole call and\n\t\t// leave the orphan in place for the renamed branch to inherit.\n\t\tawait this.removeGkConfigBranchSection(repoPath, newRef);\n\t\tawait this.runGkConfigSectionCommand(\n\t\t\trepoPath,\n\t\t\toldRef,\n\t\t\t'--rename-section',\n\t\t\t`branch.${oldRef}`,\n\t\t\t`branch.${newRef}`,\n\t\t);\n\t}\n\n\t/**\n\t * Runs a section-level `git config` against `.git/gk/config` for `ref`'s section, skipping the\n\t * subprocess entirely when the bulk map (already cached on any warm path) shows that ref has no gk\n\t * keys — the overwhelmingly common case, since most branches never get gk metadata written at all.\n\t *\n\t * Never throws: callers invoke this as bookkeeping after a branch op has already succeeded, so a\n\t * failure here must not be reported as (or roll back) the branch/checkout/worktree operation itself.\n\t * The worst case is metadata that stays behind until the next op on that name.\n\t */\n\tprivate async runGkConfigSectionCommand(repoPath: string, ref: string, ...args: string[]): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\t\ttry {\n\t\t\tconst prefix = `branch.${ref}.`;\n\t\t\tconst map = await this.getGkConfigMap(repoPath);\n\t\t\t// The shortcut needs a map with CONTENT to be trustworthy. A failed bulk read resolves empty\n\t\t\t// (see `getGkConfigMap`) — the cache refuses it, but this caller still holds it — and an empty map\n\t\t\t// read as authoritative would skip the removal entirely, leaving a deleted branch's base,\n\t\t\t// disposition and issue links behind for the next branch reusing that name. When it's empty, run\n\t\t\t// the command: worst case is a no-op on a section that isn't there.\n\t\t\tif (map.size && !some(map.keys(), k => k.startsWith(prefix))) return;\n\n\t\t\tconst gkConfigPath = await this.getGkConfigPath(repoPath);\n\t\t\tif (!gkConfigPath) return;\n\t\t\t// `getGkConfigPath` only joins a path, so check the file: with no `.git/gk/config` there is\n\t\t\t// genuinely nothing to remove, and running the command would fail with a fatal we'd then warn\n\t\t\t// about on every branch delete in a repo that has never had gk metadata.\n\t\t\tif (!(await fsExists(gkConfigPath))) return;\n\n\t\t\tconst result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, runLocally: true, errors: 'ignore' },\n\t\t\t\t'config',\n\t\t\t\t'-f',\n\t\t\t\tgkConfigPath,\n\t\t\t\t...args,\n\t\t\t);\n\t\t\t// `errors: 'ignore'` is deliberate — see the note above on why this must never throw — but that\n\t\t\t// also means the `catch` below never sees a failed write, so without this the metadata silently\n\t\t\t// stays behind (or, on a rename, stays under the old name) with nothing recorded anywhere.\n\t\t\t// Reported, not thrown: the branch op it follows has already succeeded.\n\t\t\tif (result.completion.status !== 'exited' || result.exitCode !== 0) {\n\t\t\t\tscope?.warn(\n\t\t\t\t\t`Failed to update gk config section for '${ref}' in '${repoPath}': ${\n\t\t\t\t\t\tresult.completion.status === 'exited'\n\t\t\t\t\t\t\t? `git config exited ${result.exitCode}`\n\t\t\t\t\t\t\t: `${result.completion.status} · ${result.completion.error.message}`\n\t\t\t\t\t}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\t// A whole section moved or vanished, which the per-key `deleteGkConfig` cascade can't express.\n\t\t\t// Drop the bulk map so the next read hits disk; the derived caches for the affected ref are\n\t\t\t// evicted by the caller's own `deleteBaseBranchName` plus the `'branches'` cascade it fires.\n\t\t\tthis.cache.deleteGkConfigMap(repoPath);\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex, `Failed to update gk config section for '${ref}' in '${repoPath}'`);\n\t\t}\n\t}\n\n\t/**\n\t * Reconciles a watcher-observed `'gkConfig'` change — registered with the shared `Cache` as its\n\t * gk-config reconciler (see the constructor). Re-reads the bulk map (hard-evicted by\n\t * `Cache.handleGkConfigChanged`, so this hits disk) and diffs it against `priorSnapshot` to cascade\n\t * `baseBranchName`/`branchOverviews` only for refs whose merge-relevant keys actually changed.\n\t *\n\t * Serialized per commonPath: a reconcile is a read-then-diff against a single shared baseline, so\n\t * two overlapping passes would both diff against the same snapshot and the later change could fall\n\t * out entirely. An event arriving mid-pass instead queues one trailing pass, which re-reads and\n\t * diffs against the baseline the previous pass just established.\n\t *\n\t * `.git/gk/config` lives in the common dir, so the watcher delivers one event per worktree sharing it\n\t * (see `WatchGroup.onCommonEvent`). Siblings never run concurrently — the later ones fold into the\n\t * in-flight pass — but folding in arms the trailing pass, so a fan-out costs one extra read that\n\t * re-reads and diffs an unchanged file. However many siblings land while a pass is running, they\n\t * coalesce into that single trailing pass; the cost is the price of never dropping a real change.\n\t * Every reporting path is retained because `Repository` matches the follow-up change event on exact\n\t * path, and a sibling worktree that never receives one would sit on stale derived values.\n\t */\n\tprivate reconcileGkConfig(\n\t\trepoPath: string,\n\t\tpriorSnapshot: ReadonlyMap<string, string> | undefined,\n\t): GkReconcileOutcome | Promise<GkReconcileOutcome> {\n\t\tconst commonPath = this.cache.getCommonPath(repoPath);\n\n\t\tconst inflight = this._gkConfigReconciles.get(commonPath);\n\t\tif (inflight != null) {\n\t\t\tinflight.paths.set(repoPath, this.cache.getCloseGeneration(repoPath));\n\t\t\tinflight.pending = true;\n\t\t\t// Handed to the in-flight pass's trailing loop, so it IS being reconciled — just not by this\n\t\t\t// call. Reporting a failure here would coarse-clear on every write in a burst.\n\t\t\treturn 'deferred';\n\t\t}\n\n\t\tconst entry = { pending: false, paths: new Map([[repoPath, this.cache.getCloseGeneration(repoPath)]]) };\n\t\tthis._gkConfigReconciles.set(commonPath, entry);\n\t\treturn this.runGkConfigReconcile(commonPath, priorSnapshot, entry);\n\t}\n\n\t/** Drops paths that closed since they reported the change; returns whichever remain. */\n\tprivate pruneClosedReconcilePaths(paths: Map<string, number>): Map<string, number> {\n\t\tfor (const [path, generation] of paths) {\n\t\t\tif (this.cache.getCloseGeneration(path) !== generation) {\n\t\t\t\tpaths.delete(path);\n\t\t\t}\n\t\t}\n\t\treturn paths;\n\t}\n\n\tprivate async runGkConfigReconcile(\n\t\tcommonPath: string,\n\t\tpriorSnapshot: ReadonlyMap<string, string> | undefined,\n\t\tentry: { pending: boolean; paths: Map<string, number> },\n\t): Promise<GkReconcileOutcome> {\n\t\tconst scope = getScopedLogger();\n\t\tlet snapshot = priorSnapshot;\n\n\t\ttry {\n\t\t\tdo {\n\t\t\t\tentry.pending = false;\n\n\t\t\t\t// Read through a path that's still open — one worktree closing must not drop the event for\n\t\t\t\t// its still-open siblings, which is why this reads from the surviving set rather than from\n\t\t\t\t// whichever path happened to report first.\n\t\t\t\tconst readPath = first(this.pruneClosedReconcilePaths(entry.paths).keys());\n\t\t\t\t// Every path that reported the change has since closed — nothing left to reconcile, and\n\t\t\t\t// nothing left holding a stale derived value either.\n\t\t\t\tif (readPath == null) return 'reconciled';\n\n\t\t\t\t// A trailing pass must not reuse the entry the pass before it installed.\n\t\t\t\tthis.cache.deleteGkConfigMap(readPath);\n\t\t\t\tconst freshMap = await this.getGkConfigMap(readPath);\n\t\t\t\t// Paths may have closed while the re-read was in flight; if every one did, there's nothing\n\t\t\t\t// left to reconcile against.\n\t\t\t\tif (!this.pruneClosedReconcilePaths(entry.paths).size) return 'reconciled';\n\n\t\t\t\tif (this.cache.reconcileGkConfigMap(readPath, snapshot, freshMap)) {\n\t\t\t\t\t// Fire a follow-up change: a consumer that re-read on the original event may have done so\n\t\t\t\t\t// before this async cascade landed, so it would otherwise hold a stale derived value with\n\t\t\t\t\t// nothing left to prompt another re-read.\n\t\t\t\t\tfor (const path of entry.paths.keys()) {\n\t\t\t\t\t\tthis.context.hooks?.repository?.onChanged?.(path, ['gkConfig']);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// `reconcileGkConfigMap` advanced the stored baseline to what we just read; a trailing pass\n\t\t\t\t// diffs its own read against that.\n\t\t\t\tsnapshot = this.cache.getGkConfigMergeSnapshot(readPath);\n\t\t\t} while (entry.pending);\n\n\t\t\treturn 'reconciled';\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex, `Failed to reconcile gk config for '${commonPath}'`);\n\t\t\t// The caller falls back to the coarse clear — derived caches are otherwise left holding\n\t\t\t// pre-change values with nothing to correct them.\n\t\t\treturn 'failed';\n\t\t} finally {\n\t\t\tthis._gkConfigReconciles.delete(commonPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync getSigningConfig(repoPath: string): Promise<SigningConfig> {\n\t\t// Fetch all signing-related config in one call\n\t\tconst configMap = await this.getConfigRegex(\n\t\t\trepoPath,\n\t\t\t'^(commit\\\\.gpgsign|gpg\\\\.format|user\\\\.signingkey|gpg\\\\.program|gpg\\\\.ssh\\\\.program|gpg\\\\.ssh\\\\.allowedsignersfile)$',\n\t\t);\n\n\t\t// Extract values (keys are lowercase in git output)\n\t\tconst enabledRaw = configMap.get('commit.gpgsign');\n\t\tconst format = configMap.get('gpg.format');\n\t\tconst signingKey = configMap.get('user.signingkey');\n\t\tconst gpgProgram = configMap.get('gpg.program');\n\t\tconst sshProgram = configMap.get('gpg.ssh.program');\n\t\tconst allowedSignersFile = configMap.get('gpg.ssh.allowedsignersfile');\n\n\t\t// Check if git config has commit signing enabled, falling back to the host-level override\n\t\t// (e.g. VS Code's `git.enableCommitSigning`) when `commit.gpgsign` is unset/false. The host\n\t\t// override can only enable signing, never force it off.\n\t\tconst isEnabled = parseGitBoolean(enabledRaw) || this.context.config?.signing?.enabled === true;\n\n\t\treturn {\n\t\t\tenabled: isEnabled,\n\t\t\tformat: (format as SigningFormat) ?? 'gpg',\n\t\t\tsigningKey: signingKey,\n\t\t\tgpgProgram: gpgProgram,\n\t\t\tsshProgram: sshProgram,\n\t\t\tallowedSignersFile: allowedSignersFile,\n\t\t};\n\t}\n\n\t@debug()\n\tasync validateSigningSetup(repoPath: string): Promise<ValidationResult> {\n\t\tconst config = await this.getSigningConfig(repoPath);\n\n\t\tif (!config.signingKey) {\n\t\t\treturn { valid: false, error: 'No signing key configured' };\n\t\t}\n\n\t\t// Basic validation: just check that a signing key is configured\n\t\t// Git will handle the actual validation when signing commits\n\t\treturn { valid: true };\n\t}\n\n\t@debug()\n\tasync setSigningConfig(\n\t\trepoPath: string,\n\t\tconfig: Partial<SigningConfig>,\n\t\toptions?: { global?: boolean },\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tif (config.enabled != null) {\n\t\t\t\tawait this.setConfig(repoPath, 'commit.gpgsign', config.enabled ? 'true' : 'false', options);\n\t\t\t}\n\t\t\tif (config.format != null) {\n\t\t\t\tawait this.setConfig(repoPath, 'gpg.format', config.format, options);\n\t\t\t}\n\t\t\tif (config.signingKey != null) {\n\t\t\t\tawait this.setConfig(repoPath, 'user.signingkey', config.signingKey, options);\n\t\t\t}\n\t\t\tif (config.gpgProgram != null) {\n\t\t\t\tawait this.setConfig(repoPath, 'gpg.program', config.gpgProgram, options);\n\t\t\t}\n\t\t\tif (config.sshProgram != null) {\n\t\t\t\tawait this.setConfig(repoPath, 'gpg.ssh.program', config.sshProgram, options);\n\t\t\t}\n\t\t\tif (config.allowedSignersFile != null) {\n\t\t\t\tawait this.setConfig(repoPath, 'gpg.ssh.allowedSignersFile', config.allowedSignersFile, options);\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\tgetSigningConfigFlags(config: SigningConfig): string[] {\n\t\tconst flags: string[] = [];\n\n\t\tif (config.gpgProgram) {\n\t\t\tflags.push('-c', `gpg.program=${config.gpgProgram}`);\n\t\t}\n\t\tif (config.format && config.format !== 'gpg') {\n\t\t\tflags.push('-c', `gpg.format=${config.format}`);\n\t\t}\n\t\tif (config.sshProgram) {\n\t\t\tflags.push('-c', `gpg.ssh.program=${config.sshProgram}`);\n\t\t}\n\t\tif (config.allowedSignersFile) {\n\t\t\tflags.push('-c', `gpg.ssh.allowedSignersFile=${config.allowedSignersFile}`);\n\t\t}\n\n\t\treturn flags;\n\t}\n\n\tasync getRepositoryInfo(\n\t\tcwd: string,\n\t): Promise<\n\t\t| { repoPath: string; gitDir: string; commonGitDir: string | undefined; superprojectPath: string | undefined }\n\t\t| [safe: true, repoPath: string]\n\t\t| [safe: false]\n\t\t| []\n\t> {\n\t\tlet result;\n\n\t\tif (this.context.workspace?.isTrusted === false) {\n\t\t\ttry {\n\t\t\t\tawait fs.stat(joinPaths(cwd, 'HEAD'));\n\t\t\t\tresult = await this.git.run(\n\t\t\t\t\t{ cwd: cwd, errors: 'throw', configs: ['-C', cwd] },\n\t\t\t\t\t'rev-parse',\n\t\t\t\t\t'--show-cdup',\n\t\t\t\t);\n\t\t\t\tif (!result.stdout.trim()) {\n\t\t\t\t\tLogger.warn(`Skipping (untrusted); bare clone repository detected in '${cwd}'`);\n\t\t\t\t\treturn emptyArray as [];\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// If this throws, we should be good to open the repo\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\tresult = await this.git.run(\n\t\t\t\t{ cwd: cwd, errors: 'throw' },\n\t\t\t\t'rev-parse',\n\t\t\t\t'--show-toplevel',\n\t\t\t\t'--git-dir',\n\t\t\t\t'--git-common-dir',\n\t\t\t\t'--show-superproject-working-tree',\n\t\t\t);\n\t\t\tif (!result.stdout) return emptyArray as [];\n\n\t\t\t// Output is 3-4 lines: show-toplevel, git-dir, git-common-dir, [show-superproject-working-tree]\n\t\t\t// The 4th line is only present for submodules\n\t\t\tconst lines = result.stdout.split('\\n').map(r => r.trimStart());\n\t\t\tconst [repoPath, dotGitPath, commonDotGitPath, superprojectPath] = lines;\n\n\t\t\tif (!repoPath) return emptyArray as [];\n\n\t\t\tconst normalizedRepoPath = normalizePath(repoPath.replace(/[\\r|\\n]+$/, ''));\n\n\t\t\tlet gitDir = dotGitPath;\n\t\t\tif (gitDir && !isAbsolute(gitDir)) {\n\t\t\t\tgitDir = joinPaths(cwd, gitDir);\n\t\t\t}\n\t\t\tgitDir = normalizePath(gitDir);\n\n\t\t\tlet commonGitDir: string | undefined;\n\t\t\tif (commonDotGitPath) {\n\t\t\t\tcommonGitDir = commonDotGitPath;\n\t\t\t\tif (!isAbsolute(commonGitDir)) {\n\t\t\t\t\tcommonGitDir = joinPaths(cwd, commonGitDir);\n\t\t\t\t}\n\t\t\t\tcommonGitDir = normalizePath(commonGitDir);\n\t\t\t\tif (commonGitDir === gitDir) {\n\t\t\t\t\tcommonGitDir = undefined;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\trepoPath: normalizedRepoPath,\n\t\t\t\tgitDir: gitDir,\n\t\t\t\tcommonGitDir: commonGitDir,\n\t\t\t\tsuperprojectPath: superprojectPath?.trim() || undefined,\n\t\t\t};\n\t\t} catch (ex: any) {\n\t\t\tif (ex instanceof WorkspaceUntrustedError) return emptyArray as [];\n\n\t\t\tconst unsafeMatch =\n\t\t\t\t/(?:^fatal:\\s*detected dubious ownership in repository at '([^']+)'|unsafe repository \\('([^']+)' is owned by someone else\\))[\\s\\S]*(git config --global --add safe\\.directory [^\\n\\u2022]+)/m.exec(\n\t\t\t\t\tex.stderr,\n\t\t\t\t);\n\t\t\tif (unsafeMatch != null) {\n\t\t\t\tLogger.warn(\n\t\t\t\t\t`Skipping; unsafe repository detected in '${unsafeMatch[1] || unsafeMatch[2]}'; run '${\n\t\t\t\t\t\tunsafeMatch[3]\n\t\t\t\t\t}' to allow it`,\n\t\t\t\t);\n\t\t\t\treturn [false];\n\t\t\t}\n\n\t\t\tconst inDotGit = /this operation must be run in a work tree/.test(ex.stderr);\n\t\t\tif (inDotGit && this.context.workspace?.isTrusted !== false) {\n\t\t\t\tresult = await this.git.run({ cwd: cwd, errors: 'ignore' }, 'rev-parse', '--is-bare-repository');\n\t\t\t\tif (result.stdout.trim() === 'true') {\n\t\t\t\t\tconst result = await this.revParseGitDir(cwd);\n\t\t\t\t\tconst repoPath = result?.commonPath ?? result?.path;\n\t\t\t\t\tif (repoPath?.length) return [true, repoPath];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (inDotGit || ex.code === 'ENOENT') {\n\t\t\t\tlet exists = inDotGit ? false : await fsExists(cwd);\n\t\t\t\tif (!exists) {\n\t\t\t\t\tdo {\n\t\t\t\t\t\tconst parent = dirname(cwd);\n\t\t\t\t\t\tif (parent === cwd || parent.length === 0) return emptyArray as [];\n\n\t\t\t\t\t\tcwd = parent;\n\t\t\t\t\t\texists = await fsExists(cwd);\n\t\t\t\t\t} while (!exists);\n\n\t\t\t\t\treturn this.getRepositoryInfo(cwd);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn emptyArray as [];\n\t\t}\n\t}\n\n\tprivate async revParseGitDir(cwd: string): Promise<{ path: string; commonPath?: string } | undefined> {\n\t\tconst result = await this.git.run({ cwd: cwd, errors: 'ignore' }, 'rev-parse', '--git-dir', '--git-common-dir');\n\t\tif (!result.stdout) return undefined;\n\n\t\tlet [dotGitPath, commonDotGitPath] = result.stdout.split('\\n').map(r => r.trimStart());\n\n\t\tif (!isAbsolute(dotGitPath)) {\n\t\t\tdotGitPath = joinPaths(cwd, dotGitPath);\n\t\t}\n\t\tdotGitPath = normalizePath(dotGitPath);\n\n\t\tif (commonDotGitPath) {\n\t\t\tif (!isAbsolute(commonDotGitPath)) {\n\t\t\t\tcommonDotGitPath = joinPaths(cwd, commonDotGitPath);\n\t\t\t}\n\t\t\tcommonDotGitPath = normalizePath(commonDotGitPath);\n\n\t\t\treturn { path: dotGitPath, commonPath: commonDotGitPath !== dotGitPath ? commonDotGitPath : undefined };\n\t\t}\n\n\t\treturn { path: dotGitPath };\n\t}\n\n\t/**\n\t * Ensures the `.git/gk/` folder exists, but only if the parent `.git` directory already exists.\n\t * This prevents creating stray `.git` directories if the computed path is wrong.\n\t * Returns `true` if the folder was ensured, `false` if the parent `.git` does not exist.\n\t */\n\tprivate async ensureGkConfigFolder(\n\t\tgkConfigFolder: string,\n\t\tscope: ReturnType<typeof getScopedLogger>,\n\t): Promise<boolean> {\n\t\t// Verify the .git directory already exists — never create it from scratch\n\t\tconst dotGitDir = joinPaths(gkConfigFolder, '..');\n\t\ttry {\n\t\t\tawait fs.stat(dotGitDir);\n\t\t} catch {\n\t\t\tscope?.warn(`Skipping GK config write — expected git directory '${dotGitDir}' does not exist`);\n\t\t\treturn false;\n\t\t}\n\n\t\ttry {\n\t\t\tawait fs.mkdir(gkConfigFolder, { recursive: true });\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex, `Failed to create '${gkConfigFolder}' directory`);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tprivate _migratedRepos = new Set<string>();\n\n\t/**\n\t * One-time migration of GK config entries from regular git config to `.git/gk/config`.\n\t * If `.git/gk/config` already exists, assumes migration is complete (or data is already there).\n\t * Preserves existing `.git/gk/config` values as source of truth (won't overwrite).\n\t * Removes migrated keys from regular git config to stop cluttering it.\n\t */\n\t@gate()\n\t@debug()\n\tprivate async migrateGkConfigFromGitConfig(repoPath: string): Promise<void> {\n\t\tif (this._migratedRepos.has(repoPath)) return;\n\n\t\tconst scope = getScopedLogger();\n\n\t\tconst gkConfigPath = await this.getGkConfigPath(repoPath);\n\t\tif (!gkConfigPath) {\n\t\t\tthis._migratedRepos.add(repoPath);\n\t\t\treturn;\n\t\t}\n\n\t\tconst gkConfigFolder = joinPaths(gkConfigPath, '..');\n\n\t\t// If .git/gk/config already exists, consider migration done — it was either\n\t\t// already migrated or values were written there directly via setGkConfig\n\t\ttry {\n\t\t\tawait fs.stat(gkConfigPath);\n\t\t\tthis._migratedRepos.add(repoPath);\n\t\t\treturn;\n\t\t} catch {\n\t\t\t// file doesn't exist, proceed with migration\n\t\t}\n\n\t\t// If .git/gk/config doesn't exist, create an empty file to prevent multiple migration attempts in future sessions\n\t\tif (!(await this.ensureGkConfigFolder(gkConfigFolder, scope))) return;\n\n\t\ttry {\n\t\t\tawait fs.writeFile(gkConfigPath, new Uint8Array());\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex, `Failed to create '${gkConfigPath}' file`);\n\t\t}\n\n\t\t// Read legacy gk-* keys from regular git config\n\t\tlet migrateConfig: Map<string, string>;\n\t\ttry {\n\t\t\tmigrateConfig = await this.getConfigRegexCore(repoPath, '^branch\\\\..*\\\\.gk-', { runGitLocally: true });\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex, 'Failed to read legacy GK config entries');\n\t\t\tthis._migratedRepos.add(repoPath);\n\t\t\treturn;\n\t\t}\n\n\t\tif (!migrateConfig.size) {\n\t\t\tthis._migratedRepos.add(repoPath);\n\t\t\treturn;\n\t\t}\n\n\t\tscope?.info(`Migrating ${String(migrateConfig.size)} GK config entries from git config to .git/gk/config`);\n\n\t\t// Copy legacy entries to .git/gk/config\n\t\tfor (const [key, value] of [...migrateConfig]) {\n\t\t\ttry {\n\t\t\t\tawait this.setConfigCore(repoPath, key, value, { file: gkConfigPath });\n\t\t\t} catch (ex) {\n\t\t\t\tscope?.error(ex, `Failed to migrate key '${key}' to GK config`);\n\t\t\t\t// If we failed to migrate, delete it from the list so we won't try to remove it from git config later\n\t\t\t\tmigrateConfig.delete(key);\n\t\t\t}\n\t\t}\n\n\t\t// Remove legacy keys from regular git config (use --unset-all defensively)\n\t\tfor (const [key] of migrateConfig) {\n\t\t\ttry {\n\t\t\t\tawait this.git.run(\n\t\t\t\t\t{ cwd: repoPath, errors: 'ignore', runLocally: true },\n\t\t\t\t\t'config',\n\t\t\t\t\t'--local',\n\t\t\t\t\t'--unset-all',\n\t\t\t\t\tkey,\n\t\t\t\t);\n\t\t\t} catch (ex) {\n\t\t\t\tscope?.error(ex, `Failed to remove migrated key '${key}' from git config`);\n\t\t\t}\n\t\t}\n\n\t\t// Clear caches since we modified both config files\n\t\tthis.cache.clearCaches(repoPath, 'config', 'gkConfig');\n\n\t\tthis._migratedRepos.add(repoPath);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AA2BA,MAAM,oBAAoB;AAC1B,MAAM,aAA+B,OAAO,OAAO,CAAC,CAAC;;AAGrD,MAAM,qBAAqB;;;;;;AAO3B,SAAgB,yBAAyB,KAAqB;CAC7D,MAAM,QAAQ,IAAI,QAAQ,GAAG;CAC7B,IAAI,UAAU,IAAI,OAAO,IAAI,YAAY;CAEzC,MAAM,OAAO,IAAI,YAAY,GAAG;CAGhC,IAAI,UAAU,MAAM,OAAO,IAAI,YAAY;CAC3C,OAAO,GAAG,IAAI,MAAM,GAAG,KAAK,CAAC,CAAC,YAAY,IAAI,IAAI,MAAM,OAAO,IAAI,IAAI,IAAI,MAAM,IAAI,CAAC,CAAC,YAAY;AACpG;;;;;;;;;;;;;;;;AAiBA,SAAgB,uBACf,MACA,SACsB;CACtB,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I,EAAE,cAAc,EAAE,WAAW,SAAS,IAAI,IACrH,CAAC,CAAA,GAAA,qBAAA,WAAA,aAAA,IAAA;AA8CA,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,eAAA,IAAA;AASN,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,oBAAA,IAAA;AAwEN,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,eAAA,IAAA;AAoDN,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,+BAAA,IAAA;AAKN,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,+BAAA,IAAA;AAgLN,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,oBAAA,IAAA;AA+BN,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,wBAAA,IAAA;AAaN,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,oBAAA,IAAA;AAkON,WAAA,CAAA,KAAK,GACL,MAAM,CAAA,GAAA,qBAAA,WAAA,gCAAA,IAAA"}
|
|
1
|
+
{"version":3,"file":"config.js","names":["process_env","fs"],"sources":["../../../../git-cli/src/providers/config.ts"],"sourcesContent":["import { promises as fs } from 'fs';\nimport { hostname, userInfo } from 'os';\nimport { env as process_env } from 'process';\nimport type { Cache, GkConfigInvalidationTarget, GkReconcileOutcome } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport { WorkspaceUntrustedError } from '@gitlens/git/errors.js';\nimport type { GitDir } from '@gitlens/git/models/repository.js';\nimport type { SigningConfig, SigningFormat, ValidationResult } from '@gitlens/git/models/signature.js';\nimport type { GitUser } from '@gitlens/git/models/user.js';\nimport type {\n\tDeprecatedGkConfigKeys,\n\tGitConfigKeys,\n\tGitConfigSubProvider,\n\tGitConfigType,\n\tGkConfigKeys,\n} from '@gitlens/git/providers/config.js';\nimport { gate } from '@gitlens/utils/decorators/gate.js';\nimport { debug, trace } from '@gitlens/utils/decorators/log.js';\nimport { first, some } from '@gitlens/utils/iterable.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { dirname, getBestPath, isAbsolute, joinPaths, normalizePath } from '@gitlens/utils/path.js';\nimport { fileUri } from '@gitlens/utils/uri.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport { fsExists } from '../exec/exec.js';\nimport type { Git } from '../exec/git.js';\n\nconst mappedAuthorRegex = /(.+)\\s<(.+)>/;\nconst emptyArray: readonly never[] = Object.freeze([]);\n\n/** Catch-all pattern matching every key in `.git/gk/config` for the one-shot bulk read. */\nconst gkConfigAllPattern = '.';\n\n/**\n * Canonicalizes a git config key for lookup against `--get-regexp` output, which git emits with the\n * section and variable-name lowercased and only the subsection case-preserved. Without this a\n * subsection-less key like `gk.defaultRemote` would miss the lowercased `gk.defaultremote` in the map.\n */\nexport function canonicalizeGitConfigKey(key: string): string {\n\tconst first = key.indexOf('.');\n\tif (first === -1) return key.toLowerCase();\n\n\tconst last = key.lastIndexOf('.');\n\t// `section.name` (no subsection) → fully lowercased; `section.subsection.name` → lowercase\n\t// section + name, preserve the case-sensitive subsection in the middle.\n\tif (first === last) return key.toLowerCase();\n\treturn `${key.slice(0, first).toLowerCase()}${key.slice(first, last)}${key.slice(last).toLowerCase()}`;\n}\n\n/**\n * Parses git config --get-regex output into a Map.\n * The output format is \"key value\" per line, where key and value are space-separated.\n *\n * A line with NO space at all is git's rendering of a bareword/valueless entry (`key`, no `=`) — git's\n * OWN config parser reads that as boolean TRUE (git-config(1): \"a variable defined without `= <value>`\n * is taken as true\"), confirmed against git's `format_config` (builtin/config.c): the key-delimiter is\n * appended unconditionally, then backed out ONLY when the stored value is NULL (the bareword case) —\n * an explicit empty value (`key =`) is a real, non-NULL empty string, so its line KEEPS the trailing\n * space and is already handled by the branch below, byte-distinct from a bareword line.\n *\n * By default a bareword line is skipped (the historical behavior, which reads as \"unset\" — wrong, but\n * safe); pass `includeValueless` to map it to the literal string `'true'` instead, so `parseGitBoolean`\n * and callers checking `.has()` for \"configured\" both read it correctly.\n */\nexport function parseConfigRegexOutput(\n\tdata: string | undefined,\n\toptions?: { includeValueless?: boolean },\n): Map<string, string> {\n\tconst configMap = new Map<string, string>();\n\tif (!data) return configMap;\n\n\tfor (const line of data.split('\\n')) {\n\t\tif (!line) continue;\n\n\t\tconst spaceIndex = line.indexOf(' ');\n\t\tif (spaceIndex === -1) {\n\t\t\tif (options?.includeValueless) {\n\t\t\t\tconfigMap.set(line, 'true');\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tconfigMap.set(line.substring(0, spaceIndex), line.substring(spaceIndex + 1));\n\t}\n\n\treturn configMap;\n}\n\nexport function parseGitBoolean(value: string | undefined): boolean {\n\tif (value == null) return false;\n\n\tconst normalized = value.toLowerCase().trim();\n\treturn normalized === 'true' || normalized === 'yes' || normalized === 'on' || normalized === '1';\n}\n\n/** Whether a git config value spells boolean-false (`false`/`no`/`off`/`0`/empty), per git's maybe-bool parsing. */\nexport function isGitBooleanFalse(value: string): boolean {\n\tconst normalized = value.toLowerCase().trim();\n\treturn (\n\t\tnormalized === '' || normalized === 'false' || normalized === 'no' || normalized === 'off' || normalized === '0'\n\t);\n}\n\nexport class ConfigGitSubProvider implements GitConfigSubProvider {\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\t\tthis.cache.setGkConfigReconciler((repoPath, priorSnapshot) => this.reconcileGkConfig(repoPath, priorSnapshot));\n\t}\n\n\t/**\n\t * In-flight gk-config reconciles keyed by commonPath. `pending` records that another `'gkConfig'`\n\t * event landed mid-pass, so one trailing pass runs after the current one settles. `paths` holds every\n\t * worktree path that reported the change, mapped to its close generation at that moment — the pass\n\t * reads through one that's still open and notifies all of them.\n\t */\n\tprivate readonly _gkConfigReconciles = new Map<string, { pending: boolean; paths: Map<string, number> }>();\n\n\t/**\n\t * Pending `setGkConfig` writes keyed by `(commonPath, key, value, skip-option)`. Concurrent\n\t * callers writing the same `(key, value)` pair share the in-flight Promise so only one\n\t * `git config --set` subprocess actually runs. Cleared on settle.\n\t */\n\tprivate readonly _pendingGkConfigWrites = new Map<string, Promise<void>>();\n\n\t@trace()\n\tgetConfig(\n\t\trepoPath: string | undefined,\n\t\tkey: GitConfigKeys,\n\t\toptions?: { global?: boolean; runGitLocally?: boolean; type?: GitConfigType },\n\t): Promise<string | undefined> {\n\t\tconst global = options?.global || repoPath == null;\n\t\treturn this.cache.getConfig(global ? undefined : repoPath, key, () =>\n\t\t\tthis.getConfigCore(repoPath, key, options),\n\t\t);\n\t}\n\n\tprivate async getConfigCore(\n\t\trepoPath: string | undefined,\n\t\tkey: string,\n\t\toptions?: { file?: string; global?: boolean; runGitLocally?: boolean; type?: GitConfigType },\n\t): Promise<string | undefined> {\n\t\tconst args = ['config', '--get'];\n\t\tif (options?.file) {\n\t\t\targs.push('-f', options.file);\n\t\t} else if (options?.global || repoPath == null) {\n\t\t\targs.push('--global');\n\t\t}\n\t\tif (options?.type) {\n\t\t\targs.push(`--type=${options.type}`);\n\t\t}\n\t\targs.push(key);\n\n\t\tconst result = await this.git.run(\n\t\t\t{ cwd: repoPath ?? '', errors: 'ignore', runLocally: options?.runGitLocally },\n\t\t\t...args,\n\t\t);\n\t\treturn result.stdout.trim() || undefined;\n\t}\n\n\t@trace()\n\tgetConfigRegex(\n\t\trepoPath: string | undefined,\n\t\tpattern: string,\n\t\toptions?: { global?: boolean; runGitLocally?: boolean },\n\t): Promise<Map<string, string>> {\n\t\tconst global = options?.global || repoPath == null;\n\t\treturn this.cache.getConfigRegex(global ? undefined : repoPath, pattern, () =>\n\t\t\tthis.getConfigRegexCore(repoPath, pattern, options),\n\t\t);\n\t}\n\n\tprivate async getConfigRegexCore(\n\t\trepoPath: string | undefined,\n\t\tpattern: string,\n\t\toptions?: { file?: string; global?: boolean; runGitLocally?: boolean },\n\t): Promise<Map<string, string>> {\n\t\tconst args = ['config', '--get-regex'];\n\t\tif (options?.file) {\n\t\t\targs.push('-f', options.file);\n\t\t} else if (options?.global || repoPath == null) {\n\t\t\targs.push('--global');\n\t\t}\n\t\targs.push(pattern);\n\n\t\tconst result = await this.git.run(\n\t\t\t{ cwd: repoPath ?? '', errors: 'ignore', runLocally: options?.runGitLocally },\n\t\t\t...args,\n\t\t);\n\t\t// Deliberately NOT `.trim()`-ed: an explicit-empty value's LAST line ends in a meaningful trailing\n\t\t// space, and `.trim()`-ing the whole (possibly multi-line) buffer strips it — `parseConfigRegexOutput`\n\t\t// already skips the blank line a trailing newline produces, so no trim is needed.\n\t\treturn parseConfigRegexOutput(result.stdout);\n\t}\n\n\t@debug()\n\tasync setConfig(\n\t\trepoPath: string | undefined,\n\t\tkey: GitConfigKeys,\n\t\tvalue: string | undefined,\n\t\toptions?: { file?: string; global?: boolean },\n\t): Promise<void> {\n\t\tawait this.setConfigCore(repoPath, key, value, options);\n\n\t\t// A branch's upstream (`remote`/`merge`) is read back through the cached branch list, which a\n\t\t// `'config'` reset alone leaves serving the old tracking info.\n\t\tif (repoPath != null && !options?.file && /^branch\\..+\\.(?:remote|merge)$/i.test(key)) {\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'branches');\n\t\t}\n\t}\n\n\tprivate async setConfigCore(\n\t\trepoPath: string | undefined,\n\t\tkey: string,\n\t\tvalue: string | undefined,\n\t\toptions?: { file?: string; global?: boolean },\n\t): Promise<void> {\n\t\tconst args: string[] = ['config'];\n\n\t\tif (options?.file) {\n\t\t\targs.push('-f', options.file);\n\t\t} else {\n\t\t\tconst global = options?.global || repoPath == null;\n\t\t\targs.push(global ? '--global' : '--local');\n\t\t}\n\n\t\tif (value == null) {\n\t\t\targs.push('--unset', key);\n\t\t} else {\n\t\t\targs.push(key, value);\n\t\t}\n\n\t\tawait this.git.run({ cwd: repoPath ?? '', runLocally: true }, ...args);\n\n\t\t// Only invalidate cache when not using a custom file (custom files aren't cached)\n\t\tif (!options?.file) {\n\t\t\tconst global = options?.global || repoPath == null;\n\t\t\t// Invalidate the cached value for this key and clear all regex patterns for this scope\n\t\t\tthis.cache.deleteConfig(global ? undefined : repoPath, key);\n\t\t}\n\t}\n\n\t@gate()\n\t@debug()\n\tasync getCurrentUser(repoPath: string): Promise<GitUser | undefined> {\n\t\tif (!repoPath) return undefined;\n\n\t\tconst scope = getScopedLogger();\n\n\t\tconst cached = this.cache.currentUser.get(repoPath);\n\t\tif (cached != null) return cached;\n\t\t// If we found null, user data was not found - don't bother trying again\n\t\tif (cached === null) return undefined;\n\n\t\tconst user: GitUser = { name: undefined, email: undefined };\n\n\t\ttry {\n\t\t\tconst configMap = await this.getConfigRegex(repoPath, '^user\\\\.(name|email)$', {\n\t\t\t\trunGitLocally: true,\n\t\t\t});\n\t\t\tif (configMap.size) {\n\t\t\t\tuser.name = configMap.get('user.name');\n\t\t\t\tuser.email = configMap.get('user.email');\n\t\t\t} else {\n\t\t\t\tuser.name =\n\t\t\t\t\tprocess_env.GIT_AUTHOR_NAME || process_env.GIT_COMMITTER_NAME || userInfo()?.username || undefined;\n\t\t\t\tif (!user.name) {\n\t\t\t\t\t// If we found no user data, mark it so we won't bother trying again\n\t\t\t\t\tthis.cache.currentUser.set(repoPath, null);\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tuser.email =\n\t\t\t\t\tprocess_env.GIT_AUTHOR_EMAIL ||\n\t\t\t\t\tprocess_env.GIT_COMMITTER_EMAIL ||\n\t\t\t\t\tprocess_env.EMAIL ||\n\t\t\t\t\t`${user.name}@${hostname()}`;\n\t\t\t}\n\n\t\t\tconst author = `${user.name} <${user.email}>`;\n\t\t\t// Check if there is a mailmap for the current user\n\t\t\tconst result = await this.git.run({ cwd: repoPath, errors: 'ignore' }, 'check-mailmap', author);\n\n\t\t\tif (result.stdout && result.stdout !== author) {\n\t\t\t\tconst match = mappedAuthorRegex.exec(result.stdout);\n\t\t\t\tif (match != null) {\n\t\t\t\t\t[, user.name, user.email] = match;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.cache.currentUser.set(repoPath, user);\n\t\t\treturn user;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\n\t\t\t// Mark it so we won't bother trying again\n\t\t\tthis.cache.currentUser.set(repoPath, null);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@gate()\n\t@trace({ exit: r => `returned ${r}` })\n\tasync getDefaultWorktreePath(repoPath: string): Promise<string | undefined> {\n\t\tconst gitDir = await this.getGitDir(repoPath);\n\t\tif (gitDir == null) return undefined;\n\n\t\tconst basePath = (gitDir.commonUri ?? gitDir.uri).fsPath;\n\t\treturn getBestPath(normalizePath(joinPaths(basePath, '..')));\n\t}\n\n\t@gate()\n\t@trace({\n\t\texit: r =>\n\t\t\t`returned ${r.uri.toString(true)}, commonUri=${r.commonUri?.toString(true)}, parentUri=${r.parentUri?.toString(true)}`,\n\t})\n\tasync getGitDir(repoPath: string): Promise<GitDir> {\n\t\tconst cached = this.cache.gitDir.get(repoPath);\n\t\tif (cached != null) return cached;\n\n\t\tconst scope = getScopedLogger();\n\t\tconst repoInfo = await this.getRepositoryInfo(repoPath);\n\n\t\tlet gitDir: GitDir;\n\t\tif (!Array.isArray(repoInfo) && repoInfo != null) {\n\t\t\tgitDir = {\n\t\t\t\turi: fileUri(repoInfo.gitDir),\n\t\t\t\tcommonUri: repoInfo.commonGitDir ? fileUri(repoInfo.commonGitDir) : undefined,\n\t\t\t\tparentUri: repoInfo.superprojectPath ? fileUri(repoInfo.superprojectPath) : undefined,\n\t\t\t};\n\t\t} else {\n\t\t\tgitDir = {\n\t\t\t\turi: this.provider.getAbsoluteUri(joinPaths(repoPath, '.git'), repoPath),\n\t\t\t};\n\n\t\t\tconst gitDirPath = gitDir.uri.toString(true);\n\t\t\tscope?.warn(`rev-parse failed for '${repoPath}'; falling back to '${gitDirPath}'`);\n\t\t\tthis.context.hooks?.operations?.onGitDirResolveFailed?.(\n\t\t\t\trepoPath,\n\t\t\t\tgitDirPath,\n\t\t\t\t`rev_parse returned ${JSON.stringify(repoInfo)}`,\n\t\t\t);\n\t\t}\n\t\tthis.cache.gitDir.set(repoPath, gitDir);\n\n\t\treturn gitDir;\n\t}\n\n\t/**\n\t * Gets the path to the .git/gk/config file for storing GitKraken-specific metadata.\n\t * Uses commonPath for worktrees so all worktrees share the same data.\n\t */\n\tprivate async getGkConfigPath(repoPath: string): Promise<string | undefined> {\n\t\tconst gitDir = await this.getGitDir(repoPath);\n\t\tif (gitDir == null) return undefined;\n\n\t\t// Use commonUri (main .git dir) for worktrees, otherwise use uri\n\t\tconst basePath = (gitDir.commonUri ?? gitDir.uri).fsPath;\n\t\treturn joinPaths(basePath, 'gk', 'config');\n\t}\n\n\t@debug()\n\tasync getGkConfig(repoPath: string, key: GkConfigKeys | DeprecatedGkConfigKeys): Promise<string | undefined> {\n\t\t// Served in-memory from a single bulk read of the whole `.git/gk/config` (no gk read needs `--type`).\n\t\t// Canonicalize the key the way git does for `--get-regexp` output so subsection-less keys\n\t\t// (e.g. `gk.defaultRemote`) match, and coerce an empty value to undefined to match the old\n\t\t// `git config --get` (`.trim() || undefined`) contract.\n\t\treturn (await this.getGkConfigMap(repoPath)).get(canonicalizeGitConfigKey(key)) || undefined;\n\t}\n\n\t@debug()\n\tasync getGkConfigRegex(repoPath: string, pattern: string): Promise<Map<string, string>> {\n\t\tconst all = await this.getGkConfigMap(repoPath);\n\n\t\t// Filter the bulk map in-memory. The old path passed `pattern` to `git config --get-regex`\n\t\t// (errors ignored → empty result on a bad pattern); preserve that no-throw contract here\n\t\t// rather than letting an invalid-JS pattern reject the read.\n\t\tlet re: RegExp;\n\t\ttry {\n\t\t\tre = new RegExp(pattern);\n\t\t} catch {\n\t\t\treturn new Map();\n\t\t}\n\n\t\tconst result = new Map<string, string>();\n\t\tfor (const [k, v] of all) {\n\t\t\tif (re.test(k)) {\n\t\t\t\tresult.set(k, v);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Reads the entire `.git/gk/config` in one `git config --get-regexp` and caches the parsed map\n\t * per commonPath. Per-key (getGkConfig) and per-namespace (getGkConfigRegex) lookups are served\n\t * from this single cached read — so a branch-overview render that fans out across several gk\n\t * namespaces costs one `git config` call instead of one per namespace.\n\t */\n\tprivate async getGkConfigMap(repoPath: string): Promise<Map<string, string>> {\n\t\t// Migrate BEFORE populating the cache, not inside the factory: a first-time migration calls\n\t\t// clearCaches('gkConfig'), which would otherwise evict the in-flight gkConfigMap entry the\n\t\t// cache wrapper synchronously stored and force a redundant bulk re-read.\n\t\tawait this.migrateGkConfigFromGitConfig(this.cache.getCommonPath(repoPath));\n\t\treturn this.cache.getGkConfigMap(repoPath, async cacheable => {\n\t\t\tconst { map, failed } = await this.getGkConfigRegexCore(repoPath, gkConfigAllPattern);\n\t\t\t// This map has no TTL and everything gk-related reads through it, so a failed read cached as an\n\t\t\t// empty map would report every branch as having no stored base or merge target for the session —\n\t\t\t// and would make the section-cleanup pre-checks skip real work. Only cache a read that happened.\n\t\t\tif (failed) {\n\t\t\t\tcacheable.invalidate();\n\t\t\t}\n\t\t\treturn map;\n\t\t});\n\t}\n\n\tprivate async getGkConfigRegexCore(\n\t\trepoPath: string,\n\t\tpattern: string,\n\t): Promise<{ map: Map<string, string>; failed: boolean }> {\n\t\tconst gkConfigPath = await this.getGkConfigPath(repoPath);\n\t\t// No `.git/gk/config` yet is a real answer, not a failure — a repo GitLens has never written to.\n\t\tif (!gkConfigPath) return { map: new Map(), failed: false };\n\n\t\tconst result = await this.git.run(\n\t\t\t{ cwd: repoPath, errors: 'ignore', runLocally: true },\n\t\t\t'config',\n\t\t\t'--get-regex',\n\t\t\t'-f',\n\t\t\tgkConfigPath,\n\t\t\tpattern,\n\t\t);\n\t\t// `--get-regex` exits 1 when nothing matches, which IS an answer (an empty gk config).\n\t\tconst exited = result.completion.status === 'exited';\n\t\treturn {\n\t\t\t// Deliberately NOT `.trim()`-ed — see `getConfigRegexCore`'s comment: it strips the trailing\n\t\t\t// space that marks an explicit-empty value's LAST line, silently dropping it from the map.\n\t\t\tmap: parseConfigRegexOutput(result.stdout),\n\t\t\tfailed: !exited || (result.exitCode !== 0 && result.exitCode !== 1),\n\t\t};\n\t}\n\n\t@debug()\n\tasync setGkConfig(\n\t\trepoPath: string,\n\t\tkey: GkConfigKeys | DeprecatedGkConfigKeys,\n\t\tvalue: string | undefined,\n\t\toptions?: { skipInvalidation?: readonly GkConfigInvalidationTarget[] },\n\t): Promise<void> {\n\t\t// Encode the skip-invalidation option in the dedup key: a self-write (with skip targets)\n\t\t// and a user-driven write of the same `(key, value)` (no skip targets) have different\n\t\t// cache-invalidation semantics, so sharing their Promise would silently let the user-driven\n\t\t// write skip invalidation. Sort the array so callers passing the same targets in different\n\t\t// orders share a single in-flight write.\n\t\tconst commonPath = this.cache.getCommonPath(repoPath);\n\t\tconst skipKey = options?.skipInvalidation?.length ? options.skipInvalidation.toSorted().join(',') : '';\n\t\tconst dedupKey = `${commonPath}\\0${key}\\0${value ?? ''}\\0${skipKey}`;\n\n\t\tconst pending = this._pendingGkConfigWrites.get(dedupKey);\n\t\tif (pending != null) return pending;\n\n\t\tconst promise = this.setGkConfigCore(repoPath, key, value, options);\n\t\tthis._pendingGkConfigWrites.set(dedupKey, promise);\n\t\t// Swallow the cleanup chain's rejection so a failed write doesn't surface as an unhandled\n\t\t// rejection separate from the caller's own handling of the returned promise.\n\t\tvoid promise.finally(() => this._pendingGkConfigWrites.delete(dedupKey)).catch(() => {});\n\t\treturn promise;\n\t}\n\n\tprivate async setGkConfigCore(\n\t\trepoPath: string,\n\t\tkey: GkConfigKeys | DeprecatedGkConfigKeys,\n\t\tvalue: string | undefined,\n\t\toptions?: { skipInvalidation?: readonly GkConfigInvalidationTarget[] },\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst gkConfigPath = await this.getGkConfigPath(repoPath);\n\t\tif (!gkConfigPath) return;\n\n\t\tconst gkConfigFolder = joinPaths(gkConfigPath, '..');\n\n\t\tif (!(await this.ensureGkConfigFolder(gkConfigFolder, scope))) return;\n\n\t\tawait this.setConfigCore(repoPath, key, value, { file: gkConfigPath });\n\n\t\t// Invalidate the bulk map (so the next read re-fetches) and the derived caches for this key's\n\t\t// ref. The `.git/gk/config` file-watcher also fires `'gkConfig'` shortly after, which reconciles\n\t\t// the same change (see `reconcileGkConfig`) — recording our own write here keeps that later\n\t\t// reconcile from re-diffing this key as an external change.\n\t\tthis.cache.deleteGkConfig(repoPath, key, options);\n\t\tthis.cache.recordGkConfigWrite(repoPath, key, value);\n\t}\n\n\t@debug()\n\tasync removeGkConfigBranchSection(repoPath: string, ref: string): Promise<void> {\n\t\tif (await this.runGkConfigSectionCommand(repoPath, ref, '--remove-section', `branch.${ref}`)) {\n\t\t\tthis.cache.recordGkConfigSectionWrite(repoPath, ref);\n\t\t}\n\t}\n\n\t@debug()\n\tasync renameGkConfigBranchSection(repoPath: string, oldRef: string, newRef: string): Promise<void> {\n\t\t// Clear the destination first, unconditionally. `--rename-section` onto a section that already\n\t\t// exists APPENDS rather than replaces, leaving duplicate keys — and git resolves a duplicated key\n\t\t// to its LAST value, so the orphan left by an earlier branch of this name would win over the\n\t\t// metadata being moved. Doing this outside `runGkConfigSectionCommand` also covers the case where\n\t\t// the source has no gk keys at all, where its pre-check would otherwise skip the whole call and\n\t\t// leave the orphan in place for the renamed branch to inherit.\n\t\tawait this.removeGkConfigBranchSection(repoPath, newRef);\n\t\tif (\n\t\t\tawait this.runGkConfigSectionCommand(\n\t\t\t\trepoPath,\n\t\t\t\toldRef,\n\t\t\t\t'--rename-section',\n\t\t\t\t`branch.${oldRef}`,\n\t\t\t\t`branch.${newRef}`,\n\t\t\t)\n\t\t) {\n\t\t\tthis.cache.recordGkConfigSectionWrite(repoPath, oldRef, newRef);\n\t\t}\n\t}\n\n\t/**\n\t * Runs a section-level `git config` against `.git/gk/config` for `ref`'s section, skipping the\n\t * subprocess entirely when the bulk map (already cached on any warm path) shows that ref has no gk\n\t * keys — the overwhelmingly common case, since most branches never get gk metadata written at all.\n\t *\n\t * Never throws: callers invoke this as bookkeeping after a branch op has already succeeded, so a\n\t * failure here must not be reported as (or roll back) the branch/checkout/worktree operation itself.\n\t * The worst case is metadata that stays behind until the next op on that name.\n\t *\n\t * Returns whether `.git/gk/config` now reflects the command (it ran, or there was nothing to do), so the\n\t * caller can record its own write in the merge-key snapshot only when it actually landed.\n\t */\n\tprivate async runGkConfigSectionCommand(repoPath: string, ref: string, ...args: string[]): Promise<boolean> {\n\t\tconst scope = getScopedLogger();\n\t\ttry {\n\t\t\tconst prefix = `branch.${ref}.`;\n\t\t\tconst map = await this.getGkConfigMap(repoPath);\n\t\t\t// The shortcut needs a map with CONTENT to be trustworthy. A failed bulk read resolves empty\n\t\t\t// (see `getGkConfigMap`) — the cache refuses it, but this caller still holds it — and an empty map\n\t\t\t// read as authoritative would skip the removal entirely, leaving a deleted branch's base,\n\t\t\t// disposition and issue links behind for the next branch reusing that name. When it's empty, run\n\t\t\t// the command: worst case is a no-op on a section that isn't there.\n\t\t\tif (map.size && !some(map.keys(), k => k.startsWith(prefix))) return true;\n\n\t\t\tconst gkConfigPath = await this.getGkConfigPath(repoPath);\n\t\t\tif (!gkConfigPath) return false;\n\t\t\t// `getGkConfigPath` only joins a path, so check the file: with no `.git/gk/config` there is\n\t\t\t// genuinely nothing to remove, and running the command would fail with a fatal we'd then warn\n\t\t\t// about on every branch delete in a repo that has never had gk metadata.\n\t\t\tif (!(await fsExists(gkConfigPath))) return true;\n\n\t\t\tconst result = await this.git.run(\n\t\t\t\t{ cwd: repoPath, runLocally: true, errors: 'ignore' },\n\t\t\t\t'config',\n\t\t\t\t'-f',\n\t\t\t\tgkConfigPath,\n\t\t\t\t...args,\n\t\t\t);\n\t\t\t// `errors: 'ignore'` is deliberate — see the note above on why this must never throw — but that\n\t\t\t// also means the `catch` below never sees a failed write, so without this the metadata silently\n\t\t\t// stays behind (or, on a rename, stays under the old name) with nothing recorded anywhere.\n\t\t\t// Reported, not thrown: the branch op it follows has already succeeded.\n\t\t\tconst succeeded = result.completion.status === 'exited' && result.exitCode === 0;\n\t\t\tif (!succeeded) {\n\t\t\t\tscope?.warn(\n\t\t\t\t\t`Failed to update gk config section for '${ref}' in '${repoPath}': ${\n\t\t\t\t\t\tresult.completion.status === 'exited'\n\t\t\t\t\t\t\t? `git config exited ${result.exitCode}`\n\t\t\t\t\t\t\t: `${result.completion.status} · ${result.completion.error.message}`\n\t\t\t\t\t}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\t// A whole section moved or vanished, which the per-key `deleteGkConfig` cascade can't express.\n\t\t\t// Drop the bulk map so the next read hits disk; the derived caches for the affected ref are\n\t\t\t// evicted by the caller's own `deleteBaseBranchName` plus the `'branches'` cascade it fires.\n\t\t\tthis.cache.deleteGkConfigMap(repoPath);\n\t\t\treturn succeeded;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex, `Failed to update gk config section for '${ref}' in '${repoPath}'`);\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Reconciles a watcher-observed `'gkConfig'` change — registered with the shared `Cache` as its\n\t * gk-config reconciler (see the constructor). Re-reads the bulk map (hard-evicted by\n\t * `Cache.handleGkConfigChanged`, so this hits disk) and diffs it against `priorSnapshot` to cascade\n\t * `baseBranchName`/`branchOverviews` only for refs whose merge-relevant keys actually changed.\n\t *\n\t * Serialized per commonPath: a reconcile is a read-then-diff against a single shared baseline, so\n\t * two overlapping passes would both diff against the same snapshot and the later change could fall\n\t * out entirely. An event arriving mid-pass instead queues one trailing pass, which re-reads and\n\t * diffs against the baseline the previous pass just established.\n\t *\n\t * `.git/gk/config` lives in the common dir, so the watcher delivers one event per worktree sharing it\n\t * (see `WatchGroup.onCommonEvent`). Siblings never run concurrently — the later ones fold into the\n\t * in-flight pass — but folding in arms the trailing pass, so a fan-out costs one extra read that\n\t * re-reads and diffs an unchanged file. However many siblings land while a pass is running, they\n\t * coalesce into that single trailing pass; the cost is the price of never dropping a real change.\n\t * Every reporting path is retained because `Repository` matches the follow-up change event on exact\n\t * path, and a sibling worktree that never receives one would sit on stale derived values.\n\t */\n\tprivate reconcileGkConfig(\n\t\trepoPath: string,\n\t\tpriorSnapshot: ReadonlyMap<string, string> | undefined,\n\t): GkReconcileOutcome | Promise<GkReconcileOutcome> {\n\t\tconst commonPath = this.cache.getCommonPath(repoPath);\n\n\t\tconst inflight = this._gkConfigReconciles.get(commonPath);\n\t\tif (inflight != null) {\n\t\t\tinflight.paths.set(repoPath, this.cache.getCloseGeneration(repoPath));\n\t\t\tinflight.pending = true;\n\t\t\t// Handed to the in-flight pass's trailing loop, so it IS being reconciled — just not by this\n\t\t\t// call. Reporting a failure here would coarse-clear on every write in a burst.\n\t\t\treturn 'deferred';\n\t\t}\n\n\t\tconst entry = { pending: false, paths: new Map([[repoPath, this.cache.getCloseGeneration(repoPath)]]) };\n\t\tthis._gkConfigReconciles.set(commonPath, entry);\n\t\treturn this.runGkConfigReconcile(commonPath, priorSnapshot, entry);\n\t}\n\n\t/** Drops paths that closed since they reported the change; returns whichever remain. */\n\tprivate pruneClosedReconcilePaths(paths: Map<string, number>): Map<string, number> {\n\t\tfor (const [path, generation] of paths) {\n\t\t\tif (this.cache.getCloseGeneration(path) !== generation) {\n\t\t\t\tpaths.delete(path);\n\t\t\t}\n\t\t}\n\t\treturn paths;\n\t}\n\n\tprivate async runGkConfigReconcile(\n\t\tcommonPath: string,\n\t\tpriorSnapshot: ReadonlyMap<string, string> | undefined,\n\t\tentry: { pending: boolean; paths: Map<string, number> },\n\t): Promise<GkReconcileOutcome> {\n\t\tconst scope = getScopedLogger();\n\t\tlet snapshot = priorSnapshot;\n\n\t\ttry {\n\t\t\tdo {\n\t\t\t\tentry.pending = false;\n\n\t\t\t\t// Read through a path that's still open — one worktree closing must not drop the event for\n\t\t\t\t// its still-open siblings, which is why this reads from the surviving set rather than from\n\t\t\t\t// whichever path happened to report first.\n\t\t\t\tconst readPath = first(this.pruneClosedReconcilePaths(entry.paths).keys());\n\t\t\t\t// Every path that reported the change has since closed — nothing left to reconcile, and\n\t\t\t\t// nothing left holding a stale derived value either.\n\t\t\t\tif (readPath == null) return 'reconciled';\n\n\t\t\t\t// A trailing pass must not reuse the entry the pass before it installed.\n\t\t\t\tthis.cache.deleteGkConfigMap(readPath);\n\t\t\t\tconst freshMap = await this.getGkConfigMap(readPath);\n\t\t\t\t// Paths may have closed while the re-read was in flight; if every one did, there's nothing\n\t\t\t\t// left to reconcile against.\n\t\t\t\tif (!this.pruneClosedReconcilePaths(entry.paths).size) return 'reconciled';\n\n\t\t\t\tif (this.cache.reconcileGkConfigMap(readPath, snapshot, freshMap)) {\n\t\t\t\t\t// Fire a follow-up change: a consumer that re-read on the original event may have done so\n\t\t\t\t\t// before this async cascade landed, so it would otherwise hold a stale derived value with\n\t\t\t\t\t// nothing left to prompt another re-read.\n\t\t\t\t\tfor (const path of entry.paths.keys()) {\n\t\t\t\t\t\tthis.context.hooks?.repository?.onChanged?.(path, ['gkConfig']);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// `reconcileGkConfigMap` advanced the stored baseline to what we just read; a trailing pass\n\t\t\t\t// diffs its own read against that.\n\t\t\t\tsnapshot = this.cache.getGkConfigMergeSnapshot(readPath);\n\t\t\t} while (entry.pending);\n\n\t\t\treturn 'reconciled';\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex, `Failed to reconcile gk config for '${commonPath}'`);\n\t\t\t// The caller falls back to the coarse clear — derived caches are otherwise left holding\n\t\t\t// pre-change values with nothing to correct them.\n\t\t\treturn 'failed';\n\t\t} finally {\n\t\t\tthis._gkConfigReconciles.delete(commonPath);\n\t\t}\n\t}\n\n\t@debug()\n\tasync getSigningConfig(repoPath: string): Promise<SigningConfig> {\n\t\t// Fetch all signing-related config in one call\n\t\tconst configMap = await this.getConfigRegex(\n\t\t\trepoPath,\n\t\t\t'^(commit\\\\.gpgsign|gpg\\\\.format|user\\\\.signingkey|gpg\\\\.program|gpg\\\\.ssh\\\\.program|gpg\\\\.ssh\\\\.allowedsignersfile)$',\n\t\t);\n\n\t\t// Extract values (keys are lowercase in git output)\n\t\tconst enabledRaw = configMap.get('commit.gpgsign');\n\t\tconst format = configMap.get('gpg.format');\n\t\tconst signingKey = configMap.get('user.signingkey');\n\t\tconst gpgProgram = configMap.get('gpg.program');\n\t\tconst sshProgram = configMap.get('gpg.ssh.program');\n\t\tconst allowedSignersFile = configMap.get('gpg.ssh.allowedsignersfile');\n\n\t\t// Check if git config has commit signing enabled, falling back to the host-level override\n\t\t// (e.g. VS Code's `git.enableCommitSigning`) when `commit.gpgsign` is unset/false. The host\n\t\t// override can only enable signing, never force it off.\n\t\tconst isEnabled = parseGitBoolean(enabledRaw) || this.context.config?.signing?.enabled === true;\n\n\t\treturn {\n\t\t\tenabled: isEnabled,\n\t\t\tformat: (format as SigningFormat) ?? 'gpg',\n\t\t\tsigningKey: signingKey,\n\t\t\tgpgProgram: gpgProgram,\n\t\t\tsshProgram: sshProgram,\n\t\t\tallowedSignersFile: allowedSignersFile,\n\t\t};\n\t}\n\n\t@debug()\n\tasync validateSigningSetup(repoPath: string): Promise<ValidationResult> {\n\t\tconst config = await this.getSigningConfig(repoPath);\n\n\t\tif (!config.signingKey) {\n\t\t\treturn { valid: false, error: 'No signing key configured' };\n\t\t}\n\n\t\t// Basic validation: just check that a signing key is configured\n\t\t// Git will handle the actual validation when signing commits\n\t\treturn { valid: true };\n\t}\n\n\t@debug()\n\tasync setSigningConfig(\n\t\trepoPath: string,\n\t\tconfig: Partial<SigningConfig>,\n\t\toptions?: { global?: boolean },\n\t): Promise<void> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tif (config.enabled != null) {\n\t\t\t\tawait this.setConfig(repoPath, 'commit.gpgsign', config.enabled ? 'true' : 'false', options);\n\t\t\t}\n\t\t\tif (config.format != null) {\n\t\t\t\tawait this.setConfig(repoPath, 'gpg.format', config.format, options);\n\t\t\t}\n\t\t\tif (config.signingKey != null) {\n\t\t\t\tawait this.setConfig(repoPath, 'user.signingkey', config.signingKey, options);\n\t\t\t}\n\t\t\tif (config.gpgProgram != null) {\n\t\t\t\tawait this.setConfig(repoPath, 'gpg.program', config.gpgProgram, options);\n\t\t\t}\n\t\t\tif (config.sshProgram != null) {\n\t\t\t\tawait this.setConfig(repoPath, 'gpg.ssh.program', config.sshProgram, options);\n\t\t\t}\n\t\t\tif (config.allowedSignersFile != null) {\n\t\t\t\tawait this.setConfig(repoPath, 'gpg.ssh.allowedSignersFile', config.allowedSignersFile, options);\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\tgetSigningConfigFlags(config: SigningConfig): string[] {\n\t\tconst flags: string[] = [];\n\n\t\tif (config.gpgProgram) {\n\t\t\tflags.push('-c', `gpg.program=${config.gpgProgram}`);\n\t\t}\n\t\tif (config.format && config.format !== 'gpg') {\n\t\t\tflags.push('-c', `gpg.format=${config.format}`);\n\t\t}\n\t\tif (config.sshProgram) {\n\t\t\tflags.push('-c', `gpg.ssh.program=${config.sshProgram}`);\n\t\t}\n\t\tif (config.allowedSignersFile) {\n\t\t\tflags.push('-c', `gpg.ssh.allowedSignersFile=${config.allowedSignersFile}`);\n\t\t}\n\n\t\treturn flags;\n\t}\n\n\tasync getRepositoryInfo(\n\t\tcwd: string,\n\t): Promise<\n\t\t| { repoPath: string; gitDir: string; commonGitDir: string | undefined; superprojectPath: string | undefined }\n\t\t| [safe: true, repoPath: string]\n\t\t| [safe: false]\n\t\t| []\n\t> {\n\t\tlet result;\n\n\t\tif (this.context.workspace?.isTrusted === false) {\n\t\t\ttry {\n\t\t\t\tawait fs.stat(joinPaths(cwd, 'HEAD'));\n\t\t\t\tresult = await this.git.run(\n\t\t\t\t\t{ cwd: cwd, errors: 'throw', configs: ['-C', cwd] },\n\t\t\t\t\t'rev-parse',\n\t\t\t\t\t'--show-cdup',\n\t\t\t\t);\n\t\t\t\tif (!result.stdout.trim()) {\n\t\t\t\t\tLogger.warn(`Skipping (untrusted); bare clone repository detected in '${cwd}'`);\n\t\t\t\t\treturn emptyArray as [];\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// If this throws, we should be good to open the repo\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\tresult = await this.git.run(\n\t\t\t\t{ cwd: cwd, errors: 'throw' },\n\t\t\t\t'rev-parse',\n\t\t\t\t'--show-toplevel',\n\t\t\t\t'--git-dir',\n\t\t\t\t'--git-common-dir',\n\t\t\t\t'--show-superproject-working-tree',\n\t\t\t);\n\t\t\tif (!result.stdout) return emptyArray as [];\n\n\t\t\t// Output is 3-4 lines: show-toplevel, git-dir, git-common-dir, [show-superproject-working-tree]\n\t\t\t// The 4th line is only present for submodules\n\t\t\tconst lines = result.stdout.split('\\n').map(r => r.trimStart());\n\t\t\tconst [repoPath, dotGitPath, commonDotGitPath, superprojectPath] = lines;\n\n\t\t\tif (!repoPath) return emptyArray as [];\n\n\t\t\tconst normalizedRepoPath = normalizePath(repoPath.replace(/[\\r|\\n]+$/, ''));\n\n\t\t\tlet gitDir = dotGitPath;\n\t\t\tif (gitDir && !isAbsolute(gitDir)) {\n\t\t\t\tgitDir = joinPaths(cwd, gitDir);\n\t\t\t}\n\t\t\tgitDir = normalizePath(gitDir);\n\n\t\t\tlet commonGitDir: string | undefined;\n\t\t\tif (commonDotGitPath) {\n\t\t\t\tcommonGitDir = commonDotGitPath;\n\t\t\t\tif (!isAbsolute(commonGitDir)) {\n\t\t\t\t\tcommonGitDir = joinPaths(cwd, commonGitDir);\n\t\t\t\t}\n\t\t\t\tcommonGitDir = normalizePath(commonGitDir);\n\t\t\t\tif (commonGitDir === gitDir) {\n\t\t\t\t\tcommonGitDir = undefined;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\trepoPath: normalizedRepoPath,\n\t\t\t\tgitDir: gitDir,\n\t\t\t\tcommonGitDir: commonGitDir,\n\t\t\t\tsuperprojectPath: superprojectPath?.trim() || undefined,\n\t\t\t};\n\t\t} catch (ex: any) {\n\t\t\tif (ex instanceof WorkspaceUntrustedError) return emptyArray as [];\n\n\t\t\tconst unsafeMatch =\n\t\t\t\t/(?:^fatal:\\s*detected dubious ownership in repository at '([^']+)'|unsafe repository \\('([^']+)' is owned by someone else\\))[\\s\\S]*(git config --global --add safe\\.directory [^\\n\\u2022]+)/m.exec(\n\t\t\t\t\tex.stderr,\n\t\t\t\t);\n\t\t\tif (unsafeMatch != null) {\n\t\t\t\tLogger.warn(\n\t\t\t\t\t`Skipping; unsafe repository detected in '${unsafeMatch[1] || unsafeMatch[2]}'; run '${\n\t\t\t\t\t\tunsafeMatch[3]\n\t\t\t\t\t}' to allow it`,\n\t\t\t\t);\n\t\t\t\treturn [false];\n\t\t\t}\n\n\t\t\tconst inDotGit = /this operation must be run in a work tree/.test(ex.stderr);\n\t\t\tif (inDotGit && this.context.workspace?.isTrusted !== false) {\n\t\t\t\tresult = await this.git.run({ cwd: cwd, errors: 'ignore' }, 'rev-parse', '--is-bare-repository');\n\t\t\t\tif (result.stdout.trim() === 'true') {\n\t\t\t\t\tconst result = await this.revParseGitDir(cwd);\n\t\t\t\t\tconst repoPath = result?.commonPath ?? result?.path;\n\t\t\t\t\tif (repoPath?.length) return [true, repoPath];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (inDotGit || ex.code === 'ENOENT') {\n\t\t\t\tlet exists = inDotGit ? false : await fsExists(cwd);\n\t\t\t\tif (!exists) {\n\t\t\t\t\tdo {\n\t\t\t\t\t\tconst parent = dirname(cwd);\n\t\t\t\t\t\tif (parent === cwd || parent.length === 0) return emptyArray as [];\n\n\t\t\t\t\t\tcwd = parent;\n\t\t\t\t\t\texists = await fsExists(cwd);\n\t\t\t\t\t} while (!exists);\n\n\t\t\t\t\treturn this.getRepositoryInfo(cwd);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn emptyArray as [];\n\t\t}\n\t}\n\n\tprivate async revParseGitDir(cwd: string): Promise<{ path: string; commonPath?: string } | undefined> {\n\t\tconst result = await this.git.run({ cwd: cwd, errors: 'ignore' }, 'rev-parse', '--git-dir', '--git-common-dir');\n\t\tif (!result.stdout) return undefined;\n\n\t\tlet [dotGitPath, commonDotGitPath] = result.stdout.split('\\n').map(r => r.trimStart());\n\n\t\tif (!isAbsolute(dotGitPath)) {\n\t\t\tdotGitPath = joinPaths(cwd, dotGitPath);\n\t\t}\n\t\tdotGitPath = normalizePath(dotGitPath);\n\n\t\tif (commonDotGitPath) {\n\t\t\tif (!isAbsolute(commonDotGitPath)) {\n\t\t\t\tcommonDotGitPath = joinPaths(cwd, commonDotGitPath);\n\t\t\t}\n\t\t\tcommonDotGitPath = normalizePath(commonDotGitPath);\n\n\t\t\treturn { path: dotGitPath, commonPath: commonDotGitPath !== dotGitPath ? commonDotGitPath : undefined };\n\t\t}\n\n\t\treturn { path: dotGitPath };\n\t}\n\n\t/**\n\t * Ensures the `.git/gk/` folder exists, but only if the parent `.git` directory already exists.\n\t * This prevents creating stray `.git` directories if the computed path is wrong.\n\t * Returns `true` if the folder was ensured, `false` if the parent `.git` does not exist.\n\t */\n\tprivate async ensureGkConfigFolder(\n\t\tgkConfigFolder: string,\n\t\tscope: ReturnType<typeof getScopedLogger>,\n\t): Promise<boolean> {\n\t\t// Verify the .git directory already exists — never create it from scratch\n\t\tconst dotGitDir = joinPaths(gkConfigFolder, '..');\n\t\ttry {\n\t\t\tawait fs.stat(dotGitDir);\n\t\t} catch {\n\t\t\tscope?.warn(`Skipping GK config write — expected git directory '${dotGitDir}' does not exist`);\n\t\t\treturn false;\n\t\t}\n\n\t\ttry {\n\t\t\tawait fs.mkdir(gkConfigFolder, { recursive: true });\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex, `Failed to create '${gkConfigFolder}' directory`);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tprivate _migratedRepos = new Set<string>();\n\n\t/**\n\t * One-time migration of GK config entries from regular git config to `.git/gk/config`.\n\t * If `.git/gk/config` already exists, assumes migration is complete (or data is already there).\n\t * Preserves existing `.git/gk/config` values as source of truth (won't overwrite).\n\t * Removes migrated keys from regular git config to stop cluttering it.\n\t */\n\t@gate()\n\t@debug()\n\tprivate async migrateGkConfigFromGitConfig(repoPath: string): Promise<void> {\n\t\tif (this._migratedRepos.has(repoPath)) return;\n\n\t\tconst scope = getScopedLogger();\n\n\t\tconst gkConfigPath = await this.getGkConfigPath(repoPath);\n\t\tif (!gkConfigPath) {\n\t\t\tthis._migratedRepos.add(repoPath);\n\t\t\treturn;\n\t\t}\n\n\t\tconst gkConfigFolder = joinPaths(gkConfigPath, '..');\n\n\t\t// If .git/gk/config already exists, consider migration done — it was either\n\t\t// already migrated or values were written there directly via setGkConfig\n\t\ttry {\n\t\t\tawait fs.stat(gkConfigPath);\n\t\t\tthis._migratedRepos.add(repoPath);\n\t\t\treturn;\n\t\t} catch {\n\t\t\t// file doesn't exist, proceed with migration\n\t\t}\n\n\t\t// If .git/gk/config doesn't exist, create an empty file to prevent multiple migration attempts in future sessions\n\t\tif (!(await this.ensureGkConfigFolder(gkConfigFolder, scope))) return;\n\n\t\ttry {\n\t\t\tawait fs.writeFile(gkConfigPath, new Uint8Array());\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex, `Failed to create '${gkConfigPath}' file`);\n\t\t}\n\n\t\t// Read legacy gk-* keys from regular git config\n\t\tlet migrateConfig: Map<string, string>;\n\t\ttry {\n\t\t\tmigrateConfig = await this.getConfigRegexCore(repoPath, '^branch\\\\..*\\\\.gk-', { runGitLocally: true });\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex, 'Failed to read legacy GK config entries');\n\t\t\tthis._migratedRepos.add(repoPath);\n\t\t\treturn;\n\t\t}\n\n\t\tif (!migrateConfig.size) {\n\t\t\tthis._migratedRepos.add(repoPath);\n\t\t\treturn;\n\t\t}\n\n\t\tscope?.info(`Migrating ${String(migrateConfig.size)} GK config entries from git config to .git/gk/config`);\n\n\t\t// Copy legacy entries to .git/gk/config\n\t\tfor (const [key, value] of [...migrateConfig]) {\n\t\t\ttry {\n\t\t\t\tawait this.setConfigCore(repoPath, key, value, { file: gkConfigPath });\n\t\t\t} catch (ex) {\n\t\t\t\tscope?.error(ex, `Failed to migrate key '${key}' to GK config`);\n\t\t\t\t// If we failed to migrate, delete it from the list so we won't try to remove it from git config later\n\t\t\t\tmigrateConfig.delete(key);\n\t\t\t}\n\t\t}\n\n\t\t// Remove legacy keys from regular git config (use --unset-all defensively)\n\t\tfor (const [key] of migrateConfig) {\n\t\t\ttry {\n\t\t\t\tawait this.git.run(\n\t\t\t\t\t{ cwd: repoPath, errors: 'ignore', runLocally: true },\n\t\t\t\t\t'config',\n\t\t\t\t\t'--local',\n\t\t\t\t\t'--unset-all',\n\t\t\t\t\tkey,\n\t\t\t\t);\n\t\t\t} catch (ex) {\n\t\t\t\tscope?.error(ex, `Failed to remove migrated key '${key}' from git config`);\n\t\t\t}\n\t\t}\n\n\t\t// Clear caches since we modified both config files\n\t\tthis.cache.clearCaches(repoPath, 'config', 'gkConfig');\n\n\t\tthis._migratedRepos.add(repoPath);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AA2BA,MAAM,oBAAoB;AAC1B,MAAM,aAA+B,OAAO,OAAO,CAAC,CAAC;;AAGrD,MAAM,qBAAqB;;;;;;AAO3B,SAAgB,yBAAyB,KAAqB;CAC7D,MAAM,QAAQ,IAAI,QAAQ,GAAG;CAC7B,IAAI,UAAU,IAAI,OAAO,IAAI,YAAY;CAEzC,MAAM,OAAO,IAAI,YAAY,GAAG;CAGhC,IAAI,UAAU,MAAM,OAAO,IAAI,YAAY;CAC3C,OAAO,GAAG,IAAI,MAAM,GAAG,KAAK,CAAC,CAAC,YAAY,IAAI,IAAI,MAAM,OAAO,IAAI,IAAI,IAAI,MAAM,IAAI,CAAC,CAAC,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BAAA,IAAA;AA0DN,WAAA,CAAA,KAAK,GACL,MAAM,EAAE,OAAM,MAAK,YAAY,IAAI,CAAC,CAAA,GAAA,qBAAA,WAAA,0BAAA,IAAA;AASpC,WAAA,CAAA,KAAK,GACL,MAAM,EACN,OAAM,MACL,YAAY,EAAE,IAAI,SAAS,IAAI,EAAE,cAAc,EAAE,WAAW,SAAS,IAAI,EAAE,cAAc,EAAE,WAAW,SAAS,IAAI,IACrH,CAAC,CAAA,GAAA,qBAAA,WAAA,aAAA,IAAA;AA8CA,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,eAAA,IAAA;AASN,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,oBAAA,IAAA;AAwEN,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,eAAA,IAAA;AAoDN,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,+BAAA,IAAA;AAON,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,+BAAA,IAAA;AA0LN,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,oBAAA,IAAA;AA+BN,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,wBAAA,IAAA;AAaN,WAAA,CAAA,MAAM,CAAA,GAAA,qBAAA,WAAA,oBAAA,IAAA;AAkON,WAAA,CAAA,KAAK,GACL,MAAM,CAAA,GAAA,qBAAA,WAAA,gCAAA,IAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { CancellationError, isCancellationError } from "../../utils/cancellation.js";
|
|
2
2
|
import { getScopedLogger } from "../../utils/logger.scoped.js";
|
|
3
3
|
import { debug } from "../../utils/decorators/log.js";
|
|
4
|
+
import { createDisposable } from "../../utils/disposable.js";
|
|
4
5
|
import { isUncommittedStaged } from "../../git/utils/revision.utils.js";
|
|
5
6
|
import __decorate from "../../_virtual/@oxc-project+runtime/helpers/esm/decorate.js";
|
|
6
|
-
import { createDisposable } from "../../utils/disposable.js";
|
|
7
7
|
import { gitConfigsLog } from "../exec/git.js";
|
|
8
8
|
import { isUserMatch } from "../../git/utils/user.utils.js";
|
|
9
9
|
import _usingCtx from "../../_virtual/@oxc-project+runtime/helpers/esm/usingCtx.js";
|
|
@@ -67,6 +67,8 @@ export declare class DiffGitSubProvider implements GitDiffSubProvider {
|
|
|
67
67
|
encoding?: string;
|
|
68
68
|
filters?: GitDiffFilter[];
|
|
69
69
|
linesOfContext?: number;
|
|
70
|
+
/** Path of the file on the ref1 side (when renamed/copied); added to the pathspec so git can pair the rename */
|
|
71
|
+
originalPath?: string;
|
|
70
72
|
renames?: boolean;
|
|
71
73
|
similarityThreshold?: number | null;
|
|
72
74
|
}): Promise<GitResult>;
|
|
@@ -79,6 +81,7 @@ export declare class DiffGitSubProvider implements GitDiffSubProvider {
|
|
|
79
81
|
/** Returns parsed diff hunks for a file between two revisions. */
|
|
80
82
|
getDiffForFile(repoPath: string, fileName: string, ref1: string | undefined, ref2?: string, options?: {
|
|
81
83
|
encoding?: string;
|
|
84
|
+
originalPath?: string;
|
|
82
85
|
}): Promise<ParsedGitDiffHunks | undefined>;
|
|
83
86
|
private getDiffForFileCore;
|
|
84
87
|
/** Returns parsed diff hunks comparing a file's revision with given contents via stdin. */
|
|
@@ -474,7 +474,7 @@ var DiffGitSubProvider = class {
|
|
|
474
474
|
cwd: repoPath,
|
|
475
475
|
configs: gitConfigsDiff,
|
|
476
476
|
encoding: options?.encoding
|
|
477
|
-
}, ...params, "--", fileName);
|
|
477
|
+
}, ...params, "--", fileName, ...options?.originalPath && options.originalPath !== fileName ? [options.originalPath] : []);
|
|
478
478
|
} catch (ex) {
|
|
479
479
|
const match = GitErrors.badRevision.exec(ex.message);
|
|
480
480
|
if (match !== null) {
|
|
@@ -514,7 +514,7 @@ var DiffGitSubProvider = class {
|
|
|
514
514
|
}
|
|
515
515
|
/** Returns parsed diff hunks for a file between two revisions. */
|
|
516
516
|
getDiffForFile(repoPath, fileName, ref1, ref2, options) {
|
|
517
|
-
const cacheKey = `${normalizePath(fileName)}:${ref1 ?? ""}:${ref2 ?? ""}`;
|
|
517
|
+
const cacheKey = `${normalizePath(fileName)}${options?.originalPath ? `<${normalizePath(options.originalPath)}` : ""}:${ref1 ?? ""}:${ref2 ?? ""}`;
|
|
518
518
|
return this.cache.diff.getOrCreate(repoPath, cacheKey, () => this.getDiffForFileCore(repoPath, fileName, ref1, ref2, options), { errorTTL: 6e4 });
|
|
519
519
|
}
|
|
520
520
|
async getDiffForFileCore(repoPath, fileName, ref1, ref2, options) {
|
|
@@ -526,6 +526,7 @@ var DiffGitSubProvider = class {
|
|
|
526
526
|
"C"
|
|
527
527
|
],
|
|
528
528
|
linesOfContext: 0,
|
|
529
|
+
originalPath: options?.originalPath,
|
|
529
530
|
renames: true,
|
|
530
531
|
similarityThreshold: this.context.config?.commits.similarityThreshold
|
|
531
532
|
});
|