@gitkraken/core-gitlens 0.37.1 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/CHANGELOG.md +60 -1
  2. package/dist/git/cache.d.ts +128 -8
  3. package/dist/git/cache.js +425 -46
  4. package/dist/git/cache.js.map +1 -1
  5. package/dist/git/features.d.ts +1 -1
  6. package/dist/git/features.js +3 -0
  7. package/dist/git/features.js.map +1 -1
  8. package/dist/git/providers/branches.d.ts +42 -1
  9. package/dist/git/providers/diff.d.ts +17 -0
  10. package/dist/git/providers/provider.d.ts +7 -0
  11. package/dist/git/providers/shared/remotes.js +8 -4
  12. package/dist/git/providers/shared/remotes.js.map +1 -1
  13. package/dist/git/remotes/matcher.js +2 -2
  14. package/dist/git/remotes/matcher.js.map +1 -1
  15. package/dist/git/repositoryService.d.ts +16 -1
  16. package/dist/git/repositoryService.js +51 -3
  17. package/dist/git/repositoryService.js.map +1 -1
  18. package/dist/git/run.types.d.ts +1 -0
  19. package/dist/git/service.js +6 -2
  20. package/dist/git/service.js.map +1 -1
  21. package/dist/git/utils/fileStatus.utils.d.ts +5 -0
  22. package/dist/git/utils/fileStatus.utils.js +18 -1
  23. package/dist/git/utils/fileStatus.utils.js.map +1 -1
  24. package/dist/git/watching/changeEvent.d.ts +13 -3
  25. package/dist/git/watching/changeEvent.js +15 -4
  26. package/dist/git/watching/changeEvent.js.map +1 -1
  27. package/dist/git/watching/changeOrdinal.d.ts +9 -0
  28. package/dist/git/watching/changeOrdinal.js +14 -0
  29. package/dist/git/watching/changeOrdinal.js.map +1 -0
  30. package/dist/git/watching/unwatchedCacheValidator.d.ts +38 -5
  31. package/dist/git/watching/unwatchedCacheValidator.js +180 -36
  32. package/dist/git/watching/unwatchedCacheValidator.js.map +1 -1
  33. package/dist/git/watching/watchGroup.d.ts +63 -14
  34. package/dist/git/watching/watchGroup.js +213 -74
  35. package/dist/git/watching/watchGroup.js.map +1 -1
  36. package/dist/git/watching/watchService.js +4 -3
  37. package/dist/git/watching/watchService.js.map +1 -1
  38. package/dist/git/watching/watchSession.d.ts +10 -2
  39. package/dist/git/watching/watchSession.js +18 -4
  40. package/dist/git/watching/watchSession.js.map +1 -1
  41. package/dist/git/watching/watcherPatterns.d.ts +18 -4
  42. package/dist/git/watching/watcherPatterns.js +39 -8
  43. package/dist/git/watching/watcherPatterns.js.map +1 -1
  44. package/dist/git/watching/worktreeSummary.d.ts +23 -12
  45. package/dist/git/watching/worktreeSummary.js +164 -41
  46. package/dist/git/watching/worktreeSummary.js.map +1 -1
  47. package/dist/git-cli/cliGitProvider.d.ts +1 -0
  48. package/dist/git-cli/cliGitProvider.js +11 -2
  49. package/dist/git-cli/cliGitProvider.js.map +1 -1
  50. package/dist/git-cli/exec/git.d.ts +7 -2
  51. package/dist/git-cli/exec/git.js +46 -10
  52. package/dist/git-cli/exec/git.js.map +1 -1
  53. package/dist/git-cli/exec/headState.d.ts +24 -0
  54. package/dist/git-cli/exec/headState.js +46 -6
  55. package/dist/git-cli/exec/headState.js.map +1 -1
  56. package/dist/git-cli/parsers/logParser.js +6 -3
  57. package/dist/git-cli/parsers/logParser.js.map +1 -1
  58. package/dist/git-cli/providers/branches.d.ts +135 -10
  59. package/dist/git-cli/providers/branches.js +622 -80
  60. package/dist/git-cli/providers/branches.js.map +1 -1
  61. package/dist/git-cli/providers/commits.d.ts +16 -0
  62. package/dist/git-cli/providers/commits.js +80 -28
  63. package/dist/git-cli/providers/commits.js.map +1 -1
  64. package/dist/git-cli/providers/config.d.ts +10 -0
  65. package/dist/git-cli/providers/config.js +50 -12
  66. package/dist/git-cli/providers/config.js.map +1 -1
  67. package/dist/git-cli/providers/contributors.js +11 -7
  68. package/dist/git-cli/providers/contributors.js.map +1 -1
  69. package/dist/git-cli/providers/diff.d.ts +12 -0
  70. package/dist/git-cli/providers/diff.js +107 -15
  71. package/dist/git-cli/providers/diff.js.map +1 -1
  72. package/dist/git-cli/providers/graph.js +32 -25
  73. package/dist/git-cli/providers/graph.js.map +1 -1
  74. package/dist/git-cli/providers/operations.d.ts +37 -3
  75. package/dist/git-cli/providers/operations.js +124 -46
  76. package/dist/git-cli/providers/operations.js.map +1 -1
  77. package/dist/git-cli/providers/patch.js +1 -1
  78. package/dist/git-cli/providers/patch.js.map +1 -1
  79. package/dist/git-cli/providers/refs.d.ts +1 -1
  80. package/dist/git-cli/providers/refs.js +10 -11
  81. package/dist/git-cli/providers/refs.js.map +1 -1
  82. package/dist/git-cli/providers/status.d.ts +4 -5
  83. package/dist/git-cli/providers/status.js +36 -33
  84. package/dist/git-cli/providers/status.js.map +1 -1
  85. package/dist/git-cli/providers/tags.d.ts +8 -0
  86. package/dist/git-cli/providers/tags.js +53 -34
  87. package/dist/git-cli/providers/tags.js.map +1 -1
  88. package/dist/git-cli/service.d.ts +15 -0
  89. package/dist/git-cli/service.js +19 -1
  90. package/dist/git-cli/service.js.map +1 -1
  91. package/dist/plus/git-github/providers/github/diff.d.ts +1 -0
  92. package/dist/plus/git-github/providers/github/diff.js +6 -1
  93. package/dist/plus/git-github/providers/github/diff.js.map +1 -1
  94. package/dist/plus/integrations/integrationService.js +9 -0
  95. package/dist/plus/integrations/integrationService.js.map +1 -1
  96. package/dist/plus/integrations/providers/issueSorts.d.ts +1 -0
  97. package/dist/plus/integrations/providers/jira-server.js +1 -1
  98. package/dist/plus/integrations/providers/jira-server.js.map +1 -1
  99. package/dist/plus/integrations/providers/jira.d.ts +38 -6
  100. package/dist/plus/integrations/providers/jira.js +111 -69
  101. package/dist/plus/integrations/providers/jira.js.map +1 -1
  102. package/dist/plus/integrations/providers/linear.d.ts +31 -3
  103. package/dist/plus/integrations/providers/linear.js +77 -18
  104. package/dist/plus/integrations/providers/linear.js.map +1 -1
  105. package/dist/plus/integrations/providers/utils/discoveryCache.d.ts +41 -4
  106. package/dist/plus/integrations/providers/utils/discoveryCache.js +50 -11
  107. package/dist/plus/integrations/providers/utils/discoveryCache.js.map +1 -1
  108. package/dist/plus/integrations/reads/drains.d.ts +1 -0
  109. package/dist/utils/env/node/exec.d.ts +5 -4
  110. package/dist/utils/env/node/exec.js +52 -9
  111. package/dist/utils/env/node/exec.js.map +1 -1
  112. package/dist/utils/holdOffMap.d.ts +23 -0
  113. package/dist/utils/holdOffMap.js +43 -0
  114. package/dist/utils/holdOffMap.js.map +1 -0
  115. package/dist/utils/promiseCache.d.ts +15 -2
  116. package/dist/utils/promiseCache.js +34 -4
  117. package/dist/utils/promiseCache.js.map +1 -1
  118. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"contributors.js","names":[],"sources":["../../../../git-cli/src/providers/contributors.ts"],"sourcesContent":["import type { Cache } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport type { GitContributorsStats } from '@gitlens/git/models/contributor.js';\nimport { GitContributor } from '@gitlens/git/models/contributor.js';\nimport type { GitContributorsResult, GitContributorsSubProvider } from '@gitlens/git/providers/contributors.js';\nimport { calculateContributionScore } from '@gitlens/git/utils/contributor.utils.js';\nimport { isUncommittedStaged } from '@gitlens/git/utils/revision.utils.js';\nimport { isUserMatch } from '@gitlens/git/utils/user.utils.js';\nimport { CancellationError, isCancellationError } from '@gitlens/utils/cancellation.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport { createDisposable } from '@gitlens/utils/disposable.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport type { CacheController } from '@gitlens/utils/promiseCache.js';\nimport type { Mutable } from '@gitlens/utils/types.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport type { Git } from '../exec/git.js';\nimport { gitConfigsLog } from '../exec/git.js';\nimport { getContributorsLogParser } from '../parsers/logParser.js';\nimport { parseShortlog } from '../parsers/shortlogParser.js';\n\nexport class ContributorsGitSubProvider implements GitContributorsSubProvider {\n\tconstructor(\n\t\tprivate readonly _context: GitServiceContext,\n\t\tprivate readonly git: Git,\n\t\tprivate readonly cache: Cache,\n\t\tprivate readonly provider: CliGitProviderInternal,\n\t) {}\n\n\t@debug({ quiet: true })\n\tasync getContributors(\n\t\trepoPath: string,\n\t\trev?: string,\n\t\toptions?: {\n\t\t\tall?: boolean;\n\t\t\tmerges?: boolean | 'first-parent';\n\t\t\tpathspec?: string;\n\t\t\tsince?: string;\n\t\t\tstats?: boolean;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t\ttimeout?: number,\n\t): Promise<GitContributorsResult> {\n\t\tif (!repoPath) return { contributors: [] };\n\n\t\tconst scope = getScopedLogger();\n\n\t\tconst getCore = async (\n\t\t\tcommonPath: string,\n\t\t\tcacheable?: CacheController,\n\t\t\tsignal?: AbortSignal,\n\t\t): Promise<GitContributorsResult> => {\n\t\t\t// Prefer the aggregate signal from the cache; fall back to the caller's cancellation.\n\t\t\tsignal ??= cancellation;\n\n\t\t\tconst contributors = new Map<string, Mutable<GitContributor>>();\n\n\t\t\ttry {\n\t\t\t\tconst currentUser = await this.provider.config.getCurrentUser(repoPath);\n\t\t\t\tif (signal?.aborted) throw new CancellationError();\n\n\t\t\t\tconst parser = getContributorsLogParser(options?.stats);\n\n\t\t\t\tconst args = [...parser.arguments, '--use-mailmap'];\n\n\t\t\t\tconst merges = options?.merges ?? true;\n\t\t\t\tif (merges) {\n\t\t\t\t\targs.push(merges === 'first-parent' ? '--first-parent' : '--no-min-parents');\n\t\t\t\t} else {\n\t\t\t\t\targs.push('--no-merges');\n\t\t\t\t}\n\n\t\t\t\tif (options?.all) {\n\t\t\t\t\targs.push('--all', '--single-worktree');\n\t\t\t\t}\n\n\t\t\t\tif (options?.since) {\n\t\t\t\t\targs.push(`--since=\"${options.since}\"`);\n\t\t\t\t}\n\n\t\t\t\tif (rev && !isUncommittedStaged(rev)) {\n\t\t\t\t\targs.push(rev);\n\t\t\t\t}\n\n\t\t\t\tif (options?.pathspec) {\n\t\t\t\t\targs.push('--', options.pathspec);\n\t\t\t\t} else {\n\t\t\t\t\targs.push('--');\n\t\t\t\t}\n\n\t\t\t\tconst timeoutSignal = timeout ? AbortSignal.timeout(timeout) : undefined;\n\t\t\t\tconst combinedSignal =\n\t\t\t\t\tsignal && timeoutSignal ? AbortSignal.any([signal, timeoutSignal]) : (signal ?? timeoutSignal);\n\n\t\t\t\tconst stream = this.git.stream(\n\t\t\t\t\t{ cwd: repoPath, cancellation: combinedSignal, configs: gitConfigsLog },\n\t\t\t\t\t'log',\n\t\t\t\t\t...args,\n\t\t\t\t);\n\t\t\t\tusing _streamDisposer = createDisposable(() => void stream.return?.(undefined));\n\n\t\t\t\tfor await (const c of parser.parseAsync(stream)) {\n\t\t\t\t\tif (combinedSignal?.aborted) {\n\t\t\t\t\t\tcacheable?.invalidate();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst key = `${c.author}|${c.email}`;\n\t\t\t\t\tconst timestamp = Number(c.date) * 1000;\n\t\t\t\t\tconst date = new Date(timestamp);\n\n\t\t\t\t\tlet contributor: Mutable<GitContributor> | undefined = contributors.get(key);\n\t\t\t\t\tif (contributor == null) {\n\t\t\t\t\t\tcontributor = new GitContributor(\n\t\t\t\t\t\t\tcommonPath,\n\t\t\t\t\t\t\tc.author,\n\t\t\t\t\t\t\tc.email,\n\t\t\t\t\t\t\tisUserMatch(currentUser, c.author, c.email),\n\t\t\t\t\t\t\t1,\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tsha: c.sha,\n\t\t\t\t\t\t\t\t\tdate: date,\n\t\t\t\t\t\t\t\t\tmessage: c.message,\n\t\t\t\t\t\t\t\t\tfiles: c.stats?.files,\n\t\t\t\t\t\t\t\t\tadditions: c.stats?.additions,\n\t\t\t\t\t\t\t\t\tdeletions: c.stats?.deletions,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tdate,\n\t\t\t\t\t\t\tdate,\n\t\t\t\t\t\t\tc.stats\n\t\t\t\t\t\t\t\t? { ...c.stats, contributionScore: calculateContributionScore(c.stats, timestamp) }\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tcontributors.set(key, contributor);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcontributor.contributionCount++;\n\t\t\t\t\t\tif (date > contributor.latestCommitDate!) {\n\t\t\t\t\t\t\tcontributor.latestCommitDate = date;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (date < contributor.firstCommitDate!) {\n\t\t\t\t\t\t\tcontributor.firstCommitDate = date;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontributor.contributions ??= [];\n\t\t\t\t\t\tcontributor.contributions.push({\n\t\t\t\t\t\t\tsha: c.sha,\n\t\t\t\t\t\t\tdate: date,\n\t\t\t\t\t\t\tmessage: c.message,\n\t\t\t\t\t\t\tfiles: c.stats?.files,\n\t\t\t\t\t\t\tadditions: c.stats?.additions,\n\t\t\t\t\t\t\tdeletions: c.stats?.deletions,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (options?.stats && c.stats != null) {\n\t\t\t\t\t\t\tif (contributor.stats == null) {\n\t\t\t\t\t\t\t\tcontributor.stats = {\n\t\t\t\t\t\t\t\t\t...c.stats,\n\t\t\t\t\t\t\t\t\tcontributionScore: calculateContributionScore(c.stats, timestamp),\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcontributor.stats = {\n\t\t\t\t\t\t\t\t\tadditions: contributor.stats.additions + c.stats.additions,\n\t\t\t\t\t\t\t\t\tdeletions: contributor.stats.deletions + c.stats.deletions,\n\t\t\t\t\t\t\t\t\tfiles: contributor.stats.files + c.stats.files,\n\t\t\t\t\t\t\t\t\tcontributionScore:\n\t\t\t\t\t\t\t\t\t\tcontributor.stats.contributionScore +\n\t\t\t\t\t\t\t\t\t\tcalculateContributionScore(c.stats, timestamp),\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tcontributors: [...contributors.values()],\n\t\t\t\t\tcancelled: timeoutSignal?.aborted\n\t\t\t\t\t\t? { reason: 'timedout' }\n\t\t\t\t\t\t: signal?.aborted\n\t\t\t\t\t\t\t? { reason: 'cancelled' }\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t};\n\t\t\t} catch (ex) {\n\t\t\t\tcacheable?.invalidate();\n\t\t\t\tscope?.error(ex);\n\n\t\t\t\tif (!isCancellationError(ex)) return { contributors: [] };\n\t\t\t\treturn { contributors: [...contributors.values()], cancelled: { reason: 'cancelled' } };\n\t\t\t}\n\t\t};\n\n\t\tlet customCacheTTL;\n\n\t\tlet cacheKey = rev ?? '';\n\t\tif (options?.all) {\n\t\t\tcacheKey += ':all';\n\t\t}\n\t\tif (options?.pathspec) {\n\t\t\tcacheKey += `:pathspec=${options.pathspec}`;\n\t\t\tcustomCacheTTL = 1000 * 60 * 5; // 5 minutes\n\t\t}\n\t\tif (options?.merges) {\n\t\t\tcacheKey += `:merges=${String(options.merges)}`;\n\t\t}\n\t\tif (options?.since) {\n\t\t\tcacheKey += `:since=${options.since}`;\n\t\t\tcustomCacheTTL = 1000 * 60 * 5; // 5 minutes\n\t\t}\n\t\tif (options?.stats) {\n\t\t\tcacheKey += ':stats';\n\t\t}\n\t\tif (timeout) {\n\t\t\tcacheKey += `:timeout=${String(timeout)}`;\n\t\t\tcustomCacheTTL = timeout * 2;\n\t\t}\n\n\t\treturn this.cache.getContributors(repoPath, cacheKey, getCore, {\n\t\t\t...(customCacheTTL ? { accessTTL: customCacheTTL } : undefined),\n\t\t\tcancellation: cancellation,\n\t\t});\n\t}\n\n\t@debug({ quiet: true })\n\tgetContributorsLite(\n\t\trepoPath: string,\n\t\trev?: string,\n\t\toptions?: { all?: boolean; merges?: boolean | 'first-parent'; since?: string },\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitContributor[]> {\n\t\tif (!repoPath) return Promise.resolve([]);\n\n\t\tconst scope = getScopedLogger();\n\n\t\tif (!rev || isUncommittedStaged(rev)) {\n\t\t\trev = undefined;\n\t\t\toptions = { ...options, all: true };\n\t\t}\n\n\t\tconst getCore = async (commonPath: string, cacheable?: CacheController, signal?: AbortSignal) => {\n\t\t\t// Prefer the aggregate signal from the cache; fall back to the caller's cancellation.\n\t\t\tsignal ??= cancellation;\n\t\t\ttry {\n\t\t\t\t// eventually support `--group=author --group=trailer:co-authored-by`\n\t\t\t\tconst args = ['shortlog', '-s', '-e', '-n'];\n\n\t\t\t\tif (options?.all) {\n\t\t\t\t\targs.push('--all');\n\t\t\t\t}\n\t\t\t\tconst merges = options?.merges ?? true;\n\t\t\t\tif (merges) {\n\t\t\t\t\targs.push(merges === 'first-parent' ? '--first-parent' : '--no-min-parents');\n\t\t\t\t} else {\n\t\t\t\t\targs.push('--no-merges');\n\t\t\t\t}\n\t\t\t\tif (options?.since) {\n\t\t\t\t\targs.push(`--since=${options.since}`);\n\t\t\t\t}\n\t\t\t\tif (rev) {\n\t\t\t\t\targs.push(rev);\n\t\t\t\t}\n\n\t\t\t\tconst currentUserPromise = this.provider.config.getCurrentUser(repoPath).catch(() => undefined);\n\t\t\t\tconst result = await this.git.run({ cwd: repoPath, cancellation: signal }, ...args);\n\t\t\t\tif (!result.stdout) return [];\n\n\t\t\t\tconst shortlog = parseShortlog(result.stdout, commonPath, await currentUserPromise);\n\t\t\t\treturn shortlog.contributors;\n\t\t\t} catch (ex) {\n\t\t\t\tcacheable?.invalidate();\n\t\t\t\tscope?.error(ex);\n\n\t\t\t\treturn [];\n\t\t\t}\n\t\t};\n\n\t\tlet customCacheTTL;\n\n\t\tlet cacheKey = `lite${rev ? `:${rev}` : ''}`;\n\t\tif (options?.merges) {\n\t\t\tcacheKey += `:merges=${String(options.merges)}`;\n\t\t}\n\t\tif (options?.since) {\n\t\t\tcacheKey += `:since=${options.since}`;\n\t\t\tcustomCacheTTL = 1000 * 60 * 5; // 5 minutes\n\t\t}\n\n\t\treturn this.cache.getContributorsLite(repoPath, cacheKey, getCore, {\n\t\t\t...(customCacheTTL ? { accessTTL: customCacheTTL } : undefined),\n\t\t\tcancellation: cancellation,\n\t\t});\n\t}\n\n\t@debug({ quiet: true })\n\tgetContributorsStats(\n\t\trepoPath: string,\n\t\toptions?: { merges?: boolean | 'first-parent'; since?: string },\n\t\tcancellation?: AbortSignal,\n\t\ttimeout?: number,\n\t): Promise<GitContributorsStats | undefined> {\n\t\tif (!repoPath) return Promise.resolve(undefined);\n\n\t\tconst scope = getScopedLogger();\n\n\t\tconst getCore = async (\n\t\t\tcommonPath: string,\n\t\t\t_cacheable?: CacheController,\n\t\t\tsignal?: AbortSignal,\n\t\t): Promise<GitContributorsStats | undefined> => {\n\t\t\ttry {\n\t\t\t\tconst args = ['shortlog', '-s', '--all'];\n\n\t\t\t\tconst merges = options?.merges ?? true;\n\t\t\t\tif (merges) {\n\t\t\t\t\targs.push(merges === 'first-parent' ? '--first-parent' : '--no-min-parents');\n\t\t\t\t} else {\n\t\t\t\t\targs.push('--no-merges');\n\t\t\t\t}\n\n\t\t\t\tif (options?.since) {\n\t\t\t\t\targs.push(`--since=${options.since}`);\n\t\t\t\t}\n\n\t\t\t\tconst result = await this.git.run({ cwd: commonPath, cancellation: signal, timeout: timeout }, ...args);\n\t\t\t\tif (!result.stdout) return undefined;\n\n\t\t\t\tconst contributions = result.stdout\n\t\t\t\t\t.split('\\n')\n\t\t\t\t\t.map(line => parseInt(line.trim().split('\\t', 1)[0], 10))\n\t\t\t\t\t.filter(c => !isNaN(c))\n\t\t\t\t\t.sort((a, b) => b - a);\n\n\t\t\t\treturn { count: contributions.length, contributions: contributions } satisfies GitContributorsStats;\n\t\t\t} catch (ex) {\n\t\t\t\tscope?.error(ex);\n\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t};\n\n\t\tlet customCacheTTL;\n\n\t\tlet cacheKey = 'stats';\n\t\tif (options?.merges) {\n\t\t\tcacheKey += `:merges=${String(options.merges)}`;\n\t\t}\n\t\tif (options?.since) {\n\t\t\tcacheKey += `:since=${options.since}`;\n\t\t\tcustomCacheTTL = 1000 * 60 * 5; // 5 minutes\n\t\t}\n\t\tif (timeout) {\n\t\t\tcacheKey += `:timeout=${String(timeout)}`;\n\t\t\tcustomCacheTTL = timeout * 2;\n\t\t}\n\n\t\treturn this.cache.getContributorsStats(repoPath, cacheKey, getCore, {\n\t\t\taccessTTL: customCacheTTL,\n\t\t\tcancellation: cancellation,\n\t\t});\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AAoBA,IAAa,6BAAb,MAA8E;CAE3D;CACA;CACA;CACA;CAJlB,YACC,UACA,KACA,OACA,UACC;EAJgB,KAAA,WAAA;EACA,KAAA,MAAA;EACA,KAAA,QAAA;EACA,KAAA,WAAA;CACf;CAEH,MACM,gBACL,UACA,KACA,SAOA,cACA,SACiC;EACjC,IAAI,CAAC,UAAU,OAAO,EAAE,cAAc,CAAC,EAAE;EAEzC,MAAM,QAAQ,gBAAgB;EAE9B,MAAM,UAAU,OACf,YACA,WACA,WACoC;GAEpC,WAAW;GAEX,MAAM,+BAAe,IAAI,IAAqC;GAE9D,IAAI;;;KACH,MAAM,cAAc,MAAM,KAAK,SAAS,OAAO,eAAe,QAAQ;KACtE,IAAI,QAAQ,SAAS,MAAM,IAAI,kBAAkB;KAEjD,MAAM,SAAS,yBAAyB,SAAS,KAAK;KAEtD,MAAM,OAAO,CAAC,GAAG,OAAO,WAAW,eAAe;KAElD,MAAM,SAAS,SAAS,UAAU;KAClC,IAAI,QACH,KAAK,KAAK,WAAW,iBAAiB,mBAAmB,kBAAkB;UAE3E,KAAK,KAAK,aAAa;KAGxB,IAAI,SAAS,KACZ,KAAK,KAAK,SAAS,mBAAmB;KAGvC,IAAI,SAAS,OACZ,KAAK,KAAK,YAAY,QAAQ,MAAM,EAAE;KAGvC,IAAI,OAAO,CAAC,oBAAoB,GAAG,GAClC,KAAK,KAAK,GAAG;KAGd,IA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AY,OAAO,OAAO;GACtC,iBAAiB,UAAU;EAC5B;EAEA,OAAO,KAAK,MAAM,qBAAqB,UAAU,UAAU,SAAS;GACnE,WAAW;GACG;EACf,CAAC;CACF;AACD;AA3UE,WAAA,CAAA,MAAM,EAAE,OAAO,KAAK,CAAC,CAAA,GAAA,2BAAA,WAAA,mBAAA,IAAA;AAkMrB,WAAA,CAAA,MAAM,EAAE,OAAO,KAAK,CAAC,CAAA,GAAA,2BAAA,WAAA,uBAAA,IAAA;AAsErB,WAAA,CAAA,MAAM,EAAE,OAAO,KAAK,CAAC,CAAA,GAAA,2BAAA,WAAA,wBAAA,IAAA"}
