@gitkraken/core-gitlens 0.37.1 → 0.38.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/CHANGELOG.md +69 -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/jira-server.js +1 -1
  97. package/dist/plus/integrations/providers/jira-server.js.map +1 -1
  98. package/dist/plus/integrations/providers/jira.d.ts +20 -9
  99. package/dist/plus/integrations/providers/jira.js +114 -99
  100. package/dist/plus/integrations/providers/jira.js.map +1 -1
  101. package/dist/plus/integrations/providers/linear.d.ts +11 -4
  102. package/dist/plus/integrations/providers/linear.js +75 -32
  103. package/dist/plus/integrations/providers/linear.js.map +1 -1
  104. package/dist/plus/integrations/providers/utils/discoveryCache.d.ts +35 -4
  105. package/dist/plus/integrations/providers/utils/discoveryCache.js +45 -11
  106. package/dist/plus/integrations/providers/utils/discoveryCache.js.map +1 -1
  107. package/dist/utils/env/node/exec.d.ts +8 -4
  108. package/dist/utils/env/node/exec.js +115 -9
  109. package/dist/utils/env/node/exec.js.map +1 -1
  110. package/dist/utils/holdOffMap.d.ts +23 -0
  111. package/dist/utils/holdOffMap.js +43 -0
  112. package/dist/utils/holdOffMap.js.map +1 -0
  113. package/dist/utils/promiseCache.d.ts +15 -2
  114. package/dist/utils/promiseCache.js +34 -4
  115. package/dist/utils/promiseCache.js.map +1 -1
  116. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"service.js","names":[],"sources":["../../../git/src/service.ts"],"sourcesContent":["import type { UnifiedDisposable } from '@gitlens/utils/disposable.js';\nimport { createDisposable } from '@gitlens/utils/disposable.js';\nimport type { Event } from '@gitlens/utils/event.js';\nimport { Emitter } from '@gitlens/utils/event.js';\nimport { normalizePath } from '@gitlens/utils/path.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\nimport { getRepositoryKey } from '@gitlens/utils/uri.js';\nimport type { MergeTargetsChangeEvent } from './cache.js';\nimport type { GitProvider } from './providers/provider.js';\nimport type { RepositoryService, SubProviderForRepo } from './repositoryService.js';\nimport {\n\tclearGlobalRepositoryServiceResolver,\n\tcreateSubProviderProxyForRepo,\n\tsetGlobalRepositoryServiceResolver,\n} from './repositoryService.js';\nimport type { FileWatchingProvider } from './watching/provider.js';\nimport type { WatchPollingOptions } from './watching/watchService.js';\nimport { RepositoryWatchService } from './watching/watchService.js';\nimport type { WorktreeSummaryServiceOptions } from './watching/worktreeSummary.js';\nimport { WorktreeSummaryService } from './watching/worktreeSummary.js';\n\nexport interface ProvidersChangeEvent {\n\treadonly added: readonly GitProvider[];\n\treadonly removed: readonly GitProvider[];\n\treadonly etag: number;\n}\n\n/**\n * Result of {@link GitService.validateRepo}.\n *\n * - `valid: true, safe: true` — a usable git repository at `repoPath`; `gitDir` / `commonGitDir` / `superprojectPath` are populated when available\n * - `valid: true, safe: false` — git detected unsafe (dubious) ownership at the given path; no `repoPath` is surfaced (the raw call doesn't carry one back)\n * - `valid: false` — not a git repository, no registered provider can handle the path, or the routed provider doesn't implement `getRepositoryInfo`\n */\nexport type ValidateRepoResult =\n\t| {\n\t\t\tvalid: true;\n\t\t\tsafe: true;\n\t\t\trepoPath: string;\n\t\t\tgitDir?: string;\n\t\t\tcommonGitDir?: string;\n\t\t\tsuperprojectPath?: string;\n\t }\n\t| { valid: true; safe: false }\n\t| { valid: false };\n\ninterface RegisteredProvider {\n\tprovider: GitProvider;\n\tcanHandle: (repoPath: string) => boolean;\n\t/** Forwards the provider's write announcements to {@link GitService.watchService}, when there is one */\n\tannouncements?: UnifiedDisposable;\n}\n\ninterface MergeTargetsSource {\n\treadonly subscription: UnifiedDisposable;\n\trefCount: number;\n}\n\n/**\n * Entry point — provider router, repo-scoped proxy cache, and global configuration.\n *\n * Creating an instance wires up the module-level repository\n * resolver. Calling {@link dispose} tears it down.\n *\n * Consumers register providers with routing predicates, then call\n * {@link forRepo} to get a {@link RepositoryService} with sub-provider\n * proxies that auto-inject the repository path.\n *\n * The service has no discovery or repository tracking state — it trusts\n * the caller to pass valid repository paths. Discovery and lifecycle\n * (open/close, file watching, etc.) are application-level concerns.\n *\n * @example\n * ```typescript\n * const service = GitService.createSingleton();\n * service.register(cliProvider, (path) => true);\n *\n * const repo = service.forRepo('/home/user/repo');\n * const branches = await repo.branches.getBranches();\n *\n * service.dispose(); // cleans up module-level hooks\n * ```\n */\nexport class GitService implements UnifiedDisposable {\n\tprivate static _instance: GitService | undefined;\n\n\t/**\n\t * `options.watchPolling` opts the watch service into polling what `watchingProvider` reports it can't watch,\n\t * `options.readFile` lets it tell what a reported `.git/config` change changed (see `WatchServiceOptions.readFile`),\n\t * and with it `options.readDirectory` lets it drop the reports of ignored worktrees (see\n\t * `WatchServiceOptions.readDirectory`).\n\t * `options.verifyBaseRemeasure` is for tests only (see `WorktreeSummaryServiceOptions.verifyBaseRemeasure`)\n\t */\n\tstatic createSingleton(\n\t\twatchingProvider?: FileWatchingProvider,\n\t\toptions?: {\n\t\t\twatchPolling?: WatchPollingOptions;\n\t\t\treadFile?: (path: string) => Promise<Uint8Array>;\n\t\t\treadDirectory?: (path: string) => Promise<readonly (readonly [string, number])[]>;\n\t\t\tverifyBaseRemeasure?: WorktreeSummaryServiceOptions['verifyBaseRemeasure'];\n\t\t},\n\t): GitService {\n\t\tif (GitService._instance != null) {\n\t\t\tthrow new Error('GitService already exists — only one instance is allowed');\n\t\t}\n\n\t\tconst instance = new GitService(\n\t\t\twatchingProvider,\n\t\t\toptions?.watchPolling,\n\t\t\toptions?.readFile,\n\t\t\toptions?.readDirectory,\n\t\t\toptions?.verifyBaseRemeasure,\n\t\t);\n\t\tGitService._instance = instance;\n\t\treturn instance;\n\t}\n\n\tprivate readonly _onDidChangeProviders = new Emitter<ProvidersChangeEvent>();\n\tget onDidChangeProviders(): Event<ProvidersChangeEvent> {\n\t\treturn this._onDidChangeProviders.event;\n\t}\n\n\tprivate readonly _onDidChangeMergeTargets = new Emitter<MergeTargetsChangeEvent>();\n\t/**\n\t * Fires when a write changed a branch's merge-relevant `.git/gk/config` keys, for any registered provider that\n\t * reports it — never for activity timestamps. Core's own key write fires it once, as the write completes, naming\n\t * the branch. Once per change per repository (`repoPath` is its common path); see {@link MergeTargetsChangeEvent}.\n\t */\n\tget onDidChangeMergeTargets(): Event<MergeTargetsChangeEvent> {\n\t\treturn this._onDidChangeMergeTargets.event;\n\t}\n\n\t/** Keyed by the provider's event, so providers sharing one cache are forwarded once */\n\tprivate readonly _mergeTargetsSources = new Map<Event<MergeTargetsChangeEvent>, MergeTargetsSource>();\n\n\tprivate _etag = 0;\n\tprivate readonly _providers: RegisteredProvider[] = [];\n\tprivate readonly _serviceCache = new Map<string, RepositoryService>();\n\tprivate readonly _watchService: RepositoryWatchService | undefined;\n\tprivate readonly _summaries: WorktreeSummaryService | undefined;\n\n\tprivate constructor(\n\t\twatchingProvider?: FileWatchingProvider,\n\t\twatchPolling?: WatchPollingOptions,\n\t\treadFile?: (path: string) => Promise<Uint8Array>,\n\t\treadDirectory?: (path: string) => Promise<readonly (readonly [string, number])[]>,\n\t\tverifyBaseRemeasure?: WorktreeSummaryServiceOptions['verifyBaseRemeasure'],\n\t) {\n\t\tif (watchingProvider != null) {\n\t\t\tthis._watchService = new RepositoryWatchService({\n\t\t\t\twatchingProvider: watchingProvider,\n\t\t\t\tpolling: watchPolling,\n\t\t\t\treadFile: readFile,\n\t\t\t\treadDirectory: readDirectory,\n\t\t\t\tgetIgnoreFilter: (repoPath, gitDirPath) => {\n\t\t\t\t\treturn this.getProvider(repoPath)?.provider.getIgnoreFilter?.(repoPath, gitDirPath);\n\t\t\t\t},\n\t\t\t\tgetIgnoredDirectories: repoPath =>\n\t\t\t\t\tthis.getProvider(repoPath)?.provider.getIgnoredDirectories?.(repoPath) ?? Promise.resolve([]),\n\t\t\t\tgetIgnoredWorktreeRoots: repoPath =>\n\t\t\t\t\tthis.getProvider(repoPath)?.provider.getIgnoredWorktreeRoots?.(repoPath) ?? Promise.resolve([]),\n\t\t\t\tgetIgnoredWorktreeFolders: repoPath =>\n\t\t\t\t\tthis.getProvider(repoPath)?.provider.getIgnoredWorktreeFolders?.(repoPath) ?? [],\n\t\t\t});\n\t\t\tthis._summaries = new WorktreeSummaryService({\n\t\t\t\twatchService: this._watchService,\n\t\t\t\tgetRepository: repoPath => this.forRepo(repoPath),\n\t\t\t\tonDidChangeMergeTargets: this.onDidChangeMergeTargets,\n\t\t\t\tgetCommonPath: repoPath => this.getProvider(repoPath)?.provider.getCommonPath?.(repoPath),\n\t\t\t\t// The host's polling stat, when it configured polling, answers whether an unwatched index file moved\n\t\t\t\tstat: watchPolling?.stat,\n\t\t\t\tverifyBaseRemeasure: verifyBaseRemeasure,\n\t\t\t});\n\t\t}\n\n\t\tsetGlobalRepositoryServiceResolver(repoPath => this.forRepo(repoPath));\n\t}\n\n\t[Symbol.dispose](): void {\n\t\tthis.dispose();\n\t}\n\n\tdispose(): void {\n\t\tclearGlobalRepositoryServiceResolver();\n\t\tGitService._instance = undefined;\n\t\tthis._serviceCache.clear();\n\t\tthis._summaries?.dispose();\n\t\tthis._watchService?.dispose();\n\n\t\t// Don't dispose providers since they're owned by the caller, but do clear the array to release references\n\t\tfor (const entry of this._providers) {\n\t\t\tentry.announcements?.dispose();\n\t\t}\n\t\tthis._providers.length = 0;\n\n\t\tfor (const source of this._mergeTargetsSources.values()) {\n\t\t\tsource.subscription.dispose();\n\t\t}\n\t\tthis._mergeTargetsSources.clear();\n\n\t\tthis._onDidChangeProviders.dispose();\n\t\tthis._onDidChangeMergeTargets.dispose();\n\t}\n\n\t/** Monotonically increasing counter incremented on structural changes. */\n\tget etag(): number {\n\t\treturn this._etag;\n\t}\n\n\t/** Whether any providers are registered. */\n\tget hasProviders(): boolean {\n\t\treturn this._providers.length > 0;\n\t}\n\n\tget watchService(): RepositoryWatchService | undefined {\n\t\treturn this._watchService;\n\t}\n\n\t/** Cached, change-notifying per-worktree summaries, kept current by {@link watchService}; present when it is */\n\tget summaries(): WorktreeSummaryService | undefined {\n\t\treturn this._summaries;\n\t}\n\n\t/**\n\t * Registers a provider with a routing predicate.\n\t *\n\t * @returns A disposable that unregisters the provider.\n\t */\n\tregister(provider: GitProvider, canHandle: (repoPath: string) => boolean): UnifiedDisposable {\n\t\tconst watchService = this._watchService;\n\t\tconst entry: RegisteredProvider = {\n\t\t\tprovider: provider,\n\t\t\tcanHandle: canHandle,\n\t\t\tannouncements:\n\t\t\t\twatchService != null\n\t\t\t\t\t? provider.onDidAnnounceChanges?.(e =>\n\t\t\t\t\t\t\twatchService.noteSelfWrite(e.repoPath, e.changes, e.refs, {\n\t\t\t\t\t\t\t\tconfigConfinedToRefs: e.configConfinedToRefs,\n\t\t\t\t\t\t\t\tmovedWorktrees: e.movedWorktrees,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t)\n\t\t\t\t\t: undefined,\n\t\t};\n\t\tthis._providers.push(entry);\n\t\tthis._etag++;\n\t\tthis.addMergeTargetsSource(provider);\n\n\t\tthis._onDidChangeProviders.fire({\n\t\t\tadded: [provider],\n\t\t\tremoved: [],\n\t\t\tetag: this._etag,\n\t\t});\n\n\t\t// Invalidate cached proxies since provider routing may have changed\n\t\tthis._serviceCache.clear();\n\n\t\treturn createDisposable(() => {\n\t\t\tconst idx = this._providers.indexOf(entry);\n\t\t\tif (idx !== -1) {\n\t\t\t\tthis._providers.splice(idx, 1);\n\t\t\t\tentry.announcements?.dispose();\n\t\t\t\tthis._etag++;\n\t\t\t\tthis.removeMergeTargetsSource(provider);\n\t\t\t\tthis._serviceCache.clear();\n\n\t\t\t\tthis._onDidChangeProviders.fire({\n\t\t\t\t\tadded: [],\n\t\t\t\t\tremoved: [provider],\n\t\t\t\t\tetag: this._etag,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate addMergeTargetsSource(provider: GitProvider): void {\n\t\tconst event = provider.onDidChangeMergeTargets;\n\t\tif (event == null) return;\n\n\t\tconst source = this._mergeTargetsSources.get(event);\n\t\tif (source != null) {\n\t\t\tsource.refCount++;\n\t\t\treturn;\n\t\t}\n\n\t\tthis._mergeTargetsSources.set(event, {\n\t\t\tsubscription: event(e => this._onDidChangeMergeTargets.fire(e)),\n\t\t\trefCount: 1,\n\t\t});\n\t}\n\n\tprivate removeMergeTargetsSource(provider: GitProvider): void {\n\t\tconst event = provider.onDidChangeMergeTargets;\n\t\tif (event == null) return;\n\n\t\tconst source = this._mergeTargetsSources.get(event);\n\t\tif (source == null || --source.refCount > 0) return;\n\n\t\tsource.subscription.dispose();\n\t\tthis._mergeTargetsSources.delete(event);\n\t}\n\n\t/** Returns the provider that can handle the given path, or undefined if none matches. */\n\tgetProvider(repoPath: string): { provider: GitProvider; path: string } | undefined {\n\t\trepoPath = normalizePath(repoPath);\n\t\tfor (const entry of this._providers) {\n\t\t\tif (entry.canHandle(repoPath)) {\n\t\t\t\treturn { provider: entry.provider, path: repoPath };\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/** Returns all registered providers. */\n\t*getProviders(): Iterable<GitProvider> {\n\t\tfor (const entry of this._providers) {\n\t\t\tyield entry.provider;\n\t\t}\n\t}\n\n\t/**\n\t * Routes a repo URI/path to a provider and returns a cached\n\t * {@link RepositoryService} with repo-scoped sub-provider proxies.\n\t * Returns undefined if no provider can handle the path.\n\t */\n\tforRepo(repoUri: Uri | string): RepositoryService | undefined {\n\t\tconst repoPath = getRepositoryKey(repoUri);\n\n\t\tlet repo = this._serviceCache.get(repoPath);\n\t\tif (repo != null) return repo;\n\n\t\tconst result = this.getProvider(repoPath);\n\t\tif (result == null) return undefined;\n\n\t\trepo = createRepositoryService(result.provider, repoPath, this._watchService);\n\t\tthis._serviceCache.set(repoPath, repo);\n\t\treturn repo;\n\t}\n\n\t/**\n\t * Evicts the cached {@link RepositoryService} for a closed or removed repository.\n\t * No-op if the path isn't cached.\n\t */\n\tcloseRepo(repoUri: Uri | string): void {\n\t\tconst repoPath = getRepositoryKey(repoUri);\n\t\tthis._serviceCache.delete(repoPath);\n\t}\n\n\t/**\n\t * Validates whether `pathOrUri` points to (or resides inside) a git repository,\n\t * and returns information about it when it does.\n\t *\n\t * Routes the path to a registered provider and delegates to its config sub-provider's\n\t * `getRepositoryInfo` implementation, then normalizes the raw result into a clean\n\t * discriminated union. For a simple yes/no check, use `(await validateRepo(path)).valid`.\n\t *\n\t * Returns `{ valid: false }` if no provider can handle the path or if the routed\n\t * provider does not implement `getRepositoryInfo`. Rejects when git gives no answer\n\t * (it ran past its time limit, was killed or couldn't start), which says nothing about the path.\n\t */\n\tasync validateRepo(pathOrUri: Uri | string): Promise<ValidateRepoResult> {\n\t\tconst key = getRepositoryKey(pathOrUri);\n\t\tconst routed = this.getProvider(key);\n\t\tif (routed == null) return { valid: false };\n\n\t\tconst info = await routed.provider.config.getRepositoryInfo?.(routed.path);\n\t\tif (info == null) return { valid: false };\n\n\t\tif (Array.isArray(info)) {\n\t\t\tif (info.length === 0) return { valid: false };\n\t\t\tif (info[0] === false) return { valid: true, safe: false };\n\t\t\treturn { valid: true, safe: true, repoPath: info[1] };\n\t\t}\n\n\t\treturn {\n\t\t\tvalid: true,\n\t\t\tsafe: true,\n\t\t\trepoPath: info.repoPath,\n\t\t\tgitDir: info.gitDir,\n\t\t\tcommonGitDir: info.commonGitDir,\n\t\t\tsuperprojectPath: info.superprojectPath,\n\t\t};\n\t}\n}\n\nfunction createRepositoryService(\n\tprovider: GitProvider,\n\trepoPath: string,\n\twatchService?: RepositoryWatchService,\n): RepositoryService {\n\tconst proxies = new Map<string, SubProviderForRepo<unknown>>();\n\n\tfunction getProxy<T extends object>(prop: string, subProvider: T | undefined): SubProviderForRepo<T> | undefined {\n\t\tif (subProvider == null) return undefined;\n\n\t\tlet proxy = proxies.get(prop);\n\t\tif (proxy == null) {\n\t\t\tproxy = createSubProviderProxyForRepo(subProvider, repoPath);\n\t\t\tproxies.set(prop, proxy);\n\t\t}\n\t\treturn proxy as SubProviderForRepo<T>;\n\t}\n\n\treturn {\n\t\tpath: repoPath,\n\t\tprovider: provider.descriptor,\n\n\t\tget etagWorkingTree(): number | undefined {\n\t\t\treturn watchService?.getSession(repoPath)?.etagWorkingTree;\n\t\t},\n\n\t\tgetAbsoluteUri: (relativePath: string): Uri => {\n\t\t\treturn provider.getAbsoluteUri(relativePath, repoPath);\n\t\t},\n\n\t\t// Required sub-providers\n\t\tget branches() {\n\t\t\tconst proxy = getProxy('branches', provider.branches);\n\t\t\tif (proxy == null) throw new Error('GitService: branches sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget commits() {\n\t\t\tconst proxy = getProxy('commits', provider.commits);\n\t\t\tif (proxy == null) throw new Error('GitService: commits sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget config() {\n\t\t\tconst proxy = getProxy('config', provider.config);\n\t\t\tif (proxy == null) throw new Error('GitService: config sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget contributors() {\n\t\t\tconst proxy = getProxy('contributors', provider.contributors);\n\t\t\tif (proxy == null) throw new Error('GitService: contributors sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget diff() {\n\t\t\tconst proxy = getProxy('diff', provider.diff);\n\t\t\tif (proxy == null) throw new Error('GitService: diff sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget graph() {\n\t\t\tconst proxy = getProxy('graph', provider.graph);\n\t\t\tif (proxy == null) throw new Error('GitService: graph sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget refs() {\n\t\t\tconst proxy = getProxy('refs', provider.refs);\n\t\t\tif (proxy == null) throw new Error('GitService: refs sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget remotes() {\n\t\t\tconst proxy = getProxy('remotes', provider.remotes);\n\t\t\tif (proxy == null) throw new Error('GitService: remotes sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget revision() {\n\t\t\tconst proxy = getProxy('revision', provider.revision);\n\t\t\tif (proxy == null) throw new Error('GitService: revision sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget status() {\n\t\t\tconst proxy = getProxy('status', provider.status);\n\t\t\tif (proxy == null) throw new Error('GitService: status sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget tags() {\n\t\t\tconst proxy = getProxy('tags', provider.tags);\n\t\t\tif (proxy == null) throw new Error('GitService: tags sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\n\t\t// Optional sub-providers\n\t\tget blame() {\n\t\t\treturn getProxy('blame', provider.blame);\n\t\t},\n\t\tget maintenance() {\n\t\t\treturn getProxy('maintenance', provider.maintenance);\n\t\t},\n\t\tget ops() {\n\t\t\treturn getProxy('ops', provider.ops);\n\t\t},\n\t\tget patch() {\n\t\t\treturn getProxy('patch', provider.patch);\n\t\t},\n\t\tget pausedOps() {\n\t\t\treturn getProxy('pausedOps', provider.pausedOps);\n\t\t},\n\t\tget staging() {\n\t\t\treturn getProxy('staging', provider.staging);\n\t\t},\n\t\tget stash() {\n\t\t\treturn getProxy('stash', provider.stash);\n\t\t},\n\t\tget worktrees() {\n\t\t\treturn getProxy('worktrees', provider.worktrees);\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFA,IAAa,aAAb,MAAa,WAAwC;CACpD,OAAe;;;;;;;;CASf,OAAO,gBACN,kBACA,SAMa;EACb,IAAI,WAAW,aAAa,MAC3B,MAAM,IAAI,MAAM,0DAA0D;EAG3E,MAAM,WAAW,IAAI,WACpB,kBACA,SAAS,cACT,SAAS,UACT,SAAS,eACT,SAAS,mBACV;EACA,WAAW,YAAY;EACvB,OAAO;CACR;CAEA,wBAAyC,IAAI,QAA8B;CAC3E,IAAI,uBAAoD;EACvD,OAAO,KAAK,sBAAsB;CACnC;CAEA,2BAA4C,IAAI,QAAiC;;;;;;CAMjF,IAAI,0BAA0D;EAC7D,OAAO,KAAK,yBAAyB;CACtC;;CAGA,uCAAwC,IAAI,IAAwD;CAEpG,QAAgB;CAChB,aAAoD,CAAC;CACrD,gCAAiC,IAAI,IAA+B;CACpE;CACA;CAEA,YACC,kBACA,cACA,UACA,eACA,qBACC;EACD,IAAI,oBAAoB,MAAM;GAC7B,KAAK,gBAAgB,IAAI,uBAAuB;IAC7B;IAClB,SAAS;IACC;IACK;IACf,kBAAkB,UAAU,eAAe;KAC1C,OAAO,KAAK,YAAY,QAAQ,CAAC,EAAE,SAAS,kBAAkB,UAAU,UAAU;IACnF;IACA,wBAAuB,aACtB,KAAK,YAAY,QAAQ,CAAC,EAAE,SAAS,wBAAwB,QAAQ,KAAK,QAAQ,QAAQ,CAAC,CAAC;IAC7F,0BAAyB,aACxB,KAAK,YAAY,QAAQ,CAAC,EAAE,SAAS,0BAA0B,QAAQ,KAAK,QAAQ,QAAQ,CAAC,CAAC;IAC/F,4BAA2B,aAC1B,KAAK,YAAY,QAAQ,CAAC,EAAE,SAAS,4BAA4B,QAAQ,KAAK,CAA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M,iEAAiE;GACpG,OAAO;EACR;EACA,IAAI,WAAW;GACd,MAAM,QAAQ,SAAS,YAAY,SAAS,QAAQ;GACpD,IAAI,SAAS,MAAM,MAAM,IAAI,MAAM,kEAAkE;GACrG,OAAO;EACR;EACA,IAAI,SAAS;GACZ,MAAM,QAAQ,SAAS,UAAU,SAAS,MAAM;GAChD,IAAI,SAAS,MAAM,MAAM,IAAI,MAAM,gEAAgE;GACnG,OAAO;EACR;EACA,IAAI,OAAO;GACV,MAAM,QAAQ,SAAS,QAAQ,SAAS,IAAI;GAC5C,IAAI,SAAS,MAAM,MAAM,IAAI,MAAM,8DAA8D;GACjG,OAAO;EACR;EAGA,IAAI,QAAQ;GACX,OAAO,SAAS,SAAS,SAAS,KAAK;EACxC;EACA,IAAI,cAAc;GACjB,OAAO,SAAS,eAAe,SAAS,WAAW;EACpD;EACA,IAAI,MAAM;GACT,OAAO,SAAS,OAAO,SAAS,GAAG;EACpC;EACA,IAAI,QAAQ;GACX,OAAO,SAAS,SAAS,SAAS,KAAK;EACxC;EACA,IAAI,YAAY;GACf,OAAO,SAAS,aAAa,SAAS,SAAS;EAChD;EACA,IAAI,UAAU;GACb,OAAO,SAAS,WAAW,SAAS,OAAO;EAC5C;EACA,IAAI,QAAQ;GACX,OAAO,SAAS,SAAS,SAAS,KAAK;EACxC;EACA,IAAI,YAAY;GACf,OAAO,SAAS,aAAa,SAAS,SAAS;EAChD;CACD;AACD"}
