@gitkraken/core-gitlens 0.61.1 → 0.62.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -1
- package/dist/git/service.js +6 -0
- package/dist/git/service.js.map +1 -1
- package/dist/git/watching/watchService.d.ts +11 -0
- package/dist/git/watching/watchService.js +122 -30
- package/dist/git/watching/watchService.js.map +1 -1
- package/dist/git/watching/watcherPatterns.d.ts +1 -1
- package/dist/git/watching/watcherPatterns.js +11 -5
- package/dist/git/watching/watcherPatterns.js.map +1 -1
- package/dist/git-cli/cliGitProvider.d.ts +1 -6
- package/dist/git-cli/cliGitProvider.js +59 -14
- package/dist/git-cli/cliGitProvider.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.62.0] - 2026-12-03
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- Preserves working-tree change notifications for tracked files that match Git ignore rules. For Git CLI checkouts, watchers keep these paths observable and confirm ignore matches against the index before filtering events ([#6466](https://github.com/gitkraken/vscode-gitlens/issues/6466)).
|
|
14
|
+
|
|
9
15
|
## [0.61.1] - 2026-12-03
|
|
10
16
|
|
|
11
17
|
### Changed
|
|
@@ -1561,7 +1567,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
|
|
|
1561
1567
|
|
|
1562
1568
|
- Initial release. Bundles `@gitlens/utils`, `@gitlens/git`, `@gitlens/git-cli`, `@gitlens/ai`, and `@gitlens/git-github` into a single core npm package with subpath exports.
|
|
1563
1569
|
|
|
1564
|
-
[unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.
|
|
1570
|
+
[unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.62.0...core
|
|
1571
|
+
[0.62.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.61.1..releases/core/v0.62.0
|
|
1565
1572
|
[0.61.1]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.61.0..releases/core/v0.61.1
|
|
1566
1573
|
[0.61.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.60.1..releases/core/v0.61.0
|
|
1567
1574
|
[0.60.1]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.60.0..releases/core/v0.60.1
|
package/dist/git/service.js
CHANGED
|
@@ -79,6 +79,12 @@ var GitService = class GitService {
|
|
|
79
79
|
getIgnoreFilter: (repoPath, gitDirPath) => {
|
|
80
80
|
return this.getProvider(repoPath)?.provider.getIgnoreFilter?.(repoPath, gitDirPath);
|
|
81
81
|
},
|
|
82
|
+
getIgnorePathChecker: (repoPath) => {
|
|
83
|
+
const provider = this.getProvider(repoPath)?.provider;
|
|
84
|
+
const getIgnoredPaths = provider?.getIgnoredPaths;
|
|
85
|
+
if (getIgnoredPaths == null) return void 0;
|
|
86
|
+
return (paths, cancellation) => getIgnoredPaths.call(provider, repoPath, paths, { priority: "background" }, cancellation);
|
|
87
|
+
},
|
|
82
88
|
getIgnoredDirectories: (repoPath) => this.getProvider(repoPath)?.provider.getIgnoredDirectories?.(repoPath) ?? Promise.resolve([]),
|
|
83
89
|
getGitIgnoreWatchInputs: (repoPath, gitDir, options) => this.getProvider(repoPath)?.provider.getGitIgnoreWatchInputs?.(repoPath, gitDir, options) ?? Promise.resolve(void 0),
|
|
84
90
|
getIgnoredWorktreeRoots: (repoPath) => this.getProvider(repoPath)?.provider.getIgnoredWorktreeRoots?.(repoPath) ?? Promise.resolve([]),
|
package/dist/git/service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","names":[],"sources":["../../../git/src/service.ts"],"sourcesContent":["import type { Disposable, 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.disposables` are disposed with the service.\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\tdisposables?: readonly Disposable[];\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\toptions?.disposables,\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\tprivate readonly _disposables?: readonly Disposable[],\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\tgetGitIgnoreWatchInputs: (repoPath, gitDir, options) =>\n\t\t\t\t\tthis.getProvider(repoPath)?.provider.getGitIgnoreWatchInputs?.(repoPath, gitDir, options) ??\n\t\t\t\t\tPromise.resolve(undefined),\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\n\t\tfor (const disposable of this._disposables ?? []) {\n\t\t\tdisposable.dispose();\n\t\t}\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;CAmElC;CAlElB,OAAe;;;;;;;;;CAUf,OAAO,gBACN,kBACA,SAOa;EACb,IAAI,WAAW,aAAa,MAC3B,MAAM,IAAI,MAAM,0DAA0D;EAG3E,MAAM,WAAW,IAAI,WACpB,kBACA,SAAS,cACT,SAAS,UACT,SAAS,eACT,SAAS,qBACT,SAAS,WACV;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,qBACA,cACC;EADgB,KAAA,eAAA;EAEjB,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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AS,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 { Disposable, 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.disposables` are disposed with the service.\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\tdisposables?: readonly Disposable[];\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\toptions?.disposables,\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\tprivate readonly _disposables?: readonly Disposable[],\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\tgetIgnorePathChecker: repoPath => {\n\t\t\t\t\tconst provider = this.getProvider(repoPath)?.provider;\n\t\t\t\t\tconst getIgnoredPaths = provider?.getIgnoredPaths;\n\t\t\t\t\tif (getIgnoredPaths == null) return undefined;\n\n\t\t\t\t\treturn (paths, cancellation) =>\n\t\t\t\t\t\tgetIgnoredPaths.call(provider, repoPath, paths, { priority: 'background' }, cancellation);\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\tgetGitIgnoreWatchInputs: (repoPath, gitDir, options) =>\n\t\t\t\t\tthis.getProvider(repoPath)?.provider.getGitIgnoreWatchInputs?.(repoPath, gitDir, options) ??\n\t\t\t\t\tPromise.resolve(undefined),\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\n\t\tfor (const disposable of this._disposables ?? []) {\n\t\t\tdisposable.dispose();\n\t\t}\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;CAmElC;CAlElB,OAAe;;;;;;;;;CAUf,OAAO,gBACN,kBACA,SAOa;EACb,IAAI,WAAW,aAAa,MAC3B,MAAM,IAAI,MAAM,0DAA0D;E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";
|
|
|
7
7
|
import { RepositoryWatchSession } from "./watchSession.js";
|
|
8
8
|
import { GitDir, RepositoryChange } from "../models/repository.js";
|
|
9
9
|
//#region ../git/src/watching/watchService.d.ts
|
|
10
|
+
type IgnorePathChecker = (paths: readonly string[], cancellation: AbortSignal) => Promise<ReadonlySet<string>>;
|
|
10
11
|
/**
|
|
11
12
|
* A host whose watchers can report they can't be trusted (see `FileWatcherOptions.onDidChangeReliability`) passes
|
|
12
13
|
* these to have core poll in their place. A `.git` directory is polled by statting the files its watchers read and
|
|
@@ -56,6 +57,11 @@ export interface WatchServiceOptions {
|
|
|
56
57
|
readonly defaultWorkingTreeMaxWaitMs?: number;
|
|
57
58
|
/** Returns a GitIgnoreFilter for a given repo. When absent or returns undefined, gitignore filtering is skipped. */
|
|
58
59
|
readonly getIgnoreFilter?: (repoPath: string, gitDirPath: string) => GitIgnoreFilter | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Confirms rule matches against the checkout's current Git index when processing a batch of events.
|
|
62
|
+
* Providing a checker selects the ordinary watcher with fixed exclusions so these events reach the checker.
|
|
63
|
+
*/
|
|
64
|
+
readonly getIgnorePathChecker?: (repoPath: string) => IgnorePathChecker | undefined;
|
|
59
65
|
/**
|
|
60
66
|
* Returns repo-relative ignored directories for legacy native exclude pruning (`supportsExcludes`).
|
|
61
67
|
* A rejection keeps the existing excludes.
|
|
@@ -162,6 +168,7 @@ export declare class RepositoryWatchService implements UnifiedDisposable {
|
|
|
162
168
|
private readonly defaultRepoMaxWaitMs?;
|
|
163
169
|
private readonly defaultWorkingTreeMaxWaitMs?;
|
|
164
170
|
private readonly getIgnoreFilter?;
|
|
171
|
+
private readonly getIgnorePathChecker?;
|
|
165
172
|
private readonly getIgnoredDirectories?;
|
|
166
173
|
private readonly getGitIgnoreWatchInputs?;
|
|
167
174
|
private readonly getIgnoredWorktreeRoots?;
|
|
@@ -246,6 +253,10 @@ export declare class RepositoryWatchService implements UnifiedDisposable {
|
|
|
246
253
|
private computeWatchMode;
|
|
247
254
|
private updateWatchMode;
|
|
248
255
|
private startWorkingTreeWatcher;
|
|
256
|
+
private shouldDeliverWorkingTreePath;
|
|
257
|
+
private invalidateIgnoreCheck;
|
|
258
|
+
private scheduleIgnoreCheck;
|
|
259
|
+
private flushIgnoreCheck;
|
|
249
260
|
private stopWorkingTreeWatcher;
|
|
250
261
|
private createWorkingTreeWatcher;
|
|
251
262
|
private reconcileWorkingTreeLifecycle;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Emitter } from "../../utils/event.js";
|
|
2
|
+
import { isLinux, isWindows } from "../../utils/platform.js";
|
|
2
3
|
import { getRepositoryKey } from "../../utils/uri.js";
|
|
3
4
|
import { isDescendant, relative } from "../../utils/path.js";
|
|
4
5
|
import { GitDirPoller } from "./gitDirPoller.js";
|
|
@@ -12,6 +13,8 @@ import { RepositoryWatchSession } from "./watchSession.js";
|
|
|
12
13
|
* tighter bound here would mark batches incomplete when they filter down to almost nothing.
|
|
13
14
|
*/
|
|
14
15
|
const maxBufferedWorkingTreePaths = 5e3;
|
|
16
|
+
const maxIgnoreCheckPaths = 1e3;
|
|
17
|
+
const ignoreCheckDelayMs = 100;
|
|
15
18
|
const ignorePruningRefreshDelayMs = 500;
|
|
16
19
|
/**
|
|
17
20
|
* Global service that multiplexes repository watching across all repos.
|
|
@@ -70,6 +73,7 @@ var RepositoryWatchService = class {
|
|
|
70
73
|
defaultRepoMaxWaitMs;
|
|
71
74
|
defaultWorkingTreeMaxWaitMs;
|
|
72
75
|
getIgnoreFilter;
|
|
76
|
+
getIgnorePathChecker;
|
|
73
77
|
getIgnoredDirectories;
|
|
74
78
|
getGitIgnoreWatchInputs;
|
|
75
79
|
getIgnoredWorktreeRoots;
|
|
@@ -96,6 +100,7 @@ var RepositoryWatchService = class {
|
|
|
96
100
|
this.defaultRepoMaxWaitMs = options.defaultRepoMaxWaitMs;
|
|
97
101
|
this.defaultWorkingTreeMaxWaitMs = options.defaultWorkingTreeMaxWaitMs;
|
|
98
102
|
this.getIgnoreFilter = options.getIgnoreFilter;
|
|
103
|
+
this.getIgnorePathChecker = options.getIgnorePathChecker;
|
|
99
104
|
this.getIgnoredDirectories = options.getIgnoredDirectories;
|
|
100
105
|
this.getGitIgnoreWatchInputs = options.getGitIgnoreWatchInputs;
|
|
101
106
|
this.getIgnoredWorktreeRoots = options.getIgnoredWorktreeRoots;
|
|
@@ -220,7 +225,10 @@ var RepositoryWatchService = class {
|
|
|
220
225
|
*/
|
|
221
226
|
noteSelfWrite(repoPath, changes, refs, options) {
|
|
222
227
|
if (this._disposed) return;
|
|
223
|
-
|
|
228
|
+
const key = getRepositoryKey(repoPath);
|
|
229
|
+
const entry = this.wtWatchers.get(key);
|
|
230
|
+
if (entry?.ignoreCheck != null && (changes.length === 0 || changes.some((change) => change === "index" || change === "head" || change === "config" || change === "ignores" || change === "unknown"))) this.invalidateIgnoreCheck(entry);
|
|
231
|
+
this.sessionMap.get(key)?.session.noteSelfWrite(changes, refs, options);
|
|
224
232
|
}
|
|
225
233
|
/**
|
|
226
234
|
* Whether `repoPath`'s `.git` directory is watched: its session has a repo subscriber, so it is connected to its
|
|
@@ -268,6 +276,7 @@ var RepositoryWatchService = class {
|
|
|
268
276
|
suspendAll() {
|
|
269
277
|
this._suspended = true;
|
|
270
278
|
for (const record of this.sessionMap.values()) record.session.suspend();
|
|
279
|
+
for (const entry of this.wtWatchers.values()) this.invalidateIgnoreCheck(entry);
|
|
271
280
|
this.poller?.suspend();
|
|
272
281
|
}
|
|
273
282
|
/** Resume all sessions (clearing the global suspend state), with optional per-session delay */
|
|
@@ -276,10 +285,10 @@ var RepositoryWatchService = class {
|
|
|
276
285
|
for (const record of this.sessionMap.values()) {
|
|
277
286
|
const delayMs = getDelay?.(record.session);
|
|
278
287
|
record.session.resume(delayMs);
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
288
|
+
const entry = this.wtWatchers.get(record.session.repoPath);
|
|
289
|
+
if (entry == null) continue;
|
|
290
|
+
if (this.poller == null && entry.watcher == null) this.placeFallbackWorkingTreeWatcher(entry);
|
|
291
|
+
if (entry.ignoreCheck != null) this.scheduleIgnoreCheck(entry, entry.ignoreCheck);
|
|
283
292
|
}
|
|
284
293
|
this.poller?.resume();
|
|
285
294
|
}
|
|
@@ -305,9 +314,11 @@ var RepositoryWatchService = class {
|
|
|
305
314
|
const group = this.getOrCreateWatchGroup(commonGitDir, session.repoPath);
|
|
306
315
|
const hooks = {
|
|
307
316
|
onRepoChanged: (_repoPath, changes, ref, overflow, configBranches, movedWorktree) => {
|
|
317
|
+
const entry = this.wtWatchers.get(session.repoPath);
|
|
318
|
+
const indexMayHaveChanged = overflow || changes.includes("index") || changes.includes("head");
|
|
319
|
+
if (entry != null && (indexMayHaveChanged || changes.includes("config"))) this.invalidateIgnoreCheck(entry);
|
|
308
320
|
if (overflow) {
|
|
309
321
|
session.pushUnfencedRepoChanges(changes);
|
|
310
|
-
const entry = this.wtWatchers.get(session.repoPath);
|
|
311
322
|
if (entry?.delegation != null) this.scheduleIgnorePruningRefresh(entry, "recovery");
|
|
312
323
|
} else session.pushRepoChanges(changes, ref, configBranches, movedWorktree);
|
|
313
324
|
if (this.poller != null && (changes.includes("index") || changes.includes("head")) && this.wtWatchers.get(session.repoPath)?.reliability === "unwatchable") session.pushWorkingTreeChanges([], true);
|
|
@@ -388,6 +399,15 @@ var RepositoryWatchService = class {
|
|
|
388
399
|
let filterReady = filter == null;
|
|
389
400
|
let buffered = filter != null ? [] : void 0;
|
|
390
401
|
let bufferIncomplete = false;
|
|
402
|
+
const rootPrefix = repoPath.endsWith("/") ? repoPath : `${repoPath}/`;
|
|
403
|
+
const getRelativeEventPath = (path) => {
|
|
404
|
+
if (!isWindows && path.startsWith("/") && repoPath.startsWith("/")) {
|
|
405
|
+
const prefix = path.slice(0, rootPrefix.length);
|
|
406
|
+
if (prefix !== rootPrefix && (isLinux || prefix.toLowerCase() !== rootPrefix.toLowerCase())) return;
|
|
407
|
+
return path.slice(prefix.length);
|
|
408
|
+
}
|
|
409
|
+
return isDescendant(path, repoPath) ? relative(repoPath, path) : void 0;
|
|
410
|
+
};
|
|
391
411
|
const revalidated = filter?.revalidate();
|
|
392
412
|
if (filter != null) {
|
|
393
413
|
const replay = () => {
|
|
@@ -396,15 +416,22 @@ var RepositoryWatchService = class {
|
|
|
396
416
|
filterReady = true;
|
|
397
417
|
buffered = void 0;
|
|
398
418
|
bufferIncomplete = false;
|
|
399
|
-
if (
|
|
400
|
-
const
|
|
401
|
-
|
|
419
|
+
if (entry == null || this.wtWatchers.get(repoPath) !== entry) return;
|
|
420
|
+
const deliver = [];
|
|
421
|
+
for (const event of pending ?? []) {
|
|
422
|
+
const relativePath = getRelativeEventPath(event.path);
|
|
423
|
+
if (relativePath != null && this.shouldDeliverWorkingTreePath(entry, event.path, relativePath, event.reason === "delete")) deliver.push(event.path);
|
|
424
|
+
}
|
|
425
|
+
if (deliver.length || incomplete) session.pushWorkingTreeChanges(deliver, incomplete);
|
|
402
426
|
};
|
|
403
427
|
filter.ready().then(replay, replay).catch(() => {});
|
|
404
428
|
}
|
|
405
429
|
const onIgnoreRulesChanged = (refreshFilter, reason = "worktree") => {
|
|
406
430
|
if (refreshFilter && filter != null) filter.refresh();
|
|
407
|
-
if (entry != null)
|
|
431
|
+
if (entry != null) {
|
|
432
|
+
this.invalidateIgnoreCheck(entry);
|
|
433
|
+
this.scheduleIgnorePruningRefresh(entry, reason);
|
|
434
|
+
}
|
|
408
435
|
for (const h of watchHooks) h.onGitIgnoreChanged?.(repoPath);
|
|
409
436
|
session.pushUnfencedRepoChanges(["ignores"]);
|
|
410
437
|
};
|
|
@@ -417,7 +444,7 @@ var RepositoryWatchService = class {
|
|
|
417
444
|
return;
|
|
418
445
|
}
|
|
419
446
|
if (isNoise(event.path)) return;
|
|
420
|
-
const relativePath =
|
|
447
|
+
const relativePath = getRelativeEventPath(event.path);
|
|
421
448
|
if (relativePath === ".gitignore") {
|
|
422
449
|
onIgnoreRulesChanged(true);
|
|
423
450
|
return;
|
|
@@ -429,18 +456,21 @@ var RepositoryWatchService = class {
|
|
|
429
456
|
bufferIncomplete = true;
|
|
430
457
|
return;
|
|
431
458
|
}
|
|
432
|
-
buffered?.push(event
|
|
459
|
+
buffered?.push(event);
|
|
433
460
|
return;
|
|
434
461
|
}
|
|
435
|
-
if (
|
|
436
|
-
|
|
437
|
-
return;
|
|
438
|
-
}
|
|
439
|
-
session.pushWorkingTreeChanges([event.path]);
|
|
462
|
+
if (entry != null && this.wtWatchers.get(repoPath) !== entry) return;
|
|
463
|
+
if (entry == null || this.shouldDeliverWorkingTreePath(entry, event.path, relativePath, event.reason === "delete")) session.pushWorkingTreeChanges([event.path]);
|
|
440
464
|
};
|
|
441
|
-
const
|
|
442
|
-
const
|
|
465
|
+
const check = this.getIgnorePathChecker?.(repoPath);
|
|
466
|
+
const kept = check == null && canPrune && filter != null ? this.keptIgnoredDirectories.get(filter) : void 0;
|
|
467
|
+
const created = this.createWorkingTreeWatcher(repoPath, onEvent, kept != null ? [...workingTreeExcludes, ...kept] : workingTreeExcludes, check == null && this.getGitIgnoreWatchInputs != null && this.isConnected(record));
|
|
443
468
|
entry = {
|
|
469
|
+
ignoreCheck: check && {
|
|
470
|
+
check,
|
|
471
|
+
paths: /* @__PURE__ */ new Map(),
|
|
472
|
+
incomplete: false
|
|
473
|
+
},
|
|
444
474
|
session,
|
|
445
475
|
onEvent,
|
|
446
476
|
filter,
|
|
@@ -466,10 +496,80 @@ var RepositoryWatchService = class {
|
|
|
466
496
|
if (this.wtWatchers.get(repoPath) === entry) onIgnoreRulesChanged(true);
|
|
467
497
|
});
|
|
468
498
|
}
|
|
499
|
+
shouldDeliverWorkingTreePath(entry, path, relativePath, deleted = false) {
|
|
500
|
+
const filter = entry.filter;
|
|
501
|
+
if (relativePath == null || filter == null) return true;
|
|
502
|
+
const batch = entry.ignoreCheck;
|
|
503
|
+
if (!filter.isIgnored(relativePath) && !(batch != null && filter.isIgnored(`${relativePath}/`))) return true;
|
|
504
|
+
if (batch == null) {
|
|
505
|
+
if (entry.delegation == null && this.canPruneIgnoredDirectories()) this.onIgnoredEvent(entry, filter, relativePath);
|
|
506
|
+
return false;
|
|
507
|
+
}
|
|
508
|
+
if (batch.incomplete) return false;
|
|
509
|
+
const previous = batch.paths.get(path);
|
|
510
|
+
if (this._suspended || batch.paths.size >= maxIgnoreCheckPaths && previous == null) {
|
|
511
|
+
batch.paths.clear();
|
|
512
|
+
batch.incomplete = true;
|
|
513
|
+
} else batch.paths.set(path, {
|
|
514
|
+
relativePath,
|
|
515
|
+
deleted: deleted || previous?.deleted === true
|
|
516
|
+
});
|
|
517
|
+
this.scheduleIgnoreCheck(entry, batch);
|
|
518
|
+
return false;
|
|
519
|
+
}
|
|
520
|
+
invalidateIgnoreCheck(entry) {
|
|
521
|
+
const batch = entry.ignoreCheck;
|
|
522
|
+
if (batch == null) return;
|
|
523
|
+
if (batch.controller != null || batch.paths.size) {
|
|
524
|
+
clearTimeout(batch.timer);
|
|
525
|
+
batch.timer = void 0;
|
|
526
|
+
batch.controller?.abort();
|
|
527
|
+
batch.controller = void 0;
|
|
528
|
+
batch.paths.clear();
|
|
529
|
+
batch.incomplete = true;
|
|
530
|
+
}
|
|
531
|
+
this.scheduleIgnoreCheck(entry, batch);
|
|
532
|
+
}
|
|
533
|
+
scheduleIgnoreCheck(entry, batch) {
|
|
534
|
+
if (this._suspended || batch.controller != null || batch.timer != null || !batch.paths.size && !batch.incomplete) return;
|
|
535
|
+
batch.timer = setTimeout(() => {
|
|
536
|
+
batch.timer = void 0;
|
|
537
|
+
this.flushIgnoreCheck(entry, batch);
|
|
538
|
+
}, ignoreCheckDelayMs);
|
|
539
|
+
}
|
|
540
|
+
async flushIgnoreCheck(entry, batch) {
|
|
541
|
+
if (batch.incomplete) {
|
|
542
|
+
batch.incomplete = false;
|
|
543
|
+
entry.session.pushWorkingTreeChanges([], true);
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
const paths = batch.paths;
|
|
547
|
+
const generation = entry.generation;
|
|
548
|
+
batch.paths = /* @__PURE__ */ new Map();
|
|
549
|
+
const controller = new AbortController();
|
|
550
|
+
batch.controller = controller;
|
|
551
|
+
let ignored;
|
|
552
|
+
try {
|
|
553
|
+
ignored = await batch.check(Array.from(paths.values(), (item) => item.relativePath), controller.signal);
|
|
554
|
+
} catch {}
|
|
555
|
+
if (this.wtWatchers.get(entry.session.repoPath) !== entry || batch.controller !== controller) return;
|
|
556
|
+
batch.controller = void 0;
|
|
557
|
+
if (ignored == null || generation !== entry.generation) entry.session.pushWorkingTreeChanges([], true);
|
|
558
|
+
else {
|
|
559
|
+
const delivered = [];
|
|
560
|
+
let ignoredDeletion = false;
|
|
561
|
+
for (const [path, { relativePath, deleted }] of paths) if (!ignored.has(relativePath)) delivered.push(path);
|
|
562
|
+
else ignoredDeletion ||= deleted;
|
|
563
|
+
if (delivered.length || ignoredDeletion) entry.session.pushWorkingTreeChanges(delivered, ignoredDeletion);
|
|
564
|
+
}
|
|
565
|
+
this.scheduleIgnoreCheck(entry, batch);
|
|
566
|
+
}
|
|
469
567
|
stopWorkingTreeWatcher(repoPath) {
|
|
470
568
|
const entry = this.wtWatchers.get(repoPath);
|
|
471
569
|
if (entry == null) return;
|
|
472
570
|
entry.generation++;
|
|
571
|
+
clearTimeout(entry.ignoreCheck?.timer);
|
|
572
|
+
entry.ignoreCheck?.controller?.abort();
|
|
473
573
|
clearTimeout(entry.refreshTimer);
|
|
474
574
|
entry.refreshTimer = void 0;
|
|
475
575
|
this.wtWatchers.delete(repoPath);
|
|
@@ -628,7 +728,7 @@ var RepositoryWatchService = class {
|
|
|
628
728
|
}
|
|
629
729
|
scheduleIgnorePruningRefresh(entry, reason) {
|
|
630
730
|
if (entry.filter != null) this.keptIgnoredDirectories.delete(entry.filter);
|
|
631
|
-
if (entry.delegation == null && !this.canPruneIgnoredDirectories()) return;
|
|
731
|
+
if (entry.delegation == null && (entry.ignoreCheck != null || !this.canPruneIgnoredDirectories())) return;
|
|
632
732
|
const delegation = entry.delegation;
|
|
633
733
|
if (delegation != null) {
|
|
634
734
|
if (entry.starting) delegation.verified = false;
|
|
@@ -654,7 +754,7 @@ var RepositoryWatchService = class {
|
|
|
654
754
|
if (!delegation.refreshing && (!delegation.initialApplied || entry.reliability !== "unwatchable")) this.refreshDelegatedIgnores(entry, delegation);
|
|
655
755
|
return;
|
|
656
756
|
}
|
|
657
|
-
if (entry.watcher == null || !this.canPruneIgnoredDirectories()) return;
|
|
757
|
+
if (entry.watcher == null || entry.ignoreCheck != null || !this.canPruneIgnoredDirectories()) return;
|
|
658
758
|
if (entry.reading) {
|
|
659
759
|
entry.rereadQueued = true;
|
|
660
760
|
return;
|
|
@@ -791,6 +891,7 @@ var RepositoryWatchService = class {
|
|
|
791
891
|
refreshWorkingTreeFilter(repoPath, reason = "metadata") {
|
|
792
892
|
const entry = this.wtWatchers.get(repoPath);
|
|
793
893
|
if (entry == null) return;
|
|
894
|
+
this.invalidateIgnoreCheck(entry);
|
|
794
895
|
if (entry.filter != null) entry.filter.refresh();
|
|
795
896
|
this.scheduleIgnorePruningRefresh(entry, reason);
|
|
796
897
|
}
|
|
@@ -801,15 +902,6 @@ var RepositoryWatchService = class {
|
|
|
801
902
|
record.session.dispose();
|
|
802
903
|
}
|
|
803
904
|
};
|
|
804
|
-
function filterWorkingTreePaths(absolutePaths, repoPath, filter) {
|
|
805
|
-
const result = [];
|
|
806
|
-
for (const p of absolutePaths) {
|
|
807
|
-
if (!isDescendant(p, repoPath)) continue;
|
|
808
|
-
const relativePath = relative(repoPath, p);
|
|
809
|
-
if (!filter.isIgnored(relativePath)) result.push(p);
|
|
810
|
-
}
|
|
811
|
-
return result;
|
|
812
|
-
}
|
|
813
905
|
//#endregion
|
|
814
906
|
export { RepositoryWatchService };
|
|
815
907
|
|