1
+ {"version":3,"file":"contributors.js","names":[],"sources":["../../../../git-cli/src/providers/contributors.ts"],"sourcesContent":["import type { Cache } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport type { GitContributorsStats } from '@gitlens/git/models/contributor.js';\nimport { GitContributor } from '@gitlens/git/models/contributor.js';\nimport type { GitContributorsResult, GitContributorsSubProvider } from '@gitlens/git/providers/contributors.js';\nimport { calculateContributionScore } from '@gitlens/git/utils/contributor.utils.js';\nimport { isUncommittedStaged } from '@gitlens/git/utils/revision.utils.js';\nimport { isUserMatch } from '@gitlens/git/utils/user.utils.js';\nimport { CancellationError, isCancellationError } from '@gitlens/utils/cancellation.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport { createDisposable } from '@gitlens/utils/disposable.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport type { CacheController } from '@gitlens/utils/promiseCache.js';\nimport type { Mutable } from '@gitlens/utils/types.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport type { Git } from '../exec/git.js';\nimport { gitConfigsLog } from '../exec/git.js';\nimport { getContributorsLogParser } from '../parsers/logParser.js';\nimport { parseShortlog } from '../parsers/shortlogParser.js';\n\nexport class ContributorsGitSubProvider implements GitContributorsSubProvider {\n\tconstructor(\n\t\tprivate readonly _context: GitServiceContext,\n\t\tprivate readonly git: Git,\n\t\tprivate readonly cache: Cache,\n\t\tprivate readonly provider: CliGitProviderInternal,\n\t) {}\n\n\t@debug({ quiet: true })\n\tasync getContributors(\n\t\trepoPath: string,\n\t\trev?: string,\n\t\toptions?: {\n\t\t\tall?: boolean;\n\t\t\tmerges?: boolean | 'first-parent';\n\t\t\tpathspec?: string;\n\t\t\tsince?: string;\n\t\t\tstats?: boolean;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t\ttimeout?: number,\n\t): Promise<GitContributorsResult> {\n\t\tif (!repoPath) return { contributors: [] };\n\n\t\tconst scope = getScopedLogger();\n\n\t\tconst getCore = async (\n\t\t\tcommonPath: string,\n\t\t\tcacheable?: CacheController,\n\t\t\tsignal?: AbortSignal,\n\t\t): Promise<GitContributorsResult> => {\n\t\t\t// Prefer the aggregate signal from the cache; fall back to the caller's cancellation.\n\t\t\tsignal ??= cancellation;\n\n\t\t\tconst contributors = new Map<string, Mutable<GitContributor>>();\n\t\t\tlet timeoutSignal: AbortSignal | undefined;\n\n\t\t\ttry {\n\t\t\t\tconst currentUser = await this.provider.config.getCurrentUser(repoPath);\n\t\t\t\tif (signal?.aborted) throw new CancellationError();\n\n\t\t\t\tconst parser = getContributorsLogParser(options?.stats);\n\n\t\t\t\tconst args = [...parser.arguments, '--use-mailmap'];\n\n\t\t\t\tconst merges = options?.merges ?? true;\n\t\t\t\tif (merges) {\n\t\t\t\t\targs.push(merges === 'first-parent' ? '--first-parent' : '--no-min-parents');\n\t\t\t\t} else {\n\t\t\t\t\targs.push('--no-merges');\n\t\t\t\t}\n\n\t\t\t\tif (options?.all) {\n\t\t\t\t\targs.push('--all', '--single-worktree');\n\t\t\t\t}\n\n\t\t\t\tif (options?.since) {\n\t\t\t\t\targs.push(`--since=\"${options.since}\"`);\n\t\t\t\t}\n\n\t\t\t\tif (rev && !isUncommittedStaged(rev)) {\n\t\t\t\t\targs.push(rev);\n\t\t\t\t}\n\n\t\t\t\tif (options?.pathspec) {\n\t\t\t\t\targs.push('--', options.pathspec);\n\t\t\t\t} else {\n\t\t\t\t\targs.push('--');\n\t\t\t\t}\n\n\t\t\t\ttimeoutSignal = timeout ? AbortSignal.timeout(timeout) : undefined;\n\t\t\t\tconst combinedSignal =\n\t\t\t\t\tsignal && timeoutSignal ? AbortSignal.any([signal, timeoutSignal]) : (signal ?? timeoutSignal);\n\n\t\t\t\tconst stream = this.git.stream(\n\t\t\t\t\t{ cwd: repoPath, cancellation: combinedSignal, configs: gitConfigsLog },\n\t\t\t\t\t'log',\n\t\t\t\t\t...args,\n\t\t\t\t);\n\t\t\t\t// Unawaited: the stream logs a git error the close rethrows, which must not go unhandled\n\t\t\t\tusing _streamDisposer = createDisposable(() => void stream.return?.(undefined)?.catch(() => {}));\n\n\t\t\t\tfor await (const c of parser.parseAsync(stream)) {\n\t\t\t\t\tif (combinedSignal?.aborted) {\n\t\t\t\t\t\tcacheable?.invalidate();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst key = `${c.author}|${c.email}`;\n\t\t\t\t\tconst timestamp = Number(c.date) * 1000;\n\t\t\t\t\tconst date = new Date(timestamp);\n\n\t\t\t\t\tlet contributor: Mutable<GitContributor> | undefined = contributors.get(key);\n\t\t\t\t\tif (contributor == null) {\n\t\t\t\t\t\tcontributor = new GitContributor(\n\t\t\t\t\t\t\tcommonPath,\n\t\t\t\t\t\t\tc.author,\n\t\t\t\t\t\t\tc.email,\n\t\t\t\t\t\t\tisUserMatch(currentUser, c.author, c.email),\n\t\t\t\t\t\t\t1,\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tsha: c.sha,\n\t\t\t\t\t\t\t\t\tdate: date,\n\t\t\t\t\t\t\t\t\tmessage: c.message,\n\t\t\t\t\t\t\t\t\tfiles: c.stats?.files,\n\t\t\t\t\t\t\t\t\tadditions: c.stats?.additions,\n\t\t\t\t\t\t\t\t\tdeletions: c.stats?.deletions,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tdate,\n\t\t\t\t\t\t\tdate,\n\t\t\t\t\t\t\tc.stats\n\t\t\t\t\t\t\t\t? { ...c.stats, contributionScore: calculateContributionScore(c.stats, timestamp) }\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tcontributors.set(key, contributor);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcontributor.contributionCount++;\n\t\t\t\t\t\tif (date > contributor.latestCommitDate!) {\n\t\t\t\t\t\t\tcontributor.latestCommitDate = date;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (date < contributor.firstCommitDate!) {\n\t\t\t\t\t\t\tcontributor.firstCommitDate = date;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontributor.contributions ??= [];\n\t\t\t\t\t\tcontributor.contributions.push({\n\t\t\t\t\t\t\tsha: c.sha,\n\t\t\t\t\t\t\tdate: date,\n\t\t\t\t\t\t\tmessage: c.message,\n\t\t\t\t\t\t\tfiles: c.stats?.files,\n\t\t\t\t\t\t\tadditions: c.stats?.additions,\n\t\t\t\t\t\t\tdeletions: c.stats?.deletions,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (options?.stats && c.stats != null) {\n\t\t\t\t\t\t\tif (contributor.stats == null) {\n\t\t\t\t\t\t\t\tcontributor.stats = {\n\t\t\t\t\t\t\t\t\t...c.stats,\n\t\t\t\t\t\t\t\t\tcontributionScore: calculateContributionScore(c.stats, timestamp),\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcontributor.stats = {\n\t\t\t\t\t\t\t\t\tadditions: contributor.stats.additions + c.stats.additions,\n\t\t\t\t\t\t\t\t\tdeletions: contributor.stats.deletions + c.stats.deletions,\n\t\t\t\t\t\t\t\t\tfiles: contributor.stats.files + c.stats.files,\n\t\t\t\t\t\t\t\t\tcontributionScore:\n\t\t\t\t\t\t\t\t\t\tcontributor.stats.contributionScore +\n\t\t\t\t\t\t\t\t\t\tcalculateContributionScore(c.stats, timestamp),\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tcontributors: [...contributors.values()],\n\t\t\t\t\tcancelled: timeoutSignal?.aborted\n\t\t\t\t\t\t? { reason: 'timedout' }\n\t\t\t\t\t\t: signal?.aborted\n\t\t\t\t\t\t\t? { reason: 'cancelled' }\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t};\n\t\t\t} catch (ex) {\n\t\t\t\tcacheable?.invalidate();\n\n\t\t\t\tif (!isCancellationError(ex)) {\n\t\t\t\t\tscope?.error(ex);\n\t\t\t\t\treturn { contributors: [] };\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tcontributors: [...contributors.values()],\n\t\t\t\t\tcancelled: { reason: timeoutSignal?.aborted ? 'timedout' : 'cancelled' },\n\t\t\t\t};\n\t\t\t}\n\t\t};\n\n\t\tlet customCacheTTL;\n\n\t\tlet cacheKey = rev ?? '';\n\t\tif (options?.all) {\n\t\t\tcacheKey += ':all';\n\t\t}\n\t\tif (options?.pathspec) {\n\t\t\tcacheKey += `:pathspec=${options.pathspec}`;\n\t\t\tcustomCacheTTL = 1000 * 60 * 5; // 5 minutes\n\t\t}\n\t\tif (options?.merges) {\n\t\t\tcacheKey += `:merges=${String(options.merges)}`;\n\t\t}\n\t\tif (options?.since) {\n\t\t\tcacheKey += `:since=${options.since}`;\n\t\t\tcustomCacheTTL = 1000 * 60 * 5; // 5 minutes\n\t\t}\n\t\tif (options?.stats) {\n\t\t\tcacheKey += ':stats';\n\t\t}\n\t\tif (timeout) {\n\t\t\tcacheKey += `:timeout=${String(timeout)}`;\n\t\t\tcustomCacheTTL = timeout * 2;\n\t\t}\n\n\t\treturn this.cache.getContributors(repoPath, cacheKey, getCore, {\n\t\t\t...(customCacheTTL ? { accessTTL: customCacheTTL } : undefined),\n\t\t\tcancellation: cancellation,\n\t\t});\n\t}\n\n\t@debug({ quiet: true })\n\tgetContributorsLite(\n\t\trepoPath: string,\n\t\trev?: string,\n\t\toptions?: { all?: boolean; merges?: boolean | 'first-parent'; since?: string },\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitContributor[]> {\n\t\tif (!repoPath) return Promise.resolve([]);\n\n\t\tconst scope = getScopedLogger();\n\n\t\tif (!rev || isUncommittedStaged(rev)) {\n\t\t\trev = undefined;\n\t\t\toptions = { ...options, all: true };\n\t\t}\n\n\t\tconst getCore = async (commonPath: string, cacheable?: CacheController, signal?: AbortSignal) => {\n\t\t\t// Prefer the aggregate signal from the cache; fall back to the caller's cancellation.\n\t\t\tsignal ??= cancellation;\n\t\t\ttry {\n\t\t\t\t// eventually support `--group=author --group=trailer:co-authored-by`\n\t\t\t\tconst args = ['shortlog', '-s', '-e', '-n'];\n\n\t\t\t\tif (options?.all) {\n\t\t\t\t\targs.push('--all');\n\t\t\t\t}\n\t\t\t\tconst merges = options?.merges ?? true;\n\t\t\t\tif (merges) {\n\t\t\t\t\targs.push(merges === 'first-parent' ? '--first-parent' : '--no-min-parents');\n\t\t\t\t} else {\n\t\t\t\t\targs.push('--no-merges');\n\t\t\t\t}\n\t\t\t\tif (options?.since) {\n\t\t\t\t\targs.push(`--since=${options.since}`);\n\t\t\t\t}\n\t\t\t\tif (rev) {\n\t\t\t\t\targs.push(rev);\n\t\t\t\t}\n\n\t\t\t\tconst currentUserPromise = this.provider.config.getCurrentUser(repoPath).catch(() => undefined);\n\t\t\t\tconst result = await this.git.run({ cwd: repoPath, cancellation: signal }, ...args);\n\t\t\t\tif (!result.stdout) return [];\n\n\t\t\t\tconst shortlog = parseShortlog(result.stdout, commonPath, await currentUserPromise);\n\t\t\t\treturn shortlog.contributors;\n\t\t\t} catch (ex) {\n\t\t\t\tcacheable?.invalidate();\n\t\t\t\tscope?.error(ex);\n\n\t\t\t\treturn [];\n\t\t\t}\n\t\t};\n\n\t\tlet customCacheTTL;\n\n\t\tlet cacheKey = `lite${rev ? `:${rev}` : ''}`;\n\t\tif (options?.merges) {\n\t\t\tcacheKey += `:merges=${String(options.merges)}`;\n\t\t}\n\t\tif (options?.since) {\n\t\t\tcacheKey += `:since=${options.since}`;\n\t\t\tcustomCacheTTL = 1000 * 60 * 5; // 5 minutes\n\t\t}\n\n\t\treturn this.cache.getContributorsLite(repoPath, cacheKey, getCore, {\n\t\t\t...(customCacheTTL ? { accessTTL: customCacheTTL } : undefined),\n\t\t\tcancellation: cancellation,\n\t\t});\n\t}\n\n\t@debug({ quiet: true })\n\tgetContributorsStats(\n\t\trepoPath: string,\n\t\toptions?: { merges?: boolean | 'first-parent'; since?: string },\n\t\tcancellation?: AbortSignal,\n\t\ttimeout?: number,\n\t): Promise<GitContributorsStats | undefined> {\n\t\tif (!repoPath) return Promise.resolve(undefined);\n\n\t\tconst scope = getScopedLogger();\n\n\t\tconst getCore = async (\n\t\t\tcommonPath: string,\n\t\t\tcacheable?: CacheController,\n\t\t\tsignal?: AbortSignal,\n\t\t): Promise<GitContributorsStats | undefined> => {\n\t\t\ttry {\n\t\t\t\tconst args = ['shortlog', '-s', '--all'];\n\n\t\t\t\tconst merges = options?.merges ?? true;\n\t\t\t\tif (merges) {\n\t\t\t\t\targs.push(merges === 'first-parent' ? '--first-parent' : '--no-min-parents');\n\t\t\t\t} else {\n\t\t\t\t\targs.push('--no-merges');\n\t\t\t\t}\n\n\t\t\t\tif (options?.since) {\n\t\t\t\t\targs.push(`--since=${options.since}`);\n\t\t\t\t}\n\n\t\t\t\tconst result = await this.git.run({ cwd: commonPath, cancellation: signal, timeout: timeout }, ...args);\n\t\t\t\tif (!result.stdout) return undefined;\n\n\t\t\t\tconst contributions = result.stdout\n\t\t\t\t\t.split('\\n')\n\t\t\t\t\t.map(line => parseInt(line.trim().split('\\t', 1)[0], 10))\n\t\t\t\t\t.filter(c => !isNaN(c))\n\t\t\t\t\t.sort((a, b) => b - a);\n\n\t\t\t\treturn { count: contributions.length, contributions: contributions } satisfies GitContributorsStats;\n\t\t\t} catch (ex) {\n\t\t\t\tcacheable?.invalidate();\n\t\t\t\tscope?.error(ex);\n\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t};\n\n\t\tlet customCacheTTL;\n\n\t\tlet cacheKey = 'stats';\n\t\tif (options?.merges) {\n\t\t\tcacheKey += `:merges=${String(options.merges)}`;\n\t\t}\n\t\tif (options?.since) {\n\t\t\tcacheKey += `:since=${options.since}`;\n\t\t\tcustomCacheTTL = 1000 * 60 * 5; // 5 minutes\n\t\t}\n\t\tif (timeout) {\n\t\t\tcacheKey += `:timeout=${String(timeout)}`;\n\t\t\tcustomCacheTTL = timeout * 2;\n\t\t}\n\n\t\treturn this.cache.getContributorsStats(repoPath, cacheKey, getCore, {\n\t\t\t...(customCacheTTL ? { accessTTL: customCacheTTL } : undefined),\n\t\t\tcancellation: cancellation,\n\t\t});\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AAoBA,IAAa,6BAAb,MAA8E;CAE3D;CACA;CACA;CACA;CAJlB,YACC,UACA,KACA,OACA,UACC;EAJgB,KAAA,WAAA;EACA,KAAA,MAAA;EACA,KAAA,QAAA;EACA,KAAA,WAAA;CACf;CAEH,MACM,gBACL,UACA,KACA,SAOA,cACA,SACiC;EACjC,IAAI,CAAC,UAAU,OAAO,EAAE,cAAc,CAAC,EAAE;EAEzC,MAAM,QAAQ,gBAAgB;EAE9B,MAAM,UAAU,OACf,YACA,WACA,WACoC;GAEpC,WAAW;GAEX,MAAM,+BAAe,IAAI,IAAqC;GAC9D,IAAI;GAEJ,IAAI;;;KACH,MAAM,cAAc,MAAM,KAAK,SAAS,OAAO,eAAe,QAAQ;KACtE,IAAI,QAAQ,SAAS,MAAM,IAAI,kBAAkB;KAEjD,MAAM,SAAS,yBAAyB,SAAS,KAAK;KAEtD,MAAM,OAAO,CAAC,GAAG,OAAO,WAAW,eAAe;KAEl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,MAAM,CAAC,CAAC,CAAC,CACtB,MAAM,GAAG,MAAM,IAAI,CAAC;IAEtB,OAAO;KAAE,OAAO,cAAc;KAAuB;IAAc;GACpE,SAAS,IAAI;IACZ,WAAW,WAAW;IACtB,OAAO,MAAM,EAAE;IAEf;GACD;EACD;EAEA,IAAI;EAEJ,IAAI,WAAW;EACf,IAAI,SAAS,QACZ,YAAY,WAAW,OAAO,QAAQ,MAAM;EAE7C,IAAI,SAAS,OAAO;GACnB,YAAY,UAAU,QAAQ;GAC9B,iBAAiB;EAClB;EACA,IAAI,SAAS;GACZ,YAAY,YAAY,OAAO,OAAO;GACtC,iBAAiB,UAAU;EAC5B;EAEA,OAAO,KAAK,MAAM,qBAAqB,UAAU,UAAU,SAAS;GACnE,GAAI,iBAAiB,EAAE,WAAW,eAAe,IAAI,KAAA;GACvC;EACf,CAAC;CACF;AACD;AApVE,WAAA,CAAA,MAAM,EAAE,OAAO,KAAK,CAAC,CAAA,GAAA,2BAAA,WAAA,mBAAA,IAAA;AA0MrB,WAAA,CAAA,MAAM,EAAE,OAAO,KAAK,CAAC,CAAA,GAAA,2BAAA,WAAA,uBAAA,IAAA;AAsErB,WAAA,CAAA,MAAM,EAAE,OAAO,KAAK,CAAC,CAAA,GAAA,2BAAA,WAAA,wBAAA,IAAA"}
@@ -28,12 +28,16 @@ export declare class DiffGitSubProvider implements GitDiffSubProvider {
28
28
  context?: number;
29
29
  index?: DisposableTemporaryGitIndex;
30
30
  notation?: GitRevisionRangeNotation;
31
+ renames?: boolean;
32
+ similarityThreshold?: number;
31
33
  uris?: (string | Uri)[];
32
34
  errors?: GitErrorHandling;
33
35
  }, _cancellation?: AbortSignal): Promise<GitDiff | undefined>;