1
+ {"version":3,"file":"service.js","names":[],"sources":["../../../git/src/service.ts"],"sourcesContent":["import type { UnifiedDisposable } from '@gitlens/utils/disposable.js';\nimport { createDisposable } from '@gitlens/utils/disposable.js';\nimport type { Event } from '@gitlens/utils/event.js';\nimport { Emitter } from '@gitlens/utils/event.js';\nimport { normalizePath } from '@gitlens/utils/path.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\nimport { getRepositoryKey } from '@gitlens/utils/uri.js';\nimport type { MergeTargetsChangeEvent } from './cache.js';\nimport type { GitProvider } from './providers/provider.js';\nimport type { RepositoryService, SubProviderForRepo, SubProviderName } from './repositoryService.js';\nimport {\n\tclearGlobalRepositoryServiceResolver,\n\tcreateSubProviderProxyForRepo,\n\tsetGlobalRepositoryServiceResolver,\n\tsubProviderCallThroughMethods,\n} from './repositoryService.js';\nimport type { FileWatchingProvider } from './watching/provider.js';\nimport type { WatchPollingOptions } from './watching/watchService.js';\nimport { RepositoryWatchService } from './watching/watchService.js';\nimport type { WorktreeSummaryServiceOptions } from './watching/worktreeSummary.js';\nimport { WorktreeSummaryService } from './watching/worktreeSummary.js';\n\nexport interface ProvidersChangeEvent {\n\treadonly added: readonly GitProvider[];\n\treadonly removed: readonly GitProvider[];\n\treadonly etag: number;\n}\n\n/**\n * Result of {@link GitService.validateRepo}.\n *\n * - `valid: true, safe: true` — a usable git repository at `repoPath`; `gitDir` / `commonGitDir` / `superprojectPath` are populated when available\n * - `valid: true, safe: false` — git detected unsafe (dubious) ownership at the given path; no `repoPath` is surfaced (the raw call doesn't carry one back)\n * - `valid: false` — not a git repository, no registered provider can handle the path, or the routed provider doesn't implement `getRepositoryInfo`\n */\nexport type ValidateRepoResult =\n\t| {\n\t\t\tvalid: true;\n\t\t\tsafe: true;\n\t\t\trepoPath: string;\n\t\t\tgitDir?: string;\n\t\t\tcommonGitDir?: string;\n\t\t\tsuperprojectPath?: string;\n\t }\n\t| { valid: true; safe: false }\n\t| { valid: false };\n\ninterface RegisteredProvider {\n\tprovider: GitProvider;\n\tcanHandle: (repoPath: string) => boolean;\n\t/** Forwards the provider's write announcements to {@link GitService.watchService}, when there is one */\n\tannouncements?: UnifiedDisposable;\n}\n\ninterface MergeTargetsSource {\n\treadonly subscription: UnifiedDisposable;\n\trefCount: number;\n}\n\n/**\n * Entry point — provider router, repo-scoped proxy cache, and global configuration.\n *\n * Creating an instance wires up the module-level repository\n * resolver. Calling {@link dispose} tears it down.\n *\n * Consumers register providers with routing predicates, then call\n * {@link forRepo} to get a {@link RepositoryService} with sub-provider\n * proxies that auto-inject the repository path.\n *\n * The service has no discovery or repository tracking state — it trusts\n * the caller to pass valid repository paths. Discovery and lifecycle\n * (open/close, file watching, etc.) are application-level concerns.\n *\n * @example\n * ```typescript\n * const service = GitService.createSingleton();\n * service.register(cliProvider, (path) => true);\n *\n * const repo = service.forRepo('/home/user/repo');\n * const branches = await repo.branches.getBranches();\n *\n * service.dispose(); // cleans up module-level hooks\n * ```\n */\nexport class GitService implements UnifiedDisposable {\n\tprivate static _instance: GitService | undefined;\n\n\t/**\n\t * `options.watchPolling` opts the watch service into polling what `watchingProvider` reports it can't watch,\n\t * `options.readFile` lets it tell what a reported `.git/config` change changed (see `WatchServiceOptions.readFile`),\n\t * and with it `options.readDirectory` lets it drop the reports of ignored worktrees (see\n\t * `WatchServiceOptions.readDirectory`).\n\t * `options.verifyBaseRemeasure` is for tests only (see `WorktreeSummaryServiceOptions.verifyBaseRemeasure`)\n\t */\n\tstatic createSingleton(\n\t\twatchingProvider?: FileWatchingProvider,\n\t\toptions?: {\n\t\t\twatchPolling?: WatchPollingOptions;\n\t\t\treadFile?: (path: string) => Promise<Uint8Array>;\n\t\t\treadDirectory?: (path: string) => Promise<readonly (readonly [string, number])[]>;\n\t\t\tverifyBaseRemeasure?: WorktreeSummaryServiceOptions['verifyBaseRemeasure'];\n\t\t},\n\t): GitService {\n\t\tif (GitService._instance != null) {\n\t\t\tthrow new Error('GitService already exists — only one instance is allowed');\n\t\t}\n\n\t\tconst instance = new GitService(\n\t\t\twatchingProvider,\n\t\t\toptions?.watchPolling,\n\t\t\toptions?.readFile,\n\t\t\toptions?.readDirectory,\n\t\t\toptions?.verifyBaseRemeasure,\n\t\t);\n\t\tGitService._instance = instance;\n\t\treturn instance;\n\t}\n\n\tprivate readonly _onDidChangeProviders = new Emitter<ProvidersChangeEvent>();\n\tget onDidChangeProviders(): Event<ProvidersChangeEvent> {\n\t\treturn this._onDidChangeProviders.event;\n\t}\n\n\tprivate readonly _onDidChangeMergeTargets = new Emitter<MergeTargetsChangeEvent>();\n\t/**\n\t * Fires when a write changed a branch's merge-relevant `.git/gk/config` keys, for any registered provider that\n\t * reports it — never for activity timestamps. Core's own key write fires it once, as the write completes, naming\n\t * the branch. Once per change per repository (`repoPath` is its common path); see {@link MergeTargetsChangeEvent}.\n\t */\n\tget onDidChangeMergeTargets(): Event<MergeTargetsChangeEvent> {\n\t\treturn this._onDidChangeMergeTargets.event;\n\t}\n\n\t/** Keyed by the provider's event, so providers sharing one cache are forwarded once */\n\tprivate readonly _mergeTargetsSources = new Map<Event<MergeTargetsChangeEvent>, MergeTargetsSource>();\n\n\tprivate _etag = 0;\n\tprivate readonly _providers: RegisteredProvider[] = [];\n\tprivate readonly _serviceCache = new Map<string, RepositoryService>();\n\tprivate readonly _watchService: RepositoryWatchService | undefined;\n\tprivate readonly _summaries: WorktreeSummaryService | undefined;\n\n\tprivate constructor(\n\t\twatchingProvider?: FileWatchingProvider,\n\t\twatchPolling?: WatchPollingOptions,\n\t\treadFile?: (path: string) => Promise<Uint8Array>,\n\t\treadDirectory?: (path: string) => Promise<readonly (readonly [string, number])[]>,\n\t\tverifyBaseRemeasure?: WorktreeSummaryServiceOptions['verifyBaseRemeasure'],\n\t) {\n\t\tif (watchingProvider != null) {\n\t\t\tthis._watchService = new RepositoryWatchService({\n\t\t\t\twatchingProvider: watchingProvider,\n\t\t\t\tpolling: watchPolling,\n\t\t\t\treadFile: readFile,\n\t\t\t\treadDirectory: readDirectory,\n\t\t\t\tgetIgnoreFilter: (repoPath, gitDirPath) => {\n\t\t\t\t\treturn this.getProvider(repoPath)?.provider.getIgnoreFilter?.(repoPath, gitDirPath);\n\t\t\t\t},\n\t\t\t\tgetIgnoredDirectories: repoPath =>\n\t\t\t\t\tthis.getProvider(repoPath)?.provider.getIgnoredDirectories?.(repoPath) ?? Promise.resolve([]),\n\t\t\t\tgetIgnoredWorktreeRoots: repoPath =>\n\t\t\t\t\tthis.getProvider(repoPath)?.provider.getIgnoredWorktreeRoots?.(repoPath) ?? Promise.resolve([]),\n\t\t\t\tgetIgnoredWorktreeFolders: repoPath =>\n\t\t\t\t\tthis.getProvider(repoPath)?.provider.getIgnoredWorktreeFolders?.(repoPath) ?? [],\n\t\t\t});\n\t\t\tthis._summaries = new WorktreeSummaryService({\n\t\t\t\twatchService: this._watchService,\n\t\t\t\tgetRepository: repoPath => this.forRepo(repoPath),\n\t\t\t\tonDidChangeMergeTargets: this.onDidChangeMergeTargets,\n\t\t\t\tgetCommonPath: repoPath => this.getProvider(repoPath)?.provider.getCommonPath?.(repoPath),\n\t\t\t\t// The host's polling stat, when it configured polling, answers whether an unwatched index file moved\n\t\t\t\tstat: watchPolling?.stat,\n\t\t\t\tverifyBaseRemeasure: verifyBaseRemeasure,\n\t\t\t});\n\t\t}\n\n\t\tsetGlobalRepositoryServiceResolver(repoPath => this.forRepo(repoPath));\n\t}\n\n\t[Symbol.dispose](): void {\n\t\tthis.dispose();\n\t}\n\n\tdispose(): void {\n\t\tclearGlobalRepositoryServiceResolver();\n\t\tGitService._instance = undefined;\n\t\tthis._serviceCache.clear();\n\t\tthis._summaries?.dispose();\n\t\tthis._watchService?.dispose();\n\n\t\t// Don't dispose providers since they're owned by the caller, but do clear the array to release references\n\t\tfor (const entry of this._providers) {\n\t\t\tentry.announcements?.dispose();\n\t\t}\n\t\tthis._providers.length = 0;\n\n\t\tfor (const source of this._mergeTargetsSources.values()) {\n\t\t\tsource.subscription.dispose();\n\t\t}\n\t\tthis._mergeTargetsSources.clear();\n\n\t\tthis._onDidChangeProviders.dispose();\n\t\tthis._onDidChangeMergeTargets.dispose();\n\t}\n\n\t/** Monotonically increasing counter incremented on structural changes. */\n\tget etag(): number {\n\t\treturn this._etag;\n\t}\n\n\t/** Whether any providers are registered. */\n\tget hasProviders(): boolean {\n\t\treturn this._providers.length > 0;\n\t}\n\n\tget watchService(): RepositoryWatchService | undefined {\n\t\treturn this._watchService;\n\t}\n\n\t/** Cached, change-notifying per-worktree summaries, kept current by {@link watchService}; present when it is */\n\tget summaries(): WorktreeSummaryService | undefined {\n\t\treturn this._summaries;\n\t}\n\n\t/**\n\t * Registers a provider with a routing predicate.\n\t *\n\t * @returns A disposable that unregisters the provider.\n\t */\n\tregister(provider: GitProvider, canHandle: (repoPath: string) => boolean): UnifiedDisposable {\n\t\tconst watchService = this._watchService;\n\t\tconst entry: RegisteredProvider = {\n\t\t\tprovider: provider,\n\t\t\tcanHandle: canHandle,\n\t\t\tannouncements:\n\t\t\t\twatchService != null\n\t\t\t\t\t? provider.onDidAnnounceChanges?.(e =>\n\t\t\t\t\t\t\twatchService.noteSelfWrite(e.repoPath, e.changes, e.refs, {\n\t\t\t\t\t\t\t\tconfigConfinedToRefs: e.configConfinedToRefs,\n\t\t\t\t\t\t\t\tmovedWorktrees: e.movedWorktrees,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t)\n\t\t\t\t\t: undefined,\n\t\t};\n\t\tthis._providers.push(entry);\n\t\tthis._etag++;\n\t\tthis.addMergeTargetsSource(provider);\n\n\t\tthis._onDidChangeProviders.fire({\n\t\t\tadded: [provider],\n\t\t\tremoved: [],\n\t\t\tetag: this._etag,\n\t\t});\n\n\t\t// Invalidate cached proxies since provider routing may have changed\n\t\tthis._serviceCache.clear();\n\n\t\treturn createDisposable(() => {\n\t\t\tconst idx = this._providers.indexOf(entry);\n\t\t\tif (idx !== -1) {\n\t\t\t\tthis._providers.splice(idx, 1);\n\t\t\t\tentry.announcements?.dispose();\n\t\t\t\tthis._etag++;\n\t\t\t\tthis.removeMergeTargetsSource(provider);\n\t\t\t\tthis._serviceCache.clear();\n\n\t\t\t\tthis._onDidChangeProviders.fire({\n\t\t\t\t\tadded: [],\n\t\t\t\t\tremoved: [provider],\n\t\t\t\t\tetag: this._etag,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate addMergeTargetsSource(provider: GitProvider): void {\n\t\tconst event = provider.onDidChangeMergeTargets;\n\t\tif (event == null) return;\n\n\t\tconst source = this._mergeTargetsSources.get(event);\n\t\tif (source != null) {\n\t\t\tsource.refCount++;\n\t\t\treturn;\n\t\t}\n\n\t\tthis._mergeTargetsSources.set(event, {\n\t\t\tsubscription: event(e => this._onDidChangeMergeTargets.fire(e)),\n\t\t\trefCount: 1,\n\t\t});\n\t}\n\n\tprivate removeMergeTargetsSource(provider: GitProvider): void {\n\t\tconst event = provider.onDidChangeMergeTargets;\n\t\tif (event == null) return;\n\n\t\tconst source = this._mergeTargetsSources.get(event);\n\t\tif (source == null || --source.refCount > 0) return;\n\n\t\tsource.subscription.dispose();\n\t\tthis._mergeTargetsSources.delete(event);\n\t}\n\n\t/** Returns the provider that can handle the given path, or undefined if none matches. */\n\tgetProvider(repoPath: string): { provider: GitProvider; path: string } | undefined {\n\t\trepoPath = normalizePath(repoPath);\n\t\tfor (const entry of this._providers) {\n\t\t\tif (entry.canHandle(repoPath)) {\n\t\t\t\treturn { provider: entry.provider, path: repoPath };\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/** Returns all registered providers. */\n\t*getProviders(): Iterable<GitProvider> {\n\t\tfor (const entry of this._providers) {\n\t\t\tyield entry.provider;\n\t\t}\n\t}\n\n\t/**\n\t * Routes a repo URI/path to a provider and returns a cached\n\t * {@link RepositoryService} with repo-scoped sub-provider proxies.\n\t * Returns undefined if no provider can handle the path.\n\t */\n\tforRepo(repoUri: Uri | string): RepositoryService | undefined {\n\t\tconst repoPath = getRepositoryKey(repoUri);\n\n\t\tlet repo = this._serviceCache.get(repoPath);\n\t\tif (repo != null) return repo;\n\n\t\tconst result = this.getProvider(repoPath);\n\t\tif (result == null) return undefined;\n\n\t\trepo = createRepositoryService(result.provider, repoPath, this._watchService);\n\t\tthis._serviceCache.set(repoPath, repo);\n\t\treturn repo;\n\t}\n\n\t/**\n\t * Evicts the cached {@link RepositoryService} for a closed or removed repository.\n\t * No-op if the path isn't cached.\n\t */\n\tcloseRepo(repoUri: Uri | string): void {\n\t\tconst repoPath = getRepositoryKey(repoUri);\n\t\tthis._serviceCache.delete(repoPath);\n\t}\n\n\t/**\n\t * Validates whether `pathOrUri` points to (or resides inside) a git repository,\n\t * and returns information about it when it does.\n\t *\n\t * Routes the path to a registered provider and delegates to its config sub-provider's\n\t * `getRepositoryInfo` implementation, then normalizes the raw result into a clean\n\t * discriminated union. For a simple yes/no check, use `(await validateRepo(path)).valid`.\n\t *\n\t * Returns `{ valid: false }` if no provider can handle the path or if the routed\n\t * provider does not implement `getRepositoryInfo`. Rejects when git gives no answer\n\t * (it ran past its time limit, was killed or couldn't start), which says nothing about the path.\n\t */\n\tasync validateRepo(pathOrUri: Uri | string): Promise<ValidateRepoResult> {\n\t\tconst key = getRepositoryKey(pathOrUri);\n\t\tconst routed = this.getProvider(key);\n\t\tif (routed == null) return { valid: false };\n\n\t\tconst info = await routed.provider.config.getRepositoryInfo?.(routed.path);\n\t\tif (info == null) return { valid: false };\n\n\t\tif (Array.isArray(info)) {\n\t\t\tif (info.length === 0) return { valid: false };\n\t\t\tif (info[0] === false) return { valid: true, safe: false };\n\t\t\treturn { valid: true, safe: true, repoPath: info[1] };\n\t\t}\n\n\t\treturn {\n\t\t\tvalid: true,\n\t\t\tsafe: true,\n\t\t\trepoPath: info.repoPath,\n\t\t\tgitDir: info.gitDir,\n\t\t\tcommonGitDir: info.commonGitDir,\n\t\t\tsuperprojectPath: info.superprojectPath,\n\t\t};\n\t}\n}\n\nfunction createRepositoryService(\n\tprovider: GitProvider,\n\trepoPath: string,\n\twatchService?: RepositoryWatchService,\n): RepositoryService {\n\tconst proxies = new Map<string, SubProviderForRepo<unknown>>();\n\t// A provider with no registration to ask about gets proxies that only bind `repoPath`\n\tconst ensureRegistered =\n\t\tprovider.ensureRegistered != null ? () => provider.ensureRegistered?.(repoPath) : undefined;\n\n\tfunction getProxy<T extends object>(\n\t\tprop: SubProviderName,\n\t\tsubProvider: T | undefined,\n\t): SubProviderForRepo<T> | undefined {\n\t\tif (subProvider == null) return undefined;\n\n\t\tlet proxy = proxies.get(prop);\n\t\tif (proxy == null) {\n\t\t\tproxy = createSubProviderProxyForRepo(\n\t\t\t\tsubProvider,\n\t\t\t\trepoPath,\n\t\t\t\tensureRegistered != null\n\t\t\t\t\t? { ensureRegistered: ensureRegistered, callThrough: subProviderCallThroughMethods[prop] }\n\t\t\t\t\t: undefined,\n\t\t\t);\n\t\t\tproxies.set(prop, proxy);\n\t\t}\n\t\treturn proxy as SubProviderForRepo<T>;\n\t}\n\n\treturn {\n\t\tpath: repoPath,\n\t\tprovider: provider.descriptor,\n\n\t\tget etagWorkingTree(): number | undefined {\n\t\t\treturn watchService?.getSession(repoPath)?.etagWorkingTree;\n\t\t},\n\n\t\tgetAbsoluteUri: (relativePath: string): Uri => {\n\t\t\treturn provider.getAbsoluteUri(relativePath, repoPath);\n\t\t},\n\n\t\t// Required sub-providers\n\t\tget branches() {\n\t\t\tconst proxy = getProxy('branches', provider.branches);\n\t\t\tif (proxy == null) throw new Error('GitService: branches sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget commits() {\n\t\t\tconst proxy = getProxy('commits', provider.commits);\n\t\t\tif (proxy == null) throw new Error('GitService: commits sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget config() {\n\t\t\tconst proxy = getProxy('config', provider.config);\n\t\t\tif (proxy == null) throw new Error('GitService: config sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget contributors() {\n\t\t\tconst proxy = getProxy('contributors', provider.contributors);\n\t\t\tif (proxy == null) throw new Error('GitService: contributors sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget diff() {\n\t\t\tconst proxy = getProxy('diff', provider.diff);\n\t\t\tif (proxy == null) throw new Error('GitService: diff sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget graph() {\n\t\t\tconst proxy = getProxy('graph', provider.graph);\n\t\t\tif (proxy == null) throw new Error('GitService: graph sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget refs() {\n\t\t\tconst proxy = getProxy('refs', provider.refs);\n\t\t\tif (proxy == null) throw new Error('GitService: refs sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget remotes() {\n\t\t\tconst proxy = getProxy('remotes', provider.remotes);\n\t\t\tif (proxy == null) throw new Error('GitService: remotes sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget revision() {\n\t\t\tconst proxy = getProxy('revision', provider.revision);\n\t\t\tif (proxy == null) throw new Error('GitService: revision sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget status() {\n\t\t\tconst proxy = getProxy('status', provider.status);\n\t\t\tif (proxy == null) throw new Error('GitService: status sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\t\tget tags() {\n\t\t\tconst proxy = getProxy('tags', provider.tags);\n\t\t\tif (proxy == null) throw new Error('GitService: tags sub-provider is required but not registered');\n\t\t\treturn proxy;\n\t\t},\n\n\t\t// Optional sub-providers\n\t\tget blame() {\n\t\t\treturn getProxy('blame', provider.blame);\n\t\t},\n\t\tget maintenance() {\n\t\t\treturn getProxy('maintenance', provider.maintenance);\n\t\t},\n\t\tget ops() {\n\t\t\treturn getProxy('ops', provider.ops);\n\t\t},\n\t\tget patch() {\n\t\t\treturn getProxy('patch', provider.patch);\n\t\t},\n\t\tget pausedOps() {\n\t\t\treturn getProxy('pausedOps', provider.pausedOps);\n\t\t},\n\t\tget staging() {\n\t\t\treturn getProxy('staging', provider.staging);\n\t\t},\n\t\tget stash() {\n\t\t\treturn getProxy('stash', provider.stash);\n\t\t},\n\t\tget worktrees() {\n\t\t\treturn getProxy('worktrees', provider.worktrees);\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,IAAa,aAAb,MAAa,WAAwC;CACpD,OAAe;;;;;;;;CASf,OAAO,gBACN,kBACA,SAMa;EACb,IAAI,WAAW,aAAa,MAC3B,MAAM,IAAI,MAA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AAM,QAAQ,SAAS,UAAU,SAAS,MAAM;GAChD,IAAI,SAAS,MAAM,MAAM,IAAI,MAAM,gEAAgE;GACnG,OAAO;EACR;EACA,IAAI,OAAO;GACV,MAAM,QAAQ,SAAS,QAAQ,SAAS,IAAI;GAC5C,IAAI,SAAS,MAAM,MAAM,IAAI,MAAM,8DAA8D;GACjG,OAAO;EACR;EAGA,IAAI,QAAQ;GACX,OAAO,SAAS,SAAS,SAAS,KAAK;EACxC;EACA,IAAI,cAAc;GACjB,OAAO,SAAS,eAAe,SAAS,WAAW;EACpD;EACA,IAAI,MAAM;GACT,OAAO,SAAS,OAAO,SAAS,GAAG;EACpC;EACA,IAAI,QAAQ;GACX,OAAO,SAAS,SAAS,SAAS,KAAK;EACxC;EACA,IAAI,YAAY;GACf,OAAO,SAAS,aAAa,SAAS,SAAS;EAChD;EACA,IAAI,UAAU;GACb,OAAO,SAAS,WAAW,SAAS,OAAO;EAC5C;EACA,IAAI,QAAQ;GACX,OAAO,SAAS,SAAS,SAAS,KAAK;EACxC;EACA,IAAI,YAAY;GACf,OAAO,SAAS,aAAa,SAAS,SAAS;EAChD;CACD;AACD"}
@@ -29,5 +29,10 @@ export declare function getFileDiffPathspecs(file: {
29
29
  path: string;
30
30
  originalPath?: string;
31
31
  }): string[];
32
+ /**
33
+ * Matches a repository-relative path as git matches `:(literal)` pathspecs: a path itself or anything under it, a
34
+ * trailing slash naming the same folder, and `.` the whole repository.
35
+ */
36
+ export declare function toLiteralPathspecMatcher(paths: readonly string[]): (path: string) => boolean;
32
37
  //#endregion
33
38
  //# sourceMappingURL=fileStatus.utils.d.ts.map
@@ -63,7 +63,24 @@ function isConflictStatus(status) {
63
63
  function getFileDiffPathspecs(file) {
64
64
  return file.originalPath ? [file.path, file.originalPath] : [file.path];
65
65
  }
66
+ /**
67
+ * Matches a repository-relative path as git matches `:(literal)` pathspecs: a path itself or anything under it, a
68
+ * trailing slash naming the same folder, and `.` the whole repository.
69
+ */
70
+ function toLiteralPathspecMatcher(paths) {
71
+ const specs = /* @__PURE__ */ new Set();
72
+ for (const p of paths) {
73
+ const spec = p.replace(/\/+$/, "");
74
+ if (spec === "" || spec === ".") return () => true;
75
+ specs.add(spec);
76
+ }
77
+ return (path) => {
78
+ if (specs.has(path)) return true;
79
+ for (let i = path.lastIndexOf("/"); i > 0; i = path.lastIndexOf("/", i - 1)) if (specs.has(path.substring(0, i))) return true;
80
+ return false;
81
+ };
82
+ }
66
83
  //#endregion
67
- export { getFileDiffPathspecs, getGitFileStatusIcon, getGitFileStatusText, isConflictStatus };
84
+ export { getFileDiffPathspecs, getGitFileStatusIcon, getGitFileStatusText, isConflictStatus, toLiteralPathspecMatcher };
68
85
 
69
86
  //# sourceMappingURL=fileStatus.utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fileStatus.utils.js","names":[],"sources":["../../../../git/src/utils/fileStatus.utils.ts"],"sourcesContent":["import * as l10n from '@vscode/l10n';\nimport type { GitFileConflictStatus, GitFileStatus } from '../models/fileStatus.js';\n\nconst statusIconsMap = {\n\t'.': undefined,\n\t'!': 'icon-status-ignored.svg',\n\t'?': 'icon-status-untracked.svg',\n\tA: 'icon-status-added.svg',\n\tD: 'icon-status-deleted.svg',\n\tM: 'icon-status-modified.svg',\n\tR: 'icon-status-renamed.svg',\n\tC: 'icon-status-copied.svg',\n\tAA: 'icon-status-conflict.svg',\n\tAU: 'icon-status-conflict.svg',\n\tUA: 'icon-status-conflict.svg',\n\tDD: 'icon-status-conflict.svg',\n\tDU: 'icon-status-conflict.svg',\n\tUD: 'icon-status-conflict.svg',\n\tUU: 'icon-status-conflict.svg',\n\tT: 'icon-status-modified.svg',\n\tU: 'icon-status-modified.svg',\n};\n\nexport function getGitFileStatusIcon(status: GitFileStatus): string {\n\treturn statusIconsMap[status] ?? 'icon-status-unknown.svg';\n}\n\nconst statusTextMap = {\n\t'.': l10n.t('Unchanged'),\n\t'!': l10n.t('Ignored'),\n\t'?': l10n.t('Untracked'),\n\tA: l10n.t('Added'),\n\tD: l10n.t('Deleted'),\n\tM: l10n.t('Modified'),\n\tR: l10n.t('Renamed'),\n\tC: l10n.t('Copied'),\n\tAA: l10n.t('Added (Both)'),\n\tAU: l10n.t('Added (Current)'),\n\tUA: l10n.t('Added (Incoming)'),\n\tDD: l10n.t('Deleted (Both)'),\n\tDU: l10n.t('Deleted (Current)'),\n\tUD: l10n.t('Deleted (Incoming)'),\n\tUU: l10n.t('Modified (Both)'),\n\tT: l10n.t('Modified'),\n\tU: l10n.t('Updated but Unmerged'),\n};\n\nexport function getGitFileStatusText(status: GitFileStatus | keyof typeof statusTextMap): string {\n\treturn statusTextMap[status] ?? l10n.t('Unknown');\n}\n\nconst conflictStatuses = new Set<string>(['U', 'AA', 'AU', 'UA', 'DD', 'DU', 'UD', 'UU']);\n\nexport function isConflictStatus(status: string | undefined): status is 'U' | GitFileConflictStatus {\n\treturn status != null && conflictStatuses.has(status);\n}\n\n/** Repo-relative pathspec entries for a file. Renames/copies need BOTH sides: git applies pathspec limiting\n * before rename detection, so `git diff -- <new>` drops the old path's deletion and the patch reads as a\n * bare add (applying it duplicates the file instead of renaming it). */\nexport function getFileDiffPathspecs(file: { path: string; originalPath?: string }): string[] {\n\treturn file.originalPath ? [file.path, file.originalPath] : [file.path];\n}\n"],"mappings":";;AAGA,MAAM,iBAAiB;CACtB,KAAK,KAAA;CACL,KAAK;CACL,KAAK;CACL,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,GAAG;CACH,GAAG;AACJ;AAEA,SAAgB,qBAAqB,QAA+B;CACnE,OAAO,eAAe,WAAW;AAClC;AAEA,MAAM,gBAAgB;CACrB,KAAK,KAAK,EAAE,WAAW;CACvB,KAAK,KAAK,EAAE,SAAS;CACrB,KAAK,KAAK,EAAE,WAAW;CACvB,GAAG,KAAK,EAAE,OAAO;CACjB,GAAG,KAAK,EAAE,SAAS;CACnB,GAAG,KAAK,EAAE,UAAU;CACpB,GAAG,KAAK,EAAE,SAAS;CACnB,GAAG,KAAK,EAAE,QAAQ;CAClB,IAAI,KAAK,EAAE,cAAc;CACzB,IAAI,KAAK,EAAE,iBAAiB;CAC5B,IAAI,KAAK,EAAE,kBAAkB;CAC7B,IAAI,KAAK,EAAE,gBAAgB;CAC3B,IAAI,KAAK,EAAE,mBAAmB;CAC9B,IAAI,KAAK,EAAE,oBAAoB;CAC/B,IAAI,KAAK,EAAE,iBAAiB;CAC5B,GAAG,KAAK,EAAE,UAAU;CACpB,GAAG,KAAK,EAAE,sBAAsB;AACjC;AAEA,SAAgB,qBAAqB,QAA4D;CAChG,OAAO,cAAc,WAAW,KAAK,EAAE,SAAS;AACjD;AAEA,MAAM,mCAAmB,IAAI,IAAY;CAAC;CAAK;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;AAAI,CAAC;AAExF,SAAgB,iBAAiB,QAAmE;CACnG,OAAO,UAAU,QAAQ,iBAAiB,IAAI,MAAM;AACrD;;;;AAKA,SAAgB,qBAAqB,MAAyD;CAC7F,OAAO,KAAK,eAAe,CAAC,KAAK,MAAM,KAAK,YAAY,IAAI,CAAC,KAAK,IAAI;AACvE"}
1
+ {"version":3,"file":"fileStatus.utils.js","names":[],"sources":["../../../../git/src/utils/fileStatus.utils.ts"],"sourcesContent":["import * as l10n from '@vscode/l10n';\nimport type { GitFileConflictStatus, GitFileStatus } from '../models/fileStatus.js';\n\nconst statusIconsMap = {\n\t'.': undefined,\n\t'!': 'icon-status-ignored.svg',\n\t'?': 'icon-status-untracked.svg',\n\tA: 'icon-status-added.svg',\n\tD: 'icon-status-deleted.svg',\n\tM: 'icon-status-modified.svg',\n\tR: 'icon-status-renamed.svg',\n\tC: 'icon-status-copied.svg',\n\tAA: 'icon-status-conflict.svg',\n\tAU: 'icon-status-conflict.svg',\n\tUA: 'icon-status-conflict.svg',\n\tDD: 'icon-status-conflict.svg',\n\tDU: 'icon-status-conflict.svg',\n\tUD: 'icon-status-conflict.svg',\n\tUU: 'icon-status-conflict.svg',\n\tT: 'icon-status-modified.svg',\n\tU: 'icon-status-modified.svg',\n};\n\nexport function getGitFileStatusIcon(status: GitFileStatus): string {\n\treturn statusIconsMap[status] ?? 'icon-status-unknown.svg';\n}\n\nconst statusTextMap = {\n\t'.': l10n.t('Unchanged'),\n\t'!': l10n.t('Ignored'),\n\t'?': l10n.t('Untracked'),\n\tA: l10n.t('Added'),\n\tD: l10n.t('Deleted'),\n\tM: l10n.t('Modified'),\n\tR: l10n.t('Renamed'),\n\tC: l10n.t('Copied'),\n\tAA: l10n.t('Added (Both)'),\n\tAU: l10n.t('Added (Current)'),\n\tUA: l10n.t('Added (Incoming)'),\n\tDD: l10n.t('Deleted (Both)'),\n\tDU: l10n.t('Deleted (Current)'),\n\tUD: l10n.t('Deleted (Incoming)'),\n\tUU: l10n.t('Modified (Both)'),\n\tT: l10n.t('Modified'),\n\tU: l10n.t('Updated but Unmerged'),\n};\n\nexport function getGitFileStatusText(status: GitFileStatus | keyof typeof statusTextMap): string {\n\treturn statusTextMap[status] ?? l10n.t('Unknown');\n}\n\nconst conflictStatuses = new Set<string>(['U', 'AA', 'AU', 'UA', 'DD', 'DU', 'UD', 'UU']);\n\nexport function isConflictStatus(status: string | undefined): status is 'U' | GitFileConflictStatus {\n\treturn status != null && conflictStatuses.has(status);\n}\n\n/** Repo-relative pathspec entries for a file. Renames/copies need BOTH sides: git applies pathspec limiting\n * before rename detection, so `git diff -- <new>` drops the old path's deletion and the patch reads as a\n * bare add (applying it duplicates the file instead of renaming it). */\nexport function getFileDiffPathspecs(file: { path: string; originalPath?: string }): string[] {\n\treturn file.originalPath ? [file.path, file.originalPath] : [file.path];\n}\n\n/**\n * Matches a repository-relative path as git matches `:(literal)` pathspecs: a path itself or anything under it, a\n * trailing slash naming the same folder, and `.` the whole repository.\n */\nexport function toLiteralPathspecMatcher(paths: readonly string[]): (path: string) => boolean {\n\tconst specs = new Set<string>();\n\tfor (const p of paths) {\n\t\tconst spec = p.replace(/\\/+$/, '');\n\t\tif (spec === '' || spec === '.') return () => true;\n\n\t\tspecs.add(spec);\n\t}\n\n\treturn path => {\n\t\tif (specs.has(path)) return true;\n\n\t\tfor (let i = path.lastIndexOf('/'); i > 0; i = path.lastIndexOf('/', i - 1)) {\n\t\t\tif (specs.has(path.substring(0, i))) return true;\n\t\t}\n\t\treturn false;\n\t};\n}\n"],"mappings":";;AAGA,MAAM,iBAAiB;CACtB,KAAK,KAAA;CACL,KAAK;CACL,KAAK;CACL,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,GAAG;CACH,GAAG;AACJ;AAEA,SAAgB,qBAAqB,QAA+B;CACnE,OAAO,eAAe,WAAW;AAClC;AAEA,MAAM,gBAAgB;CACrB,KAAK,KAAK,EAAE,WAAW;CACvB,KAAK,KAAK,EAAE,SAAS;CACrB,KAAK,KAAK,EAAE,WAAW;CACvB,GAAG,KAAK,EAAE,OAAO;CACjB,GAAG,KAAK,EAAE,SAAS;CACnB,GAAG,KAAK,EAAE,UAAU;CACpB,GAAG,KAAK,EAAE,SAAS;CACnB,GAAG,KAAK,EAAE,QAAQ;CAClB,IAAI,KAAK,EAAE,cAAc;CACzB,IAAI,KAAK,EAAE,iBAAiB;CAC5B,IAAI,KAAK,EAAE,kBAAkB;CAC7B,IAAI,KAAK,EAAE,gBAAgB;CAC3B,IAAI,KAAK,EAAE,mBAAmB;CAC9B,IAAI,KAAK,EAAE,oBAAoB;CAC/B,IAAI,KAAK,EAAE,iBAAiB;CAC5B,GAAG,KAAK,EAAE,UAAU;CACpB,GAAG,KAAK,EAAE,sBAAsB;AACjC;AAEA,SAAgB,qBAAqB,QAA4D;CAChG,OAAO,cAAc,WAAW,KAAK,EAAE,SAAS;AACjD;AAEA,MAAM,mCAAmB,IAAI,IAAY;CAAC;CAAK;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;AAAI,CAAC;AAExF,SAAgB,iBAAiB,QAAmE;CACnG,OAAO,UAAU,QAAQ,iBAAiB,IAAI,MAAM;AACrD;;;;AAKA,SAAgB,qBAAqB,MAAyD;CAC7F,OAAO,KAAK,eAAe,CAAC,KAAK,MAAM,KAAK,YAAY,IAAI,CAAC,KAAK,IAAI;AACvE;;;;;AAMA,SAAgB,yBAAyB,OAAqD;CAC7F,MAAM,wBAAQ,IAAI,IAAY;CAC9B,KAAK,MAAM,KAAK,OAAO;EACtB,MAAM,OAAO,EAAE,QAAQ,QAAQ,EAAE;EACjC,IAAI,SAAS,MAAM,SAAS,KAAK,aAAa;EAE9C,MAAM,IAAI,IAAI;CACf;CAEA,QAAO,SAAQ;EACd,IAAI,MAAM,IAAI,IAAI,GAAG,OAAO;EAE5B,KAAK,IAAI,IAAI,KAAK,YAAY,GAAG,GAAG,IAAI,GAAG,IAAI,KAAK,YAAY,KAAK,IAAI,CAAC,GACzE,IAAI,MAAM,IAAI,KAAK,UAAU,GAAG,CAAC,CAAC,GAAG,OAAO;EAE7C,OAAO;CACR;AACD"}
@@ -37,6 +37,7 @@ export declare class WatcherRepoChangeEvent {
37
37
  private readonly _announced;
38
38
  private readonly _configBranches;
39
39
  private readonly _movedWorktrees;
40
+ private readonly _observedAt;
40
41
  constructor(
41
42
  /** The repository path this event is for */
42
43
  repoPath: string, changes: RepositoryChange[],
@@ -45,7 +46,9 @@ export declare class WatcherRepoChangeEvent {
45
46
  /** The kinds of `changes` that come only from core's own announced writes (see {@link announced}) */
46
47
  announced?: Iterable<RepositoryChange>,
47
48
  /** For a `worktreeHead` among `changes`, the worktrees moved outside core's writes (see {@link movedWorktrees}) */
48
- movedWorktrees?: Iterable<string>);
49
+ movedWorktrees?: Iterable<string>,
50
+ /** When the newest of `changes` was observed (see {@link observedAt}) */
51
+ observedAt?: number);
49
52
  get changes(): ReadonlySet<RepositoryChange>;
50
53
  /**
51
54
  * The kinds in {@link changes} that come only from core's own writes, which core already announced through
@@ -71,6 +74,12 @@ export declare class WatcherRepoChangeEvent {
71
74
  * change, or any linked worktree's HEAD may have moved.
72
75
  */
73
76
  get movedWorktrees(): ReadonlySet<string> | undefined;
77
+ /**
78
+ * The change ordinal (see `nextChangeOrdinal`) taken when the watch session received the newest report among
79
+ * {@link changes}, each of which was on disk by then; `undefined` when that isn't known, as for a change injected by
80
+ * a caller. A cache can keep what it evicted whole after this, since that was read after every change here.
81
+ */
82
+ get observedAt(): number | undefined;
74
83
  /** Whether `config` changed only in the sections of {@link configBranches} */
75
84
  get configConfined(): boolean;
76
85
  /**
@@ -113,9 +122,10 @@ export declare class WatcherRepoChangeEvent {
113
122
  * Coalesce: return a new event with all changes and refs from both this and the given set. When `refs` is omitted,
114
123
  * every ref kind in `changes` counts as unnamed. A kind in `changes` is no longer {@link announced}. `config` stays
115
124
  * {@link configConfined}, to the branches of both, only when each side that changed it was confined, and
116
- * `worktreeHead` keeps {@link movedWorktrees}, those of both, only when each side that changed it named them.
125
+ * `worktreeHead` keeps {@link movedWorktrees}, those of both, only when each side that changed it named them. The
126
+ * result was observed when the newer side was, and isn't known to have been when either side isn't.
117
127
  */
118
- with(changes: RepositoryChange[], refs?: WatcherRefChanges, movedWorktrees?: Iterable<string>): WatcherRepoChangeEvent;
128
+ with(changes: RepositoryChange[], refs?: WatcherRefChanges, movedWorktrees?: Iterable<string>, observedAt?: number): WatcherRepoChangeEvent;
119
129
  }
120
130
  /**
121
131
  * Returns the name in `names` that covers `ref` — `ref` itself, or a ref directory above it (compared on `/`
@@ -31,7 +31,8 @@ var WatcherRepoChangeEvent = class WatcherRepoChangeEvent {
31
31
  _announced;
32
32
  _configBranches;
33
33
  _movedWorktrees;
34
- constructor(repoPath, changes, refs, announced, movedWorktrees) {
34
+ _observedAt;
35
+ constructor(repoPath, changes, refs, announced, movedWorktrees, observedAt) {
35
36
  this.repoPath = repoPath;
36
37
  this._changes = new Set(changes);
37
38
  if (refs == null) {
@@ -44,6 +45,7 @@ var WatcherRepoChangeEvent = class WatcherRepoChangeEvent {
44
45
  this._configBranches = refs?.configBranches != null && this._changes.has("config") ? new Set(refs.configBranches) : void 0;
45
46
  this._announced = announced != null ? new Set(filter(announced, (c) => this._changes.has(c))) : /* @__PURE__ */ new Set();
46
47
  this._movedWorktrees = movedWorktrees != null && this._changes.has("worktreeHead") ? new Set(movedWorktrees) : void 0;
48
+ this._observedAt = observedAt;
47
49
  }
48
50
  get changes() {
49
51
  return this._changes;
@@ -84,6 +86,14 @@ var WatcherRepoChangeEvent = class WatcherRepoChangeEvent {
84
86
  get movedWorktrees() {
85
87
  return this._movedWorktrees;
86
88
  }
89
+ /**
90
+ * The change ordinal (see `nextChangeOrdinal`) taken when the watch session received the newest report among
91
+ * {@link changes}, each of which was on disk by then; `undefined` when that isn't known, as for a change injected by
92
+ * a caller. A cache can keep what it evicted whole after this, since that was read after every change here.
93
+ */
94
+ get observedAt() {
95
+ return this._observedAt;
96
+ }
87
97
  /** Whether `config` changed only in the sections of {@link configBranches} */
88
98
  get configConfined() {
89
99
  return this._configBranches != null;
@@ -157,9 +167,10 @@ var WatcherRepoChangeEvent = class WatcherRepoChangeEvent {
157
167
  * Coalesce: return a new event with all changes and refs from both this and the given set. When `refs` is omitted,
158
168
  * every ref kind in `changes` counts as unnamed. A kind in `changes` is no longer {@link announced}. `config` stays
159
169
  * {@link configConfined}, to the branches of both, only when each side that changed it was confined, and
160
- * `worktreeHead` keeps {@link movedWorktrees}, those of both, only when each side that changed it named them.
170
+ * `worktreeHead` keeps {@link movedWorktrees}, those of both, only when each side that changed it named them. The
171
+ * result was observed when the newer side was, and isn't known to have been when either side isn't.
161
172
  */
162
- with(changes, refs, movedWorktrees) {
173
+ with(changes, refs, movedWorktrees, observedAt) {
163
174
  const names = [...this._refs];
164
175
  const unnamed = [...this._unnamedRefKinds];
165
176
  if (refs == null) unnamed.push(...filter(changes, isRefChangeKind));
@@ -179,7 +190,7 @@ var WatcherRepoChangeEvent = class WatcherRepoChangeEvent {
179
190
  names,
180
191
  unnamed,
181
192
  configBranches
182
- }, filter(this._announced, (c) => !changes.includes(c)), moved);
193
+ }, filter(this._announced, (c) => !changes.includes(c)), moved, this._observedAt != null && observedAt != null ? Math.max(this._observedAt, observedAt) : void 0);
183
194
  }
184
195
  };
185
196
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"changeEvent.js","names":[],"sources":["../../../../git/src/watching/changeEvent.ts"],"sourcesContent":["import { filter, some } from '@gitlens/utils/iterable.js';\nimport type { RepositoryChange } from '../models/repository.js';\n\n/** The {@link RepositoryChange} kinds that describe ref movement, which an event can attribute to named refs */\nexport type RefChangeKind = 'heads' | 'remotes' | 'tags' | 'stash';\n\nexport interface WatcherRefChanges {\n\t/** Full ref names whose files changed (`refs/heads/main`), plus per-worktree pseudo-refs (`HEAD`, `ORIG_HEAD`). A name may be a ref directory and then covers every ref beneath it. */\n\treadonly names?: Iterable<string>;\n\t/** Ref kinds that changed without a name (packed-refs rewrite, a ref namespace directory like `refs/remotes`, shallow/replace, an injected change): any ref of that kind may have moved. */\n\treadonly unnamed?: Iterable<RefChangeKind>;\n\t/**\n\t * The local branches (full `refs/heads/` names) whose `branch.<name>` sections are all that every `config` change\n\t * among the changes touched in `.git/config`. Omitted when any of them may have changed anything else.\n\t */\n\treadonly configBranches?: Iterable<string>;\n}\n\nexport function isRefChangeKind(change: RepositoryChange): change is RefChangeKind {\n\treturn change === 'heads' || change === 'remotes' || change === 'tags' || change === 'stash';\n}\n\n/**\n * The kind of ref a full ref name (or ref directory) belongs to. A pseudo-ref (no `refs/` prefix, e.g. `HEAD`,\n * `ORIG_HEAD`) counts as `heads`; a ref outside the watched namespaces (e.g. `refs/notes/x`) has no kind, and neither\n * has a namespace directory itself (`refs/remotes`), so a change reported for one names no ref: any ref of the kind it\n * holds may have moved.\n */\nexport function getRefChangeKind(ref: string): RefChangeKind | undefined {\n\tif (!ref.startsWith('refs/')) return 'heads';\n\tif (ref.startsWith('refs/heads/')) return 'heads';\n\tif (ref.startsWith('refs/remotes/')) return 'remotes';\n\tif (ref.startsWith('refs/tags/')) return 'tags';\n\tif (ref === 'refs/stash') return 'stash';\n\n\treturn undefined;\n}\n\n/**\n * An event describing changes to a repository, produced by the watching pipeline.\n *\n * Changes are coalesced within a debounce window — a single event may represent\n * multiple filesystem changes. Use {@link changed} to test for specific change types,\n * and {@link mayHaveChangedRef} to test whether a specific ref may have moved.\n */\nexport class WatcherRepoChangeEvent {\n\tprotected readonly _changes: Set<RepositoryChange>;\n\tprivate readonly _refs: Set<string>;\n\tprivate readonly _unnamedRefKinds: Set<RefChangeKind>;\n\tprivate readonly _announced: Set<RepositoryChange>;\n\tprivate readonly _configBranches: Set<string> | undefined;\n\tprivate readonly _movedWorktrees: Set<string> | undefined;\n\n\tconstructor(\n\t\t/** The repository path this event is for */\n\t\tpublic readonly repoPath: string,\n\t\tchanges: RepositoryChange[],\n\t\t/** Which refs changed; when omitted, every ref kind in `changes` is unnamed (any ref of that kind may have moved) */\n\t\trefs?: WatcherRefChanges,\n\t\t/** The kinds of `changes` that come only from core's own announced writes (see {@link announced}) */\n\t\tannounced?: Iterable<RepositoryChange>,\n\t\t/** For a `worktreeHead` among `changes`, the worktrees moved outside core's writes (see {@link movedWorktrees}) */\n\t\tmovedWorktrees?: Iterable<string>,\n\t) {\n\t\tthis._changes = new Set(changes);\n\t\tif (refs == null) {\n\t\t\tthis._refs = new Set();\n\t\t\tthis._unnamedRefKinds = new Set(filter(changes, isRefChangeKind));\n\t\t} else {\n\t\t\tthis._refs = new Set(refs.names);\n\t\t\tthis._unnamedRefKinds = new Set(refs.unnamed);\n\t\t}\n\t\tthis._configBranches =\n\t\t\trefs?.configBranches != null && this._changes.has('config') ? new Set(refs.configBranches) : undefined;\n\t\tthis._announced = announced != null ? new Set(filter(announced, c => this._changes.has(c))) : new Set();\n\t\tthis._movedWorktrees =\n\t\t\tmovedWorktrees != null && this._changes.has('worktreeHead') ? new Set(movedWorktrees) : undefined;\n\t}\n\n\tget changes(): ReadonlySet<RepositoryChange> {\n\t\treturn this._changes;\n\t}\n\n\t/**\n\t * The kinds in {@link changes} that come only from core's own writes, which core already announced through\n\t * `hooks.repository.onChanged` after evicting their caches. A host that handled that announcement can skip them;\n\t * a kind the watcher or an injected change also reported is not among them.\n\t */\n\tget announced(): ReadonlySet<RepositoryChange> {\n\t\treturn this._announced;\n\t}\n\n\t/** The kinds in {@link changes} that aren't {@link announced}: what a cache that core already evicted for its write still has to clear */\n\tgetUnannouncedChanges(): RepositoryChange[] {\n\t\treturn this._announced.size ? [...filter(this._changes, c => !this._announced.has(c))] : [...this._changes];\n\t}\n\n\t/** Full ref names (or ref directories, or pseudo-refs) known to have changed. See {@link WatcherRefChanges.names}. */\n\tget refs(): ReadonlySet<string> {\n\t\treturn this._refs;\n\t}\n\n\t/** Ref kinds that changed without a name — any ref of these kinds may have moved */\n\tget unnamedRefKinds(): ReadonlySet<RefChangeKind> {\n\t\treturn this._unnamedRefKinds;\n\t}\n\n\t/**\n\t * The local branches (full `refs/heads/` names) whose `branch.<name>` sections are the only part of `.git/config`\n\t * that changed; `undefined` when `config` didn't change, or any config change may be elsewhere. Independent of\n\t * {@link refs}: an outside edit to a branch's tracking moves no ref.\n\t */\n\tget configBranches(): ReadonlySet<string> | undefined {\n\t\treturn this._configBranches;\n\t}\n\n\t/**\n\t * The admin ids (the `<id>` of `.git/worktrees/<id>`) of the linked worktrees whose HEAD moved other than by core's\n\t * announced writes, which are all that an unannounced `worktreeHead` reports; `undefined` when `worktreeHead` didn't\n\t * change, or any linked worktree's HEAD may have moved.\n\t */\n\tget movedWorktrees(): ReadonlySet<string> | undefined {\n\t\treturn this._movedWorktrees;\n\t}\n\n\t/** Whether `config` changed only in the sections of {@link configBranches} */\n\tget configConfined(): boolean {\n\t\treturn this._configBranches != null;\n\t}\n\n\t/**\n\t * Test whether `config` may have changed in a way that concerns a subscriber following `relevantRefs`.\n\t *\n\t * A branch's config section matters only to a checkout on that branch or one whose upstream or base is that branch,\n\t * and those follow `refs/heads/<name>` (or `HEAD`, which may be on any branch). So a {@link configConfined} change\n\t * concerns `relevantRefs` only when one of them is `HEAD` or one of {@link configBranches}; any other config change\n\t * concerns everyone.\n\t */\n\tmayHaveChangedConfig(relevantRefs: Iterable<string>): boolean {\n\t\tif (!this._changes.has('config')) return false;\n\t\tif (this._configBranches == null) return true;\n\n\t\tfor (const ref of relevantRefs) {\n\t\t\tif (ref === 'HEAD' || this._configBranches.has(ref)) return true;\n\t\t}\n\t\treturn false;\n\t}\n\n\ttoString(changesOnly: boolean = false): string {\n\t\tconst changeList = [...this._changes].join(', ');\n\t\tconst refCount = this._refs.size;\n\t\tif (changesOnly) return refCount ? `changes=${changeList}, refs=${refCount}` : `changes=${changeList}`;\n\n\t\treturn refCount\n\t\t\t? `{ repoPath: ${this.repoPath}, changes: ${changeList}, refs: ${refCount} }`\n\t\t\t: `{ repoPath: ${this.repoPath}, changes: ${changeList} }`;\n\t}\n\n\t/**\n\t * Test whether the given ref may have moved in this event.\n\t *\n\t * @param ref - A full ref name (`refs/heads/main`) or a pseudo-ref (`HEAD`).\n\t * @returns `false` when the ref's kind didn't change (or the ref is outside the watched kinds); `true` when its kind\n\t * changed without a name, or when the ref itself or a ref directory above it changed. `HEAD` is usually a symref\n\t * to the checked-out branch, so it may have moved whenever any `heads` ref did.\n\t */\n\tmayHaveChangedRef(ref: string): boolean {\n\t\tconst kind = getRefChangeKind(ref);\n\t\tif (kind == null || !this._changes.has(kind)) return false;\n\t\tif (this._unnamedRefKinds.has(kind) || ref === 'HEAD') return true;\n\n\t\treturn findCoveringRefName(this._refs, ref) != null;\n\t}\n\n\t/**\n\t * Test whether any of the specified change types are present in the event.\n\t *\n\t * @param affected - Change types to test for.\n\t * @returns `true` if any of the specified changes are present.\n\t */\n\tchanged(...affected: RepositoryChange[]): boolean {\n\t\treturn some(this._changes, c => affected.includes(c));\n\t}\n\n\t/**\n\t * Test whether the event contains ONLY the specified change types.\n\t *\n\t * `pausedOp` is treated as a union of `cherryPick`, `merge`, `rebase`,\n\t * and `revert` for convenience.\n\t *\n\t * @param affected - Change types to test for.\n\t * @returns `true` if the event contains only the specified changes.\n\t */\n\tchangedExclusive(...affected: RepositoryChange[]): boolean {\n\t\tlet changes = this._changes;\n\n\t\t// When checking for specific paused operation types, also accept the union type\n\t\tif (\n\t\t\taffected.includes('cherryPick') ||\n\t\t\taffected.includes('merge') ||\n\t\t\taffected.includes('rebase') ||\n\t\t\taffected.includes('revert')\n\t\t) {\n\t\t\tif (!affected.includes('pausedOp')) {\n\t\t\t\taffected = [...affected, 'pausedOp'];\n\t\t\t}\n\t\t} else if (affected.includes('pausedOp')) {\n\t\t\t// When checking for the union type exclusively, ignore specific subtypes\n\t\t\tchanges = new Set(changes);\n\t\t\tchanges.delete('cherryPick');\n\t\t\tchanges.delete('merge');\n\t\t\tchanges.delete('rebase');\n\t\t\tchanges.delete('revert');\n\t\t}\n\n\t\tconst intersection = [...filter(changes, c => affected.includes(c))];\n\t\treturn intersection.length === changes.size;\n\t}\n\n\t/**\n\t * Coalesce: return a new event with all changes and refs from both this and the given set. When `refs` is omitted,\n\t * every ref kind in `changes` counts as unnamed. A kind in `changes` is no longer {@link announced}. `config` stays\n\t * {@link configConfined}, to the branches of both, only when each side that changed it was confined, and\n\t * `worktreeHead` keeps {@link movedWorktrees}, those of both, only when each side that changed it named them.\n\t */\n\twith(\n\t\tchanges: RepositoryChange[],\n\t\trefs?: WatcherRefChanges,\n\t\tmovedWorktrees?: Iterable<string>,\n\t): WatcherRepoChangeEvent {\n\t\tconst names = [...this._refs];\n\t\tconst unnamed = [...this._unnamedRefKinds];\n\t\tif (refs == null) {\n\t\t\tunnamed.push(...filter(changes, isRefChangeKind));\n\t\t} else {\n\t\t\tif (refs.names != null) {\n\t\t\t\tnames.push(...refs.names);\n\t\t\t}\n\t\t\tif (refs.unnamed != null) {\n\t\t\t\tunnamed.push(...refs.unnamed);\n\t\t\t}\n\t\t}\n\n\t\tlet configBranches: Set<string> | undefined;\n\t\tconst own = this._changes.has('config') ? this._configBranches : new Set<string>();\n\t\tconst other = changes.includes('config') ? refs?.configBranches : [];\n\t\tif (own != null && other != null) {\n\t\t\tconfigBranches = new Set([...own, ...other]);\n\t\t}\n\n\t\tlet moved: Set<string> | undefined;\n\t\tconst ownMoved = this._changes.has('worktreeHead') ? this._movedWorktrees : new Set<string>();\n\t\tconst otherMoved = changes.includes('worktreeHead') ? movedWorktrees : [];\n\t\tif (ownMoved != null && otherMoved != null) {\n\t\t\tmoved = new Set([...ownMoved, ...otherMoved]);\n\t\t}\n\n\t\treturn new WatcherRepoChangeEvent(\n\t\t\tthis.repoPath,\n\t\t\t[...this._changes, ...changes],\n\t\t\t{ names: names, unnamed: unnamed, configBranches: configBranches },\n\t\t\tfilter(this._announced, c => !changes.includes(c)),\n\t\t\tmoved,\n\t\t);\n\t}\n}\n\n/**\n * Returns the name in `names` that covers `ref` — `ref` itself, or a ref directory above it (compared on `/`\n * boundaries, so `refs/heads/fe` doesn't cover `refs/heads/feature`) — or `undefined` if none does.\n */\nexport function findCoveringRefName(names: ReadonlySet<string>, ref: string): string | undefined {\n\tif (names.size === 0) return undefined;\n\tif (names.has(ref)) return ref;\n\n\tlet index = ref.lastIndexOf('/');\n\twhile (index > 0) {\n\t\tconst dir = ref.substring(0, index);\n\t\tif (names.has(dir)) return dir;\n\n\t\tindex = ref.lastIndexOf('/', index - 1);\n\t}\n\treturn undefined;\n}\n\n/**\n * An event describing working tree file changes, produced by the working tree pipeline.\n *\n * Paths have already been filtered through the gitignore filter and noise filter.\n */\nexport interface WorkingTreeChangeEvent {\n\treadonly repoPath: string;\n\t/**\n\t * Absolute paths of changed files or directories (post-gitignore filtering). A directory stands for everything\n\t * beneath it. Partial when {@link incomplete}.\n\t */\n\treadonly paths: ReadonlySet<string>;\n\t/**\n\t * `true` when more paths changed than the accumulator retains, so {@link paths} is a partial set and a\n\t * miss does NOT mean the file is unchanged. Consumers testing membership must treat this as a match.\n\t */\n\treadonly incomplete: boolean;\n}\n"],"mappings":";;AAkBA,SAAgB,gBAAgB,QAAmD;CAClF,OAAO,WAAW,WAAW,WAAW,aAAa,WAAW,UAAU,WAAW;AACtF;;;;;;;AAQA,SAAgB,iBAAiB,KAAwC;CACxE,IAAI,CAAC,IAAI,WAAW,OAAO,GAAG,OAAO;CACrC,IAAI,IAAI,WAAW,aAAa,GAAG,OAAO;CAC1C,IAAI,IAAI,WAAW,eAAe,GAAG,OAAO;CAC5C,IAAI,IAAI,WAAW,YAAY,GAAG,OAAO;CACzC,IAAI,QAAQ,cAAc,OAAO;AAGlC;;;;;;;;AASA,IAAa,yBAAb,MAAa,uBAAuB;CAUlB;CATjB;CACA;CACA;CACA;CACA;CACA;CAEA,YAEC,UACA,SAEA,MAEA,WAEA,gBACC;EARe,KAAA,WAAA;EAShB,KAAK,WAAW,IAAI,IAAI,OAAO;EAC/B,IAAI,QAAQ,MAAM;GACjB,KAAK,wBAAQ,IAAI,IAAI;GACrB,KAAK,mBAAmB,IAAI,IAAI,OAAO,SAAS,eAAe,CAAC;EACjE,OAAO;GACN,KAAK,QAAQ,IAAI,IAAI,KAAK,KAAK;GAC/B,KAAK,mBAAmB,IAAI,IAAI,KAAK,OAAO;EAC7C;EACA,KAAK,kBACJ,MAAM,kBAAkB,QAAQ,KAAK,SAAS,IAAI,QAAQ,IAAI,IAAI,IAAI,KAAK,cAAc,IAAI,KAAA;EAC9F,KAAK,aAAa,aAAa,OAAO,IAAI,IAAI,OAAO,YAAW,MAAK,KAAK,SAAS,IAAI,CAAC,CAAC,CAAC,oBAAI,IAAI,IAAI;EACtG,KAAK,kBACJ,kBAAkB,QAAQ,KAAK,SAAS,IAAI,cAAc,IAAI,IAAI,IAAI,cAAc,IAAI,KAAA;CAC1F;CAEA,IAAI,UAAyC;EAC5C,OAAO,KAAK;CACb;;;;;;CAOA,IAAI,YAA2C;EAC9C,OAAO,K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kCAAkB,IAAI,IAAY;EAC5F,MAAM,aAAa,QAAQ,SAAS,cAAc,IAAI,iBAAiB,CAAC;EACxE,IAAI,YAAY,QAAQ,cAAc,MACrC,wBAAQ,IAAI,IAAI,CAAC,GAAG,UAAU,GAAG,UAAU,CAAC;EAG7C,OAAO,IAAI,uBACV,KAAK,UACL,CAAC,GAAG,KAAK,UAAU,GAAG,OAAO,GAC7B;GAAS;GAAgB;GAAyB;EAAe,GACjE,OAAO,KAAK,aAAY,MAAK,CAAC,QAAQ,SAAS,CAAC,CAAC,GACjD,KACD;CACD;AACD;;;;;AAMA,SAAgB,oBAAoB,OAA4B,KAAiC;CAChG,IAAI,MAAM,SAAS,GAAG,OAAO,KAAA;CAC7B,IAAI,MAAM,IAAI,GAAG,GAAG,OAAO;CAE3B,IAAI,QAAQ,IAAI,YAAY,GAAG;CAC/B,OAAO,QAAQ,GAAG;EACjB,MAAM,MAAM,IAAI,UAAU,GAAG,KAAK;EAClC,IAAI,MAAM,IAAI,GAAG,GAAG,OAAO;EAE3B,QAAQ,IAAI,YAAY,KAAK,QAAQ,CAAC;CACvC;AAED"}
1
+ {"version":3,"file":"changeEvent.js","names":[],"sources":["../../../../git/src/watching/changeEvent.ts"],"sourcesContent":["import { filter, some } from '@gitlens/utils/iterable.js';\nimport type { RepositoryChange } from '../models/repository.js';\n\n/** The {@link RepositoryChange} kinds that describe ref movement, which an event can attribute to named refs */\nexport type RefChangeKind = 'heads' | 'remotes' | 'tags' | 'stash';\n\nexport interface WatcherRefChanges {\n\t/** Full ref names whose files changed (`refs/heads/main`), plus per-worktree pseudo-refs (`HEAD`, `ORIG_HEAD`). A name may be a ref directory and then covers every ref beneath it. */\n\treadonly names?: Iterable<string>;\n\t/** Ref kinds that changed without a name (packed-refs rewrite, a ref namespace directory like `refs/remotes`, shallow/replace, an injected change): any ref of that kind may have moved. */\n\treadonly unnamed?: Iterable<RefChangeKind>;\n\t/**\n\t * The local branches (full `refs/heads/` names) whose `branch.<name>` sections are all that every `config` change\n\t * among the changes touched in `.git/config`. Omitted when any of them may have changed anything else.\n\t */\n\treadonly configBranches?: Iterable<string>;\n}\n\nexport function isRefChangeKind(change: RepositoryChange): change is RefChangeKind {\n\treturn change === 'heads' || change === 'remotes' || change === 'tags' || change === 'stash';\n}\n\n/**\n * The kind of ref a full ref name (or ref directory) belongs to. A pseudo-ref (no `refs/` prefix, e.g. `HEAD`,\n * `ORIG_HEAD`) counts as `heads`; a ref outside the watched namespaces (e.g. `refs/notes/x`) has no kind, and neither\n * has a namespace directory itself (`refs/remotes`), so a change reported for one names no ref: any ref of the kind it\n * holds may have moved.\n */\nexport function getRefChangeKind(ref: string): RefChangeKind | undefined {\n\tif (!ref.startsWith('refs/')) return 'heads';\n\tif (ref.startsWith('refs/heads/')) return 'heads';\n\tif (ref.startsWith('refs/remotes/')) return 'remotes';\n\tif (ref.startsWith('refs/tags/')) return 'tags';\n\tif (ref === 'refs/stash') return 'stash';\n\n\treturn undefined;\n}\n\n/**\n * An event describing changes to a repository, produced by the watching pipeline.\n *\n * Changes are coalesced within a debounce window — a single event may represent\n * multiple filesystem changes. Use {@link changed} to test for specific change types,\n * and {@link mayHaveChangedRef} to test whether a specific ref may have moved.\n */\nexport class WatcherRepoChangeEvent {\n\tprotected readonly _changes: Set<RepositoryChange>;\n\tprivate readonly _refs: Set<string>;\n\tprivate readonly _unnamedRefKinds: Set<RefChangeKind>;\n\tprivate readonly _announced: Set<RepositoryChange>;\n\tprivate readonly _configBranches: Set<string> | undefined;\n\tprivate readonly _movedWorktrees: Set<string> | undefined;\n\tprivate readonly _observedAt: number | undefined;\n\n\tconstructor(\n\t\t/** The repository path this event is for */\n\t\tpublic readonly repoPath: string,\n\t\tchanges: RepositoryChange[],\n\t\t/** Which refs changed; when omitted, every ref kind in `changes` is unnamed (any ref of that kind may have moved) */\n\t\trefs?: WatcherRefChanges,\n\t\t/** The kinds of `changes` that come only from core's own announced writes (see {@link announced}) */\n\t\tannounced?: Iterable<RepositoryChange>,\n\t\t/** For a `worktreeHead` among `changes`, the worktrees moved outside core's writes (see {@link movedWorktrees}) */\n\t\tmovedWorktrees?: Iterable<string>,\n\t\t/** When the newest of `changes` was observed (see {@link observedAt}) */\n\t\tobservedAt?: number,\n\t) {\n\t\tthis._changes = new Set(changes);\n\t\tif (refs == null) {\n\t\t\tthis._refs = new Set();\n\t\t\tthis._unnamedRefKinds = new Set(filter(changes, isRefChangeKind));\n\t\t} else {\n\t\t\tthis._refs = new Set(refs.names);\n\t\t\tthis._unnamedRefKinds = new Set(refs.unnamed);\n\t\t}\n\t\tthis._configBranches =\n\t\t\trefs?.configBranches != null && this._changes.has('config') ? new Set(refs.configBranches) : undefined;\n\t\tthis._announced = announced != null ? new Set(filter(announced, c => this._changes.has(c))) : new Set();\n\t\tthis._movedWorktrees =\n\t\t\tmovedWorktrees != null && this._changes.has('worktreeHead') ? new Set(movedWorktrees) : undefined;\n\t\tthis._observedAt = observedAt;\n\t}\n\n\tget changes(): ReadonlySet<RepositoryChange> {\n\t\treturn this._changes;\n\t}\n\n\t/**\n\t * The kinds in {@link changes} that come only from core's own writes, which core already announced through\n\t * `hooks.repository.onChanged` after evicting their caches. A host that handled that announcement can skip them;\n\t * a kind the watcher or an injected change also reported is not among them.\n\t */\n\tget announced(): ReadonlySet<RepositoryChange> {\n\t\treturn this._announced;\n\t}\n\n\t/** The kinds in {@link changes} that aren't {@link announced}: what a cache that core already evicted for its write still has to clear */\n\tgetUnannouncedChanges(): RepositoryChange[] {\n\t\treturn this._announced.size ? [...filter(this._changes, c => !this._announced.has(c))] : [...this._changes];\n\t}\n\n\t/** Full ref names (or ref directories, or pseudo-refs) known to have changed. See {@link WatcherRefChanges.names}. */\n\tget refs(): ReadonlySet<string> {\n\t\treturn this._refs;\n\t}\n\n\t/** Ref kinds that changed without a name — any ref of these kinds may have moved */\n\tget unnamedRefKinds(): ReadonlySet<RefChangeKind> {\n\t\treturn this._unnamedRefKinds;\n\t}\n\n\t/**\n\t * The local branches (full `refs/heads/` names) whose `branch.<name>` sections are the only part of `.git/config`\n\t * that changed; `undefined` when `config` didn't change, or any config change may be elsewhere. Independent of\n\t * {@link refs}: an outside edit to a branch's tracking moves no ref.\n\t */\n\tget configBranches(): ReadonlySet<string> | undefined {\n\t\treturn this._configBranches;\n\t}\n\n\t/**\n\t * The admin ids (the `<id>` of `.git/worktrees/<id>`) of the linked worktrees whose HEAD moved other than by core's\n\t * announced writes, which are all that an unannounced `worktreeHead` reports; `undefined` when `worktreeHead` didn't\n\t * change, or any linked worktree's HEAD may have moved.\n\t */\n\tget movedWorktrees(): ReadonlySet<string> | undefined {\n\t\treturn this._movedWorktrees;\n\t}\n\n\t/**\n\t * The change ordinal (see `nextChangeOrdinal`) taken when the watch session received the newest report among\n\t * {@link changes}, each of which was on disk by then; `undefined` when that isn't known, as for a change injected by\n\t * a caller. A cache can keep what it evicted whole after this, since that was read after every change here.\n\t */\n\tget observedAt(): number | undefined {\n\t\treturn this._observedAt;\n\t}\n\n\t/** Whether `config` changed only in the sections of {@link configBranches} */\n\tget configConfined(): boolean {\n\t\treturn this._configBranches != null;\n\t}\n\n\t/**\n\t * Test whether `config` may have changed in a way that concerns a subscriber following `relevantRefs`.\n\t *\n\t * A branch's config section matters only to a checkout on that branch or one whose upstream or base is that branch,\n\t * and those follow `refs/heads/<name>` (or `HEAD`, which may be on any branch). So a {@link configConfined} change\n\t * concerns `relevantRefs` only when one of them is `HEAD` or one of {@link configBranches}; any other config change\n\t * concerns everyone.\n\t */\n\tmayHaveChangedConfig(relevantRefs: Iterable<string>): boolean {\n\t\tif (!this._changes.has('config')) return false;\n\t\tif (this._configBranches == null) return true;\n\n\t\tfor (const ref of relevantRefs) {\n\t\t\tif (ref === 'HEAD' || this._configBranches.has(ref)) return true;\n\t\t}\n\t\treturn false;\n\t}\n\n\ttoString(changesOnly: boolean = false): string {\n\t\tconst changeList = [...this._changes].join(', ');\n\t\tconst refCount = this._refs.size;\n\t\tif (changesOnly) return refCount ? `changes=${changeList}, refs=${refCount}` : `changes=${changeList}`;\n\n\t\treturn refCount\n\t\t\t? `{ repoPath: ${this.repoPath}, changes: ${changeList}, refs: ${refCount} }`\n\t\t\t: `{ repoPath: ${this.repoPath}, changes: ${changeList} }`;\n\t}\n\n\t/**\n\t * Test whether the given ref may have moved in this event.\n\t *\n\t * @param ref - A full ref name (`refs/heads/main`) or a pseudo-ref (`HEAD`).\n\t * @returns `false` when the ref's kind didn't change (or the ref is outside the watched kinds); `true` when its kind\n\t * changed without a name, or when the ref itself or a ref directory above it changed. `HEAD` is usually a symref\n\t * to the checked-out branch, so it may have moved whenever any `heads` ref did.\n\t */\n\tmayHaveChangedRef(ref: string): boolean {\n\t\tconst kind = getRefChangeKind(ref);\n\t\tif (kind == null || !this._changes.has(kind)) return false;\n\t\tif (this._unnamedRefKinds.has(kind) || ref === 'HEAD') return true;\n\n\t\treturn findCoveringRefName(this._refs, ref) != null;\n\t}\n\n\t/**\n\t * Test whether any of the specified change types are present in the event.\n\t *\n\t * @param affected - Change types to test for.\n\t * @returns `true` if any of the specified changes are present.\n\t */\n\tchanged(...affected: RepositoryChange[]): boolean {\n\t\treturn some(this._changes, c => affected.includes(c));\n\t}\n\n\t/**\n\t * Test whether the event contains ONLY the specified change types.\n\t *\n\t * `pausedOp` is treated as a union of `cherryPick`, `merge`, `rebase`,\n\t * and `revert` for convenience.\n\t *\n\t * @param affected - Change types to test for.\n\t * @returns `true` if the event contains only the specified changes.\n\t */\n\tchangedExclusive(...affected: RepositoryChange[]): boolean {\n\t\tlet changes = this._changes;\n\n\t\t// When checking for specific paused operation types, also accept the union type\n\t\tif (\n\t\t\taffected.includes('cherryPick') ||\n\t\t\taffected.includes('merge') ||\n\t\t\taffected.includes('rebase') ||\n\t\t\taffected.includes('revert')\n\t\t) {\n\t\t\tif (!affected.includes('pausedOp')) {\n\t\t\t\taffected = [...affected, 'pausedOp'];\n\t\t\t}\n\t\t} else if (affected.includes('pausedOp')) {\n\t\t\t// When checking for the union type exclusively, ignore specific subtypes\n\t\t\tchanges = new Set(changes);\n\t\t\tchanges.delete('cherryPick');\n\t\t\tchanges.delete('merge');\n\t\t\tchanges.delete('rebase');\n\t\t\tchanges.delete('revert');\n\t\t}\n\n\t\tconst intersection = [...filter(changes, c => affected.includes(c))];\n\t\treturn intersection.length === changes.size;\n\t}\n\n\t/**\n\t * Coalesce: return a new event with all changes and refs from both this and the given set. When `refs` is omitted,\n\t * every ref kind in `changes` counts as unnamed. A kind in `changes` is no longer {@link announced}. `config` stays\n\t * {@link configConfined}, to the branches of both, only when each side that changed it was confined, and\n\t * `worktreeHead` keeps {@link movedWorktrees}, those of both, only when each side that changed it named them. The\n\t * result was observed when the newer side was, and isn't known to have been when either side isn't.\n\t */\n\twith(\n\t\tchanges: RepositoryChange[],\n\t\trefs?: WatcherRefChanges,\n\t\tmovedWorktrees?: Iterable<string>,\n\t\tobservedAt?: number,\n\t): WatcherRepoChangeEvent {\n\t\tconst names = [...this._refs];\n\t\tconst unnamed = [...this._unnamedRefKinds];\n\t\tif (refs == null) {\n\t\t\tunnamed.push(...filter(changes, isRefChangeKind));\n\t\t} else {\n\t\t\tif (refs.names != null) {\n\t\t\t\tnames.push(...refs.names);\n\t\t\t}\n\t\t\tif (refs.unnamed != null) {\n\t\t\t\tunnamed.push(...refs.unnamed);\n\t\t\t}\n\t\t}\n\n\t\tlet configBranches: Set<string> | undefined;\n\t\tconst own = this._changes.has('config') ? this._configBranches : new Set<string>();\n\t\tconst other = changes.includes('config') ? refs?.configBranches : [];\n\t\tif (own != null && other != null) {\n\t\t\tconfigBranches = new Set([...own, ...other]);\n\t\t}\n\n\t\tlet moved: Set<string> | undefined;\n\t\tconst ownMoved = this._changes.has('worktreeHead') ? this._movedWorktrees : new Set<string>();\n\t\tconst otherMoved = changes.includes('worktreeHead') ? movedWorktrees : [];\n\t\tif (ownMoved != null && otherMoved != null) {\n\t\t\tmoved = new Set([...ownMoved, ...otherMoved]);\n\t\t}\n\n\t\treturn new WatcherRepoChangeEvent(\n\t\t\tthis.repoPath,\n\t\t\t[...this._changes, ...changes],\n\t\t\t{ names: names, unnamed: unnamed, configBranches: configBranches },\n\t\t\tfilter(this._announced, c => !changes.includes(c)),\n\t\t\tmoved,\n\t\t\tthis._observedAt != null && observedAt != null ? Math.max(this._observedAt, observedAt) : undefined,\n\t\t);\n\t}\n}\n\n/**\n * Returns the name in `names` that covers `ref` — `ref` itself, or a ref directory above it (compared on `/`\n * boundaries, so `refs/heads/fe` doesn't cover `refs/heads/feature`) — or `undefined` if none does.\n */\nexport function findCoveringRefName(names: ReadonlySet<string>, ref: string): string | undefined {\n\tif (names.size === 0) return undefined;\n\tif (names.has(ref)) return ref;\n\n\tlet index = ref.lastIndexOf('/');\n\twhile (index > 0) {\n\t\tconst dir = ref.substring(0, index);\n\t\tif (names.has(dir)) return dir;\n\n\t\tindex = ref.lastIndexOf('/', index - 1);\n\t}\n\treturn undefined;\n}\n\n/**\n * An event describing working tree file changes, produced by the working tree pipeline.\n *\n * Paths have already been filtered through the gitignore filter and noise filter.\n */\nexport interface WorkingTreeChangeEvent {\n\treadonly repoPath: string;\n\t/**\n\t * Absolute paths of changed files or directories (post-gitignore filtering). A directory stands for everything\n\t * beneath it. Partial when {@link incomplete}.\n\t */\n\treadonly paths: ReadonlySet<string>;\n\t/**\n\t * `true` when more paths changed than the accumulator retains, so {@link paths} is a partial set and a\n\t * miss does NOT mean the file is unchanged. Consumers testing membership must treat this as a match.\n\t */\n\treadonly incomplete: boolean;\n}\n"],"mappings":";;AAkBA,SAAgB,gBAAgB,QAAmD;CAClF,OAAO,WAAW,WAAW,WAAW,aAAa,WAAW,UAAU,WAAW;AACtF;;;;;;;AAQA,SAAgB,iBAAiB,KAAwC;CACxE,IAAI,CAAC,IAAI,WAAW,OAAO,GAAG,OAAO;CACrC,IAAI,IAAI,WAAW,aAAa,GAAG,OAAO;CAC1C,IAAI,IAAI,WAAW,eAAe,GAAG,OAAO;CAC5C,IAAI,IAAI,WAAW,YAAY,GAAG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AAY,MAAK,CAAC,QAAQ,SAAS,CAAC,CAAC,GACjD,OACA,KAAK,eAAe,QAAQ,cAAc,OAAO,KAAK,IAAI,KAAK,aAAa,UAAU,IAAI,KAAA,CAC3F;CACD;AACD;;;;;AAMA,SAAgB,oBAAoB,OAA4B,KAAiC;CAChG,IAAI,MAAM,SAAS,GAAG,OAAO,KAAA;CAC7B,IAAI,MAAM,IAAI,GAAG,GAAG,OAAO;CAE3B,IAAI,QAAQ,IAAI,YAAY,GAAG;CAC/B,OAAO,QAAQ,GAAG;EACjB,MAAM,MAAM,IAAI,UAAU,GAAG,KAAK;EAClC,IAAI,MAAM,IAAI,GAAG,GAAG,OAAO;EAE3B,QAAQ,IAAI,YAAY,KAAK,QAAQ,CAAC;CACvC;AAED"}
@@ -0,0 +1,9 @@
1
+ //#region ../git/src/watching/changeOrdinal.d.ts
2
+ /**
3
+ * The next value of a process-wide counter, which orders when a watch session observed a change against when a cache
4
+ * evicted an entry. Each call advances it, so no two calls share a value. A counter rather than a clock, so the order
5
+ * is exact and holds under fake timers
6
+ */
7
+ export declare function nextChangeOrdinal(): number;
8
+ //#endregion
9
+ //# sourceMappingURL=changeOrdinal.d.ts.map
@@ -0,0 +1,14 @@
1
+ //#region ../git/src/watching/changeOrdinal.ts
2
+ let ordinal = 0;
3
+ /**
4
+ * The next value of a process-wide counter, which orders when a watch session observed a change against when a cache
5
+ * evicted an entry. Each call advances it, so no two calls share a value. A counter rather than a clock, so the order
6
+ * is exact and holds under fake timers
7
+ */
8
+ function nextChangeOrdinal() {
9
+ return ++ordinal;
10
+ }
11
+ //#endregion
12
+ export { nextChangeOrdinal };
13
+
14
+ //# sourceMappingURL=changeOrdinal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"changeOrdinal.js","names":[],"sources":["../../../../git/src/watching/changeOrdinal.ts"],"sourcesContent":["let ordinal = 0;\n\n/**\n * The next value of a process-wide counter, which orders when a watch session observed a change against when a cache\n * evicted an entry. Each call advances it, so no two calls share a value. A counter rather than a clock, so the order\n * is exact and holds under fake timers\n */\nexport function nextChangeOrdinal(): number {\n\treturn ++ordinal;\n}\n"],"mappings":";AAAA,IAAI,UAAU;;;;;;AAOd,SAAgB,oBAA4B;CAC3C,OAAO,EAAE;AACV"}
@@ -50,7 +50,8 @@ export interface UnwatchedCacheValidatorOptions {
50
50
  * files a watcher would have reported (see {@link UnwatchedCacheValidatorOptions.stat}) and applies what moved to the
51
51
  * cache as a watcher event would have. Both a worktree's own git dir and the common one are validated while that
52
52
  * worktree is unwatched; while another worktree's watcher covers the common one, what moved there clears only the
53
- * unwatched worktrees' own entries. A repository whose git dir nothing resolved yet is validated once
53
+ * unwatched worktrees' own entries, but for a linked worktree's HEAD moving, which is applied as that worktree's own
54
+ * report would be (see {@link apply}). A repository whose git dir nothing resolved yet is validated once
54
55
  * {@link UnwatchedCacheValidatorOptions.resolveGitDir} resolves one; a repository whose files can't show it is looked at
55
56
  * again rarely, and one whose resolution failed within the validation window. A read waits at most
56
57
  * {@link UnwatchedCacheValidatorOptions.timeoutMs} for a validation (and a resolution before it); one that outlasts it
@@ -79,7 +80,10 @@ export declare class UnwatchedCacheValidator {
79
80
  private readonly resolutions;
80
81
  /** The validation {@link onWatched} ran as a watcher attached, by repo path, which reads wait for while it runs */
81
82
  private readonly handoffs;
82
- /** By the repo path of a watched worktree, what moved in its common git dir that its watcher was left to clear */
83
+ /**
84
+ * By the repo path of a watched worktree, what moved in its common git dir that its watcher was left to clear, and
85
+ * whether its own HEAD's move, which the common git dir saw, was left to it to report (see {@link applyMovedHeads})
86
+ */
83
87
  private readonly deferred;
84
88
  constructor(options: UnwatchedCacheValidatorOptions);
85
89
  /**
@@ -104,8 +108,9 @@ export declare class UnwatchedCacheValidator {
104
108
  onWatched(repoPath: string): void;
105
109
  /**
106
110
  * A watcher left `repoPath`, dropping what it held back unreported. What moved in its common git dir that an
107
- * unwatched sibling's validation left to it is applied now, since that validation took the shared baseline past it;
108
- * whatever else it dropped is still ahead of its own baselines.
111
+ * unwatched sibling's validation left to it is applied now, since that validation took the shared baseline past it,
112
+ * and so is its own HEAD's move that the common git dir saw, as its watcher would have reported it; whatever else it
113
+ * dropped is still ahead of its own baselines.
109
114
  */
110
115
  onUnwatched(repoPath: string): void;
111
116
  private run;
@@ -131,14 +136,42 @@ export declare class UnwatchedCacheValidator {
131
136
  /** The repository's other worktrees whose watchers cover its common git dir */
132
137
  private getCommonWatchers;
133
138
  private getTarget;
139
+ /**
140
+ * The root targets, new, of `repoPath`'s registered sibling worktrees that never had one: unwatched (a watcher covers
141
+ * its own git dir, and validates it as it attaches), with a git dir the cache resolved in the same common git dir
142
+ */
143
+ private getSiblingTargets;
134
144
  private runTargets;
135
145
  /**
136
146
  * Applies what moved to `repoPath`, and what moved in the common git dir to its other unwatched registered worktrees
137
147
  * too, as the common watcher would have told each of them. While another worktree's watcher covers the common git
138
148
  * dir, it already cleared the shared entries, so only the worktrees' own are. A watcher covers it only if it watched
139
- * since before the stats began (`watchedAtStart`)
149
+ * since before the stats began (`watchedAtStart`). What each sibling whose first baseline was taken with it reports
150
+ * clears that sibling's own entries, as `repoPath`'s report cleared the shared ones.
151
+ *
152
+ * Once the common git dir (`commonDir`) holds a reading of a linked worktree's HEAD, it reports that HEAD's every
153
+ * move, and a commit on its branch as a ref directory moving. Each such move clears the shared entries, as that
154
+ * worktree's own report would (see {@link applyMovedHeads}), or is left to its watcher, which reports it or has it
155
+ * applied as it leaves. So nothing the shared entries hold of that worktree can go stale unseen: its first report (or
156
+ * its first after a reset) clears only its own entries, for up to {@link maxOwnBaselines} of them
140
157
  */
141
158
  private apply;
159
+ /** What is left to the watcher of `path` until it leaves (see {@link onUnwatched}) */
160
+ private getDeferred;
161
+ /**
162
+ * The worktrees, of `repoPath` and the `siblings`, whose report without a baseline the common git dir vouches for as
163
+ * of now: each a linked worktree registered under `commonPath` whose HEAD `commonDir` holds a reading of
164
+ */
165
+ private getVouchedBaselines;
166
+ /**
167
+ * Applies the common git dir's sighting of linked worktrees' HEADs moving as each worktree's own report would be:
168
+ * the shared entries hold each one's HEAD too (where the branch list places its branch, what a checkout's reflog
169
+ * says a branch was based on), which a `'worktreeHead'` clears nothing of. One whose own watcher covered the common
170
+ * git dir reports it itself, or, should that watcher leave first, has it applied as it leaves. A move not attributed to a registered worktree is applied to `repoPath`, as is a report
171
+ * without a baseline (whose shared entries a watcher of the common git dir cleared, if not `repoPath`'s report),
172
+ * unless what `repoPath`'s report applied in full saw its own HEAD move (`appliedHead`)
173
+ */
174
+ private applyMovedHeads;
142
175
  }
143
176
  //#endregion
144
177
  //# sourceMappingURL=unwatchedCacheValidator.d.ts.map