34
36
  getParsedDiff(repoPath: string, to: string, from?: string, options?: {
35
37
  context?: number;
36
38
  notation?: GitRevisionRangeNotation;
39
+ renames?: boolean;
40
+ similarityThreshold?: number;
37
41
  uris?: (string | Uri)[];
38
42
  errors?: GitErrorHandling;
39
43
  }, cancellation?: AbortSignal): Promise<ParsedGitDiff | undefined>;
@@ -42,10 +46,18 @@ export declare class DiffGitSubProvider implements GitDiffSubProvider {
42
46
  filters?: GitDiffFilter[];
43
47
  includeUntracked?: boolean;
44
48
  path?: string;
49
+ paths?: string[];
45
50
  renameLimit?: number;
46
51
  similarityThreshold?: number;
47
52
  errors?: GitErrorHandling;
48
53
  }): Promise<GitFile[] | undefined>;
54
+ /**
55
+ * What to diff instead when a status read fails only because there is nothing to diff from: an unborn `HEAD`
56
+ * (before the first commit) or a root commit's missing parent. Both are the empty tree, as `getDiff` treats them.
57
+ */
58
+ private getEmptyTreeRetry;
59
+ /** Whether `commit` has no parent, told from the history rather than from a failure's text. */
60
+ private isRootCommit;
49
61
  /**
50
62
  * The untracked files a working-tree diff folds in; outside `errors: 'throw'`, a failed listing adds nothing. The diff
51
63
  * reads take no cancellation, so a `CancellationError` here is a timeout and degrades like any other failure.
@@ -6,10 +6,11 @@ import { normalizePath, splitPath } from "../../utils/path.js";
6
6
  import { uncommittedStaged } from "../../git/models/revision.js";
7
7
  import { getRevisionRangeParts, isRevisionRange, isUncommitted, isUncommittedStaged } from "../../git/utils/revision.utils.js";
8
8
  import __decorate from "../../_virtual/@oxc-project+runtime/helpers/esm/decorate.js";
9
- import { GitError, GitErrors, gitConfigsDiff, gitConfigsLog } from "../exec/git.js";
9
+ import { GitError, GitErrors, batchLiteralPathspecs, gitConfigsDiff, gitConfigsLog } from "../exec/git.js";
10
10
  import { fnv1aHash } from "../../utils/hash.js";
11
11
  import { parseGitApplyFiles, parseGitDiff, parseGitDiffNumStatFiles, parseGitDiffShortStat, parseGitFileDiff } from "../../git/parsers/diffParser.js";
12
12
  import { getShaAndFileRangeLogParser, getShaAndFileSummaryLogParser } from "../parsers/logParser.js";
13
+ import { toLiteralPathspecMatcher } from "../../git/utils/fileStatus.utils.js";
13
14
  import { encodeGitLensRevisionUriAuthority } from "../../git/utils/uriAuthority.js";
14
15
  import * as l10n from "@vscode/l10n";
15
16
  //#region ../git-cli/src/providers/diff.ts
@@ -34,7 +35,7 @@ var DiffGitSubProvider = class {
34
35
  try {
35
36
  const result = await this.git.run({
36
37
  cwd: repoPath,
37
- configs: gitConfigsDiff,
38
+ configs: await this.git.getDiffReadConfigs(),
38
39
  errors: options?.errors === "throw" ? "throw" : void 0
39
40
  }, "diff", "--shortstat", "--no-ext-diff", ...args, "--", ...options?.uris?.map((p) => this.provider.getRelativePath(p, repoPath)) ?? []);
40
41
  const stat = result.stdout ? parseGitDiffShortStat(result.stdout) : void 0;
@@ -56,7 +57,11 @@ var DiffGitSubProvider = class {
56
57
  }
57
58
  async getDiff(repoPath, to, from, options, _cancellation) {
58
59
  const scope = getScopedLogger();
59
- const args = [`-U${options?.context ?? 3}`];
60
+ const args = [`-U${options?.context ?? 3}`, "--no-ext-diff"];
61
+ if (options?.renames === true) {
62
+ const similarityThreshold = options.similarityThreshold ?? this.context.config?.commits.similarityThreshold;
63
+ args.push(`-M${similarityThreshold == null ? "" : `${similarityThreshold}%`}`);
64
+ } else if (options?.renames === false) args.push("--no-renames");
60
65
  if (to != null && isRevisionRange(to)) {
61
66
  const parts = getRevisionRangeParts(to);
62
67
  if (parts != null) {
@@ -79,7 +84,7 @@ var DiffGitSubProvider = class {
79
84
  try {
80
85
  result = await this.git.run({
81
86
  cwd: repoPath,
82
- configs: gitConfigsDiff,
87
+ configs: await this.git.getDiffReadConfigs(),
83
88
  errors: "throw",
84
89
  env: options?.index?.env
85
90
  }, "diff", ...args, args.includes("--") ? void 0 : "--");
@@ -92,6 +97,14 @@ var DiffGitSubProvider = class {
92
97
  to
93
98
  } : void 0;
94
99
  }
100
+ if (!hasFrom && from === `${to}^` && await this.isRootCommit(repoPath, to)) {
101
+ const emptyTree = await this.provider.revision.getEmptyTreeSha(repoPath);
102
+ const retried = await this.getDiff(repoPath, to, emptyTree, options, _cancellation);
103
+ return retried != null ? {
104
+ ...retried,
105
+ to
106
+ } : void 0;
107
+ }
95
108
  scope?.error(ex);
96
109
  if (options?.errors === "throw") throw ex;
97
110
  return;
@@ -120,24 +133,66 @@ var DiffGitSubProvider = class {
120
133
  async getDiffStatus(repoPath, ref1OrRange, ref2, options) {
121
134
  try {
122
135
  const similarityThreshold = options?.similarityThreshold ?? this.context.config?.commits.similarityThreshold;
136
+ const diffConfigs = await this.git.getDiffReadConfigs();
123
137
  const configs = options?.renameLimit != null ? [
124
- ...gitConfigsDiff,
138
+ ...diffConfigs,
125
139
  "-c",
126
140
  `diff.renameLimit=${options.renameLimit}`
127
- ] : gitConfigsDiff;
128
- const result = await this.git.run({
129
- cwd: repoPath,
130
- configs,
131
- errors: options?.errors === "throw" ? "throw" : void 0
132
- }, "diff", "--numstat", "--summary", `-M${similarityThreshold == null ? "" : `${similarityThreshold}%`}`, "--no-ext-diff", "-z", options?.filters?.length ? `--diff-filter=${options.filters.join("")}` : void 0, ref1OrRange ? ref1OrRange : void 0, ref2 ? ref2 : void 0, "--", options?.path ? options.path : void 0);
133
- const files = result.stdout ? parseGitDiffNumStatFiles(result.stdout, repoPath) ?? [] : [];
134
- if (options?.includeUntracked && ref2 == null && typeof ref1OrRange === "string" && !isRevisionRange(ref1OrRange) && !isUncommittedStaged(ref1OrRange) && filtersAllowUntracked(options.filters) && !isNonExactPathspec(options.path)) {
141
+ ] : diffConfigs;
142
+ const args = [
143
+ "diff",
144
+ "--numstat",
145
+ "--summary",
146
+ `-M${similarityThreshold == null ? "" : `${similarityThreshold}%`}`,
147
+ "--no-ext-diff",
148
+ "-z",
149
+ options?.filters?.length ? `--diff-filter=${options.filters.join("")}` : void 0,
150
+ ref1OrRange ? ref1OrRange : void 0,
151
+ ref2 ? ref2 : void 0
152
+ ];
153
+ const paths = options?.paths;
154
+ if (paths != null && !paths.length) return void 0;
155
+ let stdouts;
156
+ try {
157
+ if (paths != null) {
158
+ const prefix = args.filter((a) => a != null);
159
+ stdouts = (await Promise.all(Array.from(batchLiteralPathspecs(paths, prefix), (batch) => this.git.run({
160
+ cwd: repoPath,
161
+ configs,
162
+ errors: options?.errors === "throw" ? "throw" : void 0
163
+ }, ...args, "--", ...batch)))).map((r) => r.stdout);
164
+ } else stdouts = [(await this.git.run({
165
+ cwd: repoPath,
166
+ configs,
167
+ errors: options?.errors === "throw" ? "throw" : void 0
168
+ }, ...args, "--", options?.path ? options.path : void 0)).stdout];
169
+ } catch (ex) {
170
+ const retry = await this.getEmptyTreeRetry(repoPath, ref1OrRange, ref2, ex);
171
+ if (retry == null) throw ex;
172
+ return await this.getDiffStatus(repoPath, retry.ref1OrRange, retry.ref2, options);
173
+ }
174
+ const files = [];
175
+ const listed = stdouts.length > 1 ? /* @__PURE__ */ new Set() : void 0;
176
+ for (const stdout of stdouts) {
177
+ if (!stdout) continue;
178
+ for (const file of parseGitDiffNumStatFiles(stdout, repoPath) ?? []) {
179
+ if (listed != null) {
180
+ if (listed.has(file.path)) continue;
181
+ listed.add(file.path);
182
+ }
183
+ files.push(file);
184
+ }
185
+ }
186
+ if (options?.includeUntracked && ref2 == null && typeof ref1OrRange === "string" && !isRevisionRange(ref1OrRange) && !isUncommittedStaged(ref1OrRange) && filtersAllowUntracked(options.filters) && (paths != null || !isNonExactPathspec(options.path))) {
135
187
  const untracked = await this.getUntrackedFilesForDiff(repoPath, options.errors);
136
188
  if (untracked.length) {
137
189
  const seen = new Set(files.map((f) => f.path));
190
+ const literal = paths != null ? toLiteralPathspecMatcher(paths) : void 0;
138
191
  for (const file of untracked) {
139
192
  if (seen.has(file.path)) continue;
140
- if (options.path && options.path !== file.path) continue;
193
+ if (literal != null) {
194
+ if (!literal(file.path)) continue;
195
+ } else if (options.path && options.path !== file.path) continue;
141
196
  files.push(file);
142
197
  }
143
198
  }
@@ -149,6 +204,43 @@ var DiffGitSubProvider = class {
149
204
  }
150
205
  }
151
206
  /**
207
+ * What to diff instead when a status read fails only because there is nothing to diff from: an unborn `HEAD`
208
+ * (before the first commit) or a root commit's missing parent. Both are the empty tree, as `getDiff` treats them.
209
+ */
210
+ async getEmptyTreeRetry(repoPath, ref1OrRange, ref2, ex) {
211
+ if ((isHead(ref1OrRange) || isHead(ref2)) && await isUnbornHeadFailure(this.provider, repoPath, ex)) {
212
+ const emptyTree = await this.provider.revision.getEmptyTreeSha(repoPath);
213
+ return {
214
+ ref1OrRange: isHead(ref1OrRange) ? emptyTree : ref1OrRange,
215
+ ref2: isHead(ref2) ? emptyTree : ref2
216
+ };
217
+ }
218
+ let parent = ref1OrRange;
219
+ let commit = ref2;
220
+ if (commit == null) {
221
+ const match = /^(.+?)\.\.(?!\.)(.+)$/.exec(ref1OrRange);
222
+ if (match == null) return void 0;
223
+ [, parent, commit] = match;
224
+ }
225
+ if (!commit || parent !== `${commit}^` && parent !== `${commit}~1`) return void 0;
226
+ if (!await this.isRootCommit(repoPath, commit)) return void 0;
227
+ return {
228
+ ref1OrRange: await this.provider.revision.getEmptyTreeSha(repoPath),
229
+ ref2: commit
230
+ };
231
+ }
232
+ /** Whether `commit` has no parent, told from the history rather than from a failure's text. */
233
+ async isRootCommit(repoPath, commit) {
234
+ try {
235
+ return (await this.git.run({
236
+ cwd: repoPath,
237
+ errors: "throw"
238
+ }, "rev-list", "--parents", "-n", "1", commit, "--")).stdout.trim().split(/\s+/).length === 1;
239
+ } catch {
240
+ return false;
241
+ }
242
+ }
243
+ /**
152
244
  * The untracked files a working-tree diff folds in; outside `errors: 'throw'`, a failed listing adds nothing. The diff
153
245
  * reads take no cancellation, so a `CancellationError` here is a timeout and degrades like any other failure.
154
246
  */
@@ -472,7 +564,7 @@ var DiffGitSubProvider = class {
472
564
  try {
473
565
  return await this.git.run({
474
566
  cwd: repoPath,
475
- configs: gitConfigsDiff,
567
+ configs: await this.git.getDiffReadConfigs(),
476
568
  encoding: options?.encoding
477
569
  }, ...params, "--", fileName, ...options?.originalPath && options.originalPath !== fileName ? [options.originalPath] : []);
478
570
  } catch (ex) {