@gitkraken/core-gitlens 0.62.0 → 0.63.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 +15 -1
- package/dist/git/cache.d.ts +1 -0
- package/dist/git/cache.js +11 -0
- package/dist/git/cache.js.map +1 -1
- package/dist/git/errors.d.ts +15 -0
- package/dist/git/errors.js +9 -1
- package/dist/git/errors.js.map +1 -1
- package/dist/git/models/pullRequest.d.ts +3 -0
- package/dist/git/models/pullRequest.js.map +1 -1
- package/dist/git/providers/operations.d.ts +4 -3
- package/dist/git/providers/staging.d.ts +16 -8
- package/dist/git/run.types.d.ts +6 -0
- package/dist/git/utils/hiddenRefs.utils.d.ts +15 -0
- package/dist/git/utils/hiddenRefs.utils.js +68 -2
- package/dist/git/utils/hiddenRefs.utils.js.map +1 -1
- package/dist/git/utils/pullRequest.utils.d.ts +3 -6
- package/dist/git/utils/pullRequest.utils.js +6 -7
- package/dist/git/utils/pullRequest.utils.js.map +1 -1
- package/dist/git/watching/gitIgnoreFilter.d.ts +12 -5
- package/dist/git/watching/gitIgnoreFilter.js +26 -32
- package/dist/git/watching/gitIgnoreFilter.js.map +1 -1
- package/dist/git/watching/provider.d.ts +18 -3
- package/dist/git/watching/watchGroup.d.ts +7 -2
- package/dist/git/watching/watchGroup.js +51 -3
- package/dist/git/watching/watchGroup.js.map +1 -1
- package/dist/git/watching/watchService.d.ts +6 -3
- package/dist/git/watching/watchService.js +94 -64
- package/dist/git/watching/watchService.js.map +1 -1
- package/dist/git-cli/cliGitProvider.d.ts +2 -0
- package/dist/git-cli/cliGitProvider.js +85 -24
- package/dist/git-cli/cliGitProvider.js.map +1 -1
- package/dist/git-cli/exec/git.js +4 -4
- package/dist/git-cli/exec/git.js.map +1 -1
- package/dist/git-cli/exec/indexLock.d.ts +7 -5
- package/dist/git-cli/exec/indexLock.js +19 -15
- package/dist/git-cli/exec/indexLock.js.map +1 -1
- package/dist/git-cli/providers/config.d.ts +1 -0
- package/dist/git-cli/providers/config.js +15 -5
- package/dist/git-cli/providers/config.js.map +1 -1
- package/dist/git-cli/providers/pausedOperations.js +2 -2
- package/dist/git-cli/providers/pausedOperations.js.map +1 -1
- package/dist/git-cli/providers/staging.d.ts +8 -8
- package/dist/git-cli/providers/staging.js +120 -25
- package/dist/git-cli/providers/staging.js.map +1 -1
- package/dist/ipc/discovery.js +1 -1
- package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
- package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
- package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
- package/dist/plus/git-github/api/config.d.ts +5 -0
- package/dist/plus/git-github/api/config.js.map +1 -1
- package/dist/plus/git-github/api/github.js +24 -4
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/models.d.ts +12 -0
- package/dist/plus/git-github/models.js +8 -3
- package/dist/plus/git-github/models.js.map +1 -1
- package/dist/plus/integrations/context.d.ts +5 -0
- package/dist/plus/integrations/providers/azure/azure.js +1 -1
- package/dist/plus/integrations/providers/github.js +7 -3
- package/dist/plus/integrations/providers/github.js.map +1 -1
- package/dist/plus/integrations/reads/etag.d.ts +5 -0
- package/dist/plus/integrations/reads/etag.js +2 -0
- package/dist/plus/integrations/reads/etag.js.map +1 -1
- package/dist/utils/env/node/exec.d.ts +2 -0
- package/dist/utils/env/node/exec.js +4 -2
- package/dist/utils/env/node/exec.js.map +1 -1
- package/docs/integrations.md +9 -9
- package/package.json +1 -1
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { FileSystemProvider } from "../context.js";
|
|
2
2
|
//#region ../git/src/watching/gitIgnoreFilter.d.ts
|
|
3
|
+
interface IgnoreFilterConfig {
|
|
4
|
+
readonly globalExcludesPath?: string;
|
|
5
|
+
readonly ignoreCase?: boolean;
|
|
6
|
+
}
|
|
3
7
|
export interface GitIgnoreFilterOptions {
|
|
4
8
|
/** Absolute path to the repository root (working tree) */
|
|
5
9
|
readonly repoPath: string;
|
|
@@ -12,6 +16,8 @@ export interface GitIgnoreFilterOptions {
|
|
|
12
16
|
* May return undefined if not configured.
|
|
13
17
|
*/
|
|
14
18
|
readonly getGlobalExcludesPath?: () => Promise<string | undefined>;
|
|
19
|
+
readonly getConfig?: () => Promise<IgnoreFilterConfig>;
|
|
20
|
+
readonly invalidateConfig?: () => void;
|
|
15
21
|
/**
|
|
16
22
|
* Returns the absolute path to `info/exclude`, which lives in the COMMON git dir for a linked worktree.
|
|
17
23
|
* When provided, replaces the `gitDirPath`-based resolution; undefined means there is none to read.
|
|
@@ -60,10 +66,11 @@ export declare class GitIgnoreFilter {
|
|
|
60
66
|
private readonly repoPath;
|
|
61
67
|
private readonly gitDirPath;
|
|
62
68
|
private readonly fs;
|
|
63
|
-
private readonly
|
|
69
|
+
private readonly getConfig;
|
|
70
|
+
private readonly invalidateConfig?;
|
|
64
71
|
private readonly getInfoExcludePath?;
|
|
65
72
|
private readonly getGitIgnorePaths?;
|
|
66
|
-
|
|
73
|
+
get canInvalidateConfig(): boolean;
|
|
67
74
|
constructor(options: GitIgnoreFilterOptions);
|
|
68
75
|
/** Resolves when patterns are loaded and any {@link revalidate} has settled. Safe to call multiple times. */
|
|
69
76
|
ready(): Promise<void>;
|
|
@@ -86,7 +93,9 @@ export declare class GitIgnoreFilter {
|
|
|
86
93
|
* Single-flight: an idle filter reloads at once, but while a reload runs, every further call shares one reload
|
|
87
94
|
* queued behind it — a checkout touching many `.gitignore` files costs two reloads, not one per file.
|
|
88
95
|
*/
|
|
89
|
-
refresh(
|
|
96
|
+
refresh(options?: {
|
|
97
|
+
configChanged?: boolean;
|
|
98
|
+
}): Promise<void>;
|
|
90
99
|
/**
|
|
91
100
|
* Reloads when an ignore source changed since the last load, for a caller that stopped watching them for a while.
|
|
92
101
|
* Resolves true once that reload has committed; false when nothing changed, when no load has committed yet, or when
|
|
@@ -118,8 +127,6 @@ export declare class GitIgnoreFilter {
|
|
|
118
127
|
private stamp;
|
|
119
128
|
private readFile;
|
|
120
129
|
private resolveInfoExcludePath;
|
|
121
|
-
private readIgnoreCase;
|
|
122
|
-
private resolveGlobalExcludesPath;
|
|
123
130
|
}
|
|
124
131
|
//#endregion
|
|
125
132
|
//# sourceMappingURL=gitIgnoreFilter.d.ts.map
|
|
@@ -42,18 +42,28 @@ var GitIgnoreFilter = class {
|
|
|
42
42
|
repoPath;
|
|
43
43
|
gitDirPath;
|
|
44
44
|
fs;
|
|
45
|
-
|
|
45
|
+
getConfig;
|
|
46
|
+
invalidateConfig;
|
|
46
47
|
getInfoExcludePath;
|
|
47
48
|
getGitIgnorePaths;
|
|
48
|
-
|
|
49
|
+
get canInvalidateConfig() {
|
|
50
|
+
return this.invalidateConfig != null;
|
|
51
|
+
}
|
|
49
52
|
constructor(options) {
|
|
50
53
|
this.repoPath = options.repoPath;
|
|
51
54
|
this.gitDirPath = options.gitDirPath;
|
|
52
55
|
this.fs = options.fs;
|
|
53
|
-
this.
|
|
56
|
+
this.getConfig = async () => {
|
|
57
|
+
if (options.getConfig != null) return options.getConfig();
|
|
58
|
+
const [path, ignoreCase] = await Promise.allSettled([Promise.resolve().then(() => options.getGlobalExcludesPath?.()), Promise.resolve().then(() => options.getIgnoreCase?.())]);
|
|
59
|
+
return {
|
|
60
|
+
globalExcludesPath: getSettledValue(path),
|
|
61
|
+
ignoreCase: getSettledValue(ignoreCase)
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
this.invalidateConfig = options.invalidateConfig;
|
|
54
65
|
this.getInfoExcludePath = options.getInfoExcludePath;
|
|
55
66
|
this.getGitIgnorePaths = options.getGitIgnorePaths;
|
|
56
|
-
this.getIgnoreCase = options.getIgnoreCase;
|
|
57
67
|
this.startLoad();
|
|
58
68
|
}
|
|
59
69
|
/** Resolves when patterns are loaded and any {@link revalidate} has settled. Safe to call multiple times. */
|
|
@@ -90,7 +100,8 @@ var GitIgnoreFilter = class {
|
|
|
90
100
|
* Single-flight: an idle filter reloads at once, but while a reload runs, every further call shares one reload
|
|
91
101
|
* queued behind it — a checkout touching many `.gitignore` files costs two reloads, not one per file.
|
|
92
102
|
*/
|
|
93
|
-
refresh() {
|
|
103
|
+
refresh(options) {
|
|
104
|
+
if (options?.configChanged) this.invalidateConfig?.();
|
|
94
105
|
if (this.inflight == null) return this.startLoad();
|
|
95
106
|
if (this.trailing == null) {
|
|
96
107
|
const run = () => {
|
|
@@ -180,18 +191,18 @@ var GitIgnoreFilter = class {
|
|
|
180
191
|
async loadPatterns() {
|
|
181
192
|
const id = this._generation.next();
|
|
182
193
|
const stamps = /* @__PURE__ */ new Map();
|
|
183
|
-
const
|
|
194
|
+
const config = this.getConfig();
|
|
184
195
|
const infoExcludePath = this.resolveInfoExcludePath();
|
|
185
|
-
const [globalResult, infoResult, rootResult, nestedResult,
|
|
186
|
-
|
|
196
|
+
const [globalResult, infoResult, rootResult, nestedResult, configResult, infoPathResult] = await Promise.allSettled([
|
|
197
|
+
config.then(({ globalExcludesPath }) => this.readSource(globalExcludesPath, stamps)),
|
|
187
198
|
infoExcludePath.then((path) => this.readSource(path, stamps)),
|
|
188
199
|
this.readSource(`${this.repoPath}/.gitignore`, stamps),
|
|
189
200
|
this.loadNested(stamps),
|
|
190
|
-
|
|
201
|
+
config,
|
|
202
|
+
infoExcludePath
|
|
191
203
|
]);
|
|
192
|
-
const [globalPathResult, infoPathResult] = await Promise.allSettled([globalExcludesPath, infoExcludePath]);
|
|
193
204
|
if (id !== this._generation.current) return;
|
|
194
|
-
const options = { ignorecase: getSettledValue(
|
|
205
|
+
const options = { ignorecase: getSettledValue(configResult)?.ignoreCase ?? defaultIgnoreCase };
|
|
195
206
|
const ig = ignore(options);
|
|
196
207
|
for (const content of [
|
|
197
208
|
getSettledValue(globalResult),
|
|
@@ -215,20 +226,19 @@ var GitIgnoreFilter = class {
|
|
|
215
226
|
this.nested = nested?.size ? nested : void 0;
|
|
216
227
|
this.sources = {
|
|
217
228
|
ignoreCase: options.ignorecase,
|
|
218
|
-
globalExcludesPath: getSettledValue(
|
|
229
|
+
globalExcludesPath: getSettledValue(configResult)?.globalExcludesPath,
|
|
219
230
|
infoExcludePath: getSettledValue(infoPathResult),
|
|
220
231
|
stamps
|
|
221
232
|
};
|
|
222
233
|
}
|
|
223
234
|
/** Whether anything {@link loadPatterns} built `sources` from differs now; a source that can't be stat'ed has */
|
|
224
235
|
async sourcesChanged(sources) {
|
|
225
|
-
const [
|
|
226
|
-
this.
|
|
236
|
+
const [config, infoExcludePath, unchanged] = await Promise.allSettled([
|
|
237
|
+
this.getConfig(),
|
|
227
238
|
this.resolveInfoExcludePath(),
|
|
228
|
-
this.readIgnoreCase(),
|
|
229
239
|
Promise.allSettled(Array.from(sources.stamps, async ([path, stamp]) => stamp != null && stamp === await this.stamp(path)))
|
|
230
240
|
]);
|
|
231
|
-
return getSettledValue(globalExcludesPath
|
|
241
|
+
return getSettledValue(config)?.globalExcludesPath !== sources.globalExcludesPath || getSettledValue(infoExcludePath) !== sources.infoExcludePath || (getSettledValue(config)?.ignoreCase ?? defaultIgnoreCase) !== sources.ignoreCase || getSettledValue(unchanged)?.every((r) => getSettledValue(r) === true) !== true;
|
|
232
242
|
}
|
|
233
243
|
/** Reads every nested `.gitignore`, keyed by its repo-relative directory (no trailing slash) */
|
|
234
244
|
async loadNested(stamps) {
|
|
@@ -288,22 +298,6 @@ var GitIgnoreFilter = class {
|
|
|
288
298
|
return;
|
|
289
299
|
}
|
|
290
300
|
}
|
|
291
|
-
async readIgnoreCase() {
|
|
292
|
-
if (this.getIgnoreCase == null) return void 0;
|
|
293
|
-
try {
|
|
294
|
-
return await this.getIgnoreCase();
|
|
295
|
-
} catch {
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
async resolveGlobalExcludesPath() {
|
|
300
|
-
if (this.getGlobalExcludesPath == null) return void 0;
|
|
301
|
-
try {
|
|
302
|
-
return await this.getGlobalExcludesPath();
|
|
303
|
-
} catch {
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
301
|
};
|
|
308
302
|
//#endregion
|
|
309
303
|
export { GitIgnoreFilter };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitIgnoreFilter.js","names":[],"sources":["../../../../git/src/watching/gitIgnoreFilter.ts"],"sourcesContent":["import type { Ignore } from 'ignore';\nimport ignore from 'ignore';\nimport { getScopedCounter } from '@gitlens/utils/counter.js';\nimport { isLinux } from '@gitlens/utils/platform.js';\nimport { getSettledValue } from '@gitlens/utils/promise.js';\nimport { fileUri } from '@gitlens/utils/uri.js';\nimport type { FileSystemProvider } from '../context.js';\n\n/**\n * Case sensitivity when `core.ignorecase` is unset or unreadable. `ignore` matches case-insensitively by default, but\n * git follows `core.ignorecase` — false on Linux (and on a case-sensitive macOS volume), where matching `Build/`\n * against `build/` would call a real change ignored and drop it.\n */\nconst defaultIgnoreCase = !isLinux;\n\nexport interface GitIgnoreFilterOptions {\n\t/** Absolute path to the repository root (working tree) */\n\treadonly repoPath: string;\n\t/** Absolute path to the .git directory (for info/exclude when `getInfoExcludePath` isn't provided) */\n\treadonly gitDirPath: string;\n\t/** File system provider for reading ignore files */\n\treadonly fs: FileSystemProvider;\n\t/**\n\t * Returns the path to the global excludes file (core.excludesFile).\n\t * May return undefined if not configured.\n\t */\n\treadonly getGlobalExcludesPath?: () => Promise<string | undefined>;\n\t/**\n\t * Returns the absolute path to `info/exclude`, which lives in the COMMON git dir for a linked worktree.\n\t * When provided, replaces the `gitDirPath`-based resolution; undefined means there is none to read.\n\t */\n\treadonly getInfoExcludePath?: () => Promise<string | undefined>;\n\t/**\n\t * Returns the repo-relative, `/`-separated paths of every `.gitignore` git reads (root included).\n\t * Without it, only the root `.gitignore` is honoured.\n\t */\n\treadonly getGitIgnorePaths?: () => Promise<readonly string[]>;\n\t/**\n\t * Returns `core.ignorecase`, which decides whether patterns match case-insensitively. Undefined (or a failed read)\n\t * falls back to the platform default (case-sensitive on Linux only).\n\t */\n\treadonly getIgnoreCase?: () => Promise<boolean | undefined>;\n}\n\n/** What a committed load was built from, which {@link GitIgnoreFilter.revalidate} compares against */\ninterface LoadedSources {\n\treadonly ignoreCase: boolean;\n\treadonly globalExcludesPath: string | undefined;\n\treadonly infoExcludePath: string | undefined;\n\t/** Every ignore file the load read, by absolute path, with its {@link GitIgnoreFilter.stamp} taken before the read */\n\treadonly stamps: ReadonlyMap<string, string | undefined>;\n}\n\n/**\n * In-memory gitignore filter using the `ignore` npm package.\n * Fully library-owned — no VS Code dependencies.\n *\n * Loads patterns eagerly on creation, in git's precedence order (lowest first):\n * 1. Global excludes file (`core.excludesFile`)\n * 2. `info/exclude`\n * 3. `<repoPath>/.gitignore`\n * 4. Nested `.gitignore` files (via `getGitIgnorePaths`), deeper overriding shallower\n *\n * Once loaded, all checks are **synchronous** for maximum performance.\n * Call `ready()` before first use to ensure patterns are loaded.\n */\nexport class GitIgnoreFilter {\n\tprivate ig: Ignore = ignore({ ignorecase: defaultIgnoreCase });\n\t/** Matchers for nested `.gitignore` files, keyed by their repo-relative directory (no trailing slash) */\n\tprivate nested: Map<string, Ignore> | undefined;\n\t/** The newest load, which {@link ready} waits for; cleared once it settles */\n\tprivate loading: Promise<void> | undefined;\n\t/** The load running now; at most one runs at a time */\n\tprivate inflight: Promise<void> | undefined;\n\t/** The one load queued behind {@link inflight}, which every refresh made meanwhile shares */\n\tprivate trailing: Promise<void> | undefined;\n\t/** The running {@link revalidate}, which {@link ready} also waits for */\n\tprivate revalidating: Promise<boolean> | undefined;\n\tprivate sources: LoadedSources | undefined;\n\tprivate readonly _generation = getScopedCounter();\n\n\t// Reused across `isIgnored` calls (which are synchronous, so never interleave) to avoid per-event allocations\n\tprivate readonly _scratchMatchers: Ignore[] = [];\n\tprivate readonly _scratchBases: number[] = [];\n\n\tprivate readonly repoPath: string;\n\tprivate readonly gitDirPath: string;\n\tprivate readonly fs: FileSystemProvider;\n\tprivate readonly getGlobalExcludesPath?: () => Promise<string | undefined>;\n\tprivate readonly getInfoExcludePath?: () => Promise<string | undefined>;\n\tprivate readonly getGitIgnorePaths?: () => Promise<readonly string[]>;\n\tprivate readonly getIgnoreCase?: () => Promise<boolean | undefined>;\n\n\tconstructor(options: GitIgnoreFilterOptions) {\n\t\tthis.repoPath = options.repoPath;\n\t\tthis.gitDirPath = options.gitDirPath;\n\t\tthis.fs = options.fs;\n\t\tthis.getGlobalExcludesPath = options.getGlobalExcludesPath;\n\t\tthis.getInfoExcludePath = options.getInfoExcludePath;\n\t\tthis.getGitIgnorePaths = options.getGitIgnorePaths;\n\t\tthis.getIgnoreCase = options.getIgnoreCase;\n\n\t\t// Start loading immediately\n\t\tvoid this.startLoad();\n\t}\n\n\t/** Resolves when patterns are loaded and any {@link revalidate} has settled. Safe to call multiple times. */\n\tasync ready(): Promise<void> {\n\t\tif (this.revalidating != null) {\n\t\t\tawait this.revalidating;\n\t\t}\n\t\t// Read after the revalidation: a refresh made during it supersedes it\n\t\tif (this.loading != null) {\n\t\t\tawait this.loading;\n\t\t}\n\t}\n\n\t/**\n\t * Check if a path is ignored. Must be called after `ready()`.\n\t * Errs toward \"not ignored\": a false \"ignored\" drops a real change, a false \"not ignored\" only costs a refresh.\n\t * @param relativePath Path relative to the repository root (forward slashes; a trailing slash marks a directory)\n\t * @returns true if the path should be ignored\n\t */\n\tisIgnored(relativePath: string): boolean {\n\t\tif (!relativePath) return false;\n\n\t\ttry {\n\t\t\tif (this.nested == null) return this.ig.ignores(relativePath);\n\n\t\t\treturn this.isIgnoredNested(relativePath, this.nested);\n\t\t} catch {\n\t\t\t// `ignore` can throw on edge-case paths\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Filter an array of relative paths, returning only non-ignored ones.\n\t * Must be called after `ready()`.\n\t */\n\tfilter(relativePaths: readonly string[]): string[] {\n\t\treturn relativePaths.filter(p => !this.isIgnored(p));\n\t}\n\n\t/**\n\t * Reload all patterns (e.g., after a .gitignore or info/exclude changes), rediscovering nested `.gitignore` files.\n\t * Returns a promise that resolves when a reload started after this call is complete.\n\t *\n\t * Single-flight: an idle filter reloads at once, but while a reload runs, every further call shares one reload\n\t * queued behind it — a checkout touching many `.gitignore` files costs two reloads, not one per file.\n\t */\n\trefresh(): Promise<void> {\n\t\tif (this.inflight == null) return this.startLoad();\n\n\t\tif (this.trailing == null) {\n\t\t\tconst run = (): Promise<void> => {\n\t\t\t\tthis.trailing = undefined;\n\t\t\t\treturn this.startLoad();\n\t\t\t};\n\t\t\tthis.trailing = this.inflight.then(run, run);\n\t\t}\n\t\tthis.loading = this.trailing;\n\t\treturn this.trailing;\n\t}\n\n\t/**\n\t * Reloads when an ignore source changed since the last load, for a caller that stopped watching them for a while.\n\t * Resolves true once that reload has committed; false when nothing changed, when no load has committed yet, or when\n\t * a load is running, queued, or started meanwhile (it reads the sources afresh).\n\t *\n\t * Only the sources the last load read are stat'ed — the nested list isn't rediscovered, which would cost a git\n\t * spawn — so a nested `.gitignore` created since then goes unseen until the next {@link refresh}.\n\t */\n\trevalidate(): Promise<boolean> {\n\t\tif (this.revalidating != null) return this.revalidating;\n\n\t\tconst sources = this.sources;\n\t\tif (sources == null || this.loading != null) return Promise.resolve(false);\n\n\t\tconst generation = this._generation.current;\n\t\tconst revalidation: Promise<boolean> = this.sourcesChanged(sources)\n\t\t\t.then(async changed => {\n\t\t\t\tif (!changed || this._generation.current !== generation) return false;\n\n\t\t\t\tawait this.refresh();\n\t\t\t\treturn true;\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\tif (this.revalidating === revalidation) {\n\t\t\t\t\tthis.revalidating = undefined;\n\t\t\t\t}\n\t\t\t});\n\t\tthis.revalidating = revalidation;\n\t\treturn revalidation;\n\t}\n\n\tprivate startLoad(): Promise<void> {\n\t\tconst load: Promise<void> = this.loadPatterns().finally(() => {\n\t\t\tif (this.inflight === load) {\n\t\t\t\tthis.inflight = undefined;\n\t\t\t}\n\t\t\tif (this.loading === load) {\n\t\t\t\tthis.loading = undefined;\n\t\t\t}\n\t\t});\n\t\tthis.inflight = load;\n\t\tthis.loading = load;\n\t\treturn load;\n\t}\n\n\t/**\n\t * Mirrors git's directory walk: each ancestor directory is checked shallow→deep, and the first one found ignored\n\t * ignores the whole path (git never descends into it, so nothing below can re-include it). At each level, the\n\t * matchers whose directory is a proper ancestor apply, and the deepest decisive one wins, falling back to the root.\n\t */\n\tprivate isIgnoredNested(path: string, nested: Map<string, Ignore>): boolean {\n\t\tconst matchers = this._scratchMatchers;\n\t\tconst bases = this._scratchBases;\n\n\t\ttry {\n\t\t\t// A trailing slash belongs to the path itself (a directory form), not to an ancestor\n\t\t\tconst last = path.length - 1;\n\n\t\t\tlet slash = path.indexOf('/');\n\t\t\twhile (slash !== -1 && slash < last) {\n\t\t\t\tif (this.isLevelIgnored(path, slash + 1, matchers, bases)) return true;\n\n\t\t\t\t// A directory's own `.gitignore` applies below it, never to the directory itself\n\t\t\t\tconst matcher = nested.get(path.slice(0, slash));\n\t\t\t\tif (matcher != null) {\n\t\t\t\t\tmatchers.push(matcher);\n\t\t\t\t\tbases.push(slash + 1);\n\t\t\t\t}\n\n\t\t\t\tslash = path.indexOf('/', slash + 1);\n\t\t\t}\n\n\t\t\treturn this.isLevelIgnored(path, path.length, matchers, bases);\n\t\t} finally {\n\t\t\tmatchers.length = 0;\n\t\t\tbases.length = 0;\n\t\t}\n\t}\n\n\t/** Whether `path.slice(0, end)` is ignored, given its ancestors aren't */\n\tprivate isLevelIgnored(path: string, end: number, matchers: readonly Ignore[], bases: readonly number[]): boolean {\n\t\tfor (let i = matchers.length - 1; i >= 0; i--) {\n\t\t\tconst verdict = this.testLevel(matchers[i], path.slice(bases[i], end));\n\t\t\tif (verdict != null) return verdict;\n\t\t}\n\n\t\treturn this.testLevel(this.ig, path.slice(0, end)) ?? false;\n\t}\n\n\t/** Returns the matcher's decisive verdict for `path`, or undefined when it has none */\n\tprivate testLevel(matcher: Ignore, path: string): boolean | undefined {\n\t\tconst result = matcher.test(path);\n\t\tif (result.unignored) return false;\n\t\tif (!result.ignored) return undefined;\n\n\t\t// `ignore` folds its own verdict for each ancestor into a path's result: once the matcher considers a parent\n\t\t// ignored, every child reports that parent's result. Reaching here means a deeper matcher re-included that\n\t\t// parent, so this result says nothing about the path itself — the matcher's own rules are unknowable, so\n\t\t// answer \"not ignored\" rather than risk dropping a real change.\n\t\tconst parentEnd = path.lastIndexOf('/', path.length - 2);\n\t\tif (parentEnd !== -1 && matcher.test(path.slice(0, parentEnd + 1)).ignored) return false;\n\n\t\treturn true;\n\t}\n\n\tprivate async loadPatterns(): Promise<void> {\n\t\tconst id = this._generation.next();\n\t\tconst stamps = new Map<string, string | undefined>();\n\n\t\tconst globalExcludesPath = this.resolveGlobalExcludesPath();\n\t\tconst infoExcludePath = this.resolveInfoExcludePath();\n\t\tconst [globalResult, infoResult, rootResult, nestedResult, ignoreCaseResult] = await Promise.allSettled([\n\t\t\tglobalExcludesPath.then(path => this.readSource(path, stamps)),\n\t\t\tinfoExcludePath.then(path => this.readSource(path, stamps)),\n\t\t\tthis.readSource(`${this.repoPath}/.gitignore`, stamps),\n\t\t\tthis.loadNested(stamps),\n\t\t\tthis.readIgnoreCase(),\n\t\t]);\n\t\tconst [globalPathResult, infoPathResult] = await Promise.allSettled([globalExcludesPath, infoExcludePath]);\n\n\t\t// Only commit results if no newer refresh has started\n\t\tif (id !== this._generation.current) return;\n\n\t\tconst options = { ignorecase: getSettledValue(ignoreCaseResult) ?? defaultIgnoreCase };\n\n\t\t// Added in git's precedence order (lowest first), since the last matching pattern wins\n\t\tconst ig = ignore(options);\n\t\tfor (const content of [\n\t\t\tgetSettledValue(globalResult),\n\t\t\tgetSettledValue(infoResult),\n\t\t\tgetSettledValue(rootResult),\n\t\t]) {\n\t\t\tif (!content) continue;\n\n\t\t\ttry {\n\t\t\t\tig.add(content);\n\t\t\t} catch {\n\t\t\t\t// A source `ignore` can't parse is skipped rather than failing the whole load\n\t\t\t}\n\t\t}\n\n\t\tlet nested: Map<string, Ignore> | undefined;\n\t\tconst nestedContents = getSettledValue(nestedResult);\n\t\tif (nestedContents?.size) {\n\t\t\tnested = new Map();\n\t\t\tfor (const [dir, content] of nestedContents) {\n\t\t\t\ttry {\n\t\t\t\t\tnested.set(dir, ignore(options).add(content));\n\t\t\t\t} catch {\n\t\t\t\t\t// A file `ignore` can't parse is skipped rather than failing the whole load\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.ig = ig;\n\t\tthis.nested = nested?.size ? nested : undefined;\n\t\tthis.sources = {\n\t\t\tignoreCase: options.ignorecase,\n\t\t\tglobalExcludesPath: getSettledValue(globalPathResult),\n\t\t\tinfoExcludePath: getSettledValue(infoPathResult),\n\t\t\tstamps: stamps,\n\t\t};\n\t}\n\n\t/** Whether anything {@link loadPatterns} built `sources` from differs now; a source that can't be stat'ed has */\n\tprivate async sourcesChanged(sources: LoadedSources): Promise<boolean> {\n\t\tconst [globalExcludesPath, infoExcludePath, ignoreCase, unchanged] = await Promise.allSettled([\n\t\t\tthis.resolveGlobalExcludesPath(),\n\t\t\tthis.resolveInfoExcludePath(),\n\t\t\tthis.readIgnoreCase(),\n\t\t\tPromise.allSettled(\n\t\t\t\tArray.from(\n\t\t\t\t\tsources.stamps,\n\t\t\t\t\tasync ([path, stamp]) => stamp != null && stamp === (await this.stamp(path)),\n\t\t\t\t),\n\t\t\t),\n\t\t]);\n\n\t\treturn (\n\t\t\tgetSettledValue(globalExcludesPath) !== sources.globalExcludesPath ||\n\t\t\tgetSettledValue(infoExcludePath) !== sources.infoExcludePath ||\n\t\t\t(getSettledValue(ignoreCase) ?? defaultIgnoreCase) !== sources.ignoreCase ||\n\t\t\tgetSettledValue(unchanged)?.every(r => getSettledValue(r) === true) !== true\n\t\t);\n\t}\n\n\t/** Reads every nested `.gitignore`, keyed by its repo-relative directory (no trailing slash) */\n\tprivate async loadNested(stamps: Map<string, string | undefined>): Promise<Map<string, string> | undefined> {\n\t\tif (this.getGitIgnorePaths == null) return undefined;\n\n\t\tlet paths: readonly string[];\n\t\ttry {\n\t\t\tpaths = await this.getGitIgnorePaths();\n\t\t} catch {\n\t\t\t// Discovery failed — fall back to the root `.gitignore` alone\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst suffix = '/.gitignore';\n\t\tconst dirs = new Set<string>();\n\t\tfor (const path of paths) {\n\t\t\t// The root `.gitignore` (no directory) is loaded with the other root sources\n\t\t\tif (path.length <= suffix.length || !path.endsWith(suffix)) continue;\n\n\t\t\tdirs.add(path.slice(0, -suffix.length));\n\t\t}\n\t\tif (!dirs.size) return undefined;\n\n\t\tconst entries = await Promise.allSettled(\n\t\t\tArray.from(dirs, async dir => {\n\t\t\t\tconst content = await this.readSource(`${this.repoPath}/${dir}${suffix}`, stamps);\n\t\t\t\treturn content ? ([dir, content] as const) : undefined;\n\t\t\t}),\n\t\t);\n\n\t\tconst nested = new Map<string, string>();\n\t\tfor (const entry of entries) {\n\t\t\tconst value = getSettledValue(entry);\n\t\t\tif (value != null) {\n\t\t\t\tnested.set(value[0], value[1]);\n\t\t\t}\n\t\t}\n\t\treturn nested;\n\t}\n\n\t/** Stamps an ignore file, then reads it — stamped first, so an edit landing in between reads as a change later */\n\tprivate async readSource(\n\t\tpath: string | undefined,\n\t\tstamps: Map<string, string | undefined>,\n\t): Promise<string | undefined> {\n\t\tif (path == null) return undefined;\n\n\t\tstamps.set(path, await this.stamp(path));\n\t\treturn this.readFile(path);\n\t}\n\n\t/** `mtime:size`, `''` when the file is absent, or undefined when it can't be stat'ed */\n\tprivate async stamp(path: string): Promise<string | undefined> {\n\t\ttry {\n\t\t\tconst stat = await this.fs.stat(fileUri(path));\n\t\t\treturn stat != null ? `${stat.mtime}:${stat.size}` : '';\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate async readFile(path: string): Promise<string | undefined> {\n\t\ttry {\n\t\t\tconst data = await this.fs.readFile(fileUri(path));\n\t\t\treturn new TextDecoder().decode(data);\n\t\t} catch {\n\t\t\t// File might not exist or be unreadable — that's fine\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate async resolveInfoExcludePath(): Promise<string | undefined> {\n\t\tif (this.getInfoExcludePath == null) return `${this.gitDirPath}/info/exclude`;\n\n\t\ttry {\n\t\t\treturn await this.getInfoExcludePath();\n\t\t} catch {\n\t\t\t// The git dir couldn't be resolved\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate async readIgnoreCase(): Promise<boolean | undefined> {\n\t\tif (this.getIgnoreCase == null) return undefined;\n\n\t\ttry {\n\t\t\treturn await this.getIgnoreCase();\n\t\t} catch {\n\t\t\t// Unreadable — the platform default applies\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate async resolveGlobalExcludesPath(): Promise<string | undefined> {\n\t\tif (this.getGlobalExcludesPath == null) return undefined;\n\n\t\ttry {\n\t\t\treturn await this.getGlobalExcludesPath();\n\t\t} catch {\n\t\t\t// Global excludes might not be configured\n\t\t\treturn undefined;\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;AAaA,MAAM,oBAAoB,CAAC;;;;;;;;;;;;;;AAqD3B,IAAa,kBAAb,MAA6B;CAC5B,KAAqB,OAAO,EAAE,YAAY,kBAAkB,CAAC;;CAE7D;;CAEA;;CAEA;;CAEA;;CAEA;CACA;CACA,cAA+B,iBAAiB;CAGhD,mBAA8C,CAAC;CAC/C,gBAA2C,CAAC;CAE5C;CACA;CACA;CACA;CACA;CACA;CACA;CAEA,YAAY,SAAiC;EAC5C,KAAK,WAAW,QAAQ;EACxB,KAAK,aAAa,QAAQ;EAC1B,KAAK,KAAK,QAAQ;EAClB,KAAK,wBAAwB,QAAQ;EACrC,KAAK,qBAAqB,QAAQ;EAClC,KAAK,oBAAoB,QAAQ;EACjC,KAAK,gBAAgB,QAAQ;EAG7B,KAAU,UAAU;CACrB;;CAGA,MAAM,QAAuB;EAC5B,IAAI,KAAK,gBAAgB,MACxB,MAAM,KAAK;EAGZ,IAAI,KAAK,WAAW,MACnB,MAAM,K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AAK;GACnC,IAAI,SAAS,MACZ,OAAO,IAAI,MAAM,IAAI,MAAM,EAAE;EAE/B;EACA,OAAO;CACR;;CAGA,MAAc,WACb,MACA,QAC8B;EAC9B,IAAI,QAAQ,MAAM,OAAO,KAAA;EAEzB,OAAO,IAAI,MAAM,MAAM,KAAK,MAAM,IAAI,CAAC;EACvC,OAAO,KAAK,SAAS,IAAI;CAC1B;;CAGA,MAAc,MAAM,MAA2C;EAC9D,IAAI;GACH,MAAM,OAAO,MAAM,KAAK,GAAG,KAAK,QAAQ,IAAI,CAAC;GAC7C,OAAO,QAAQ,OAAO,GAAG,KAAK,MAAM,GAAG,KAAK,SAAS;EACtD,QAAQ;GACP;EACD;CACD;CAEA,MAAc,SAAS,MAA2C;EACjE,IAAI;GACH,MAAM,OAAO,MAAM,KAAK,GAAG,SAAS,QAAQ,IAAI,CAAC;GACjD,OAAO,IAAI,YAAY,CAAC,CAAC,OAAO,IAAI;EACrC,QAAQ;GAEP;EACD;CACD;CAEA,MAAc,yBAAsD;EACnE,IAAI,KAAK,sBAAsB,MAAM,OAAO,GAAG,KAAK,WAAW;EAE/D,IAAI;GACH,OAAO,MAAM,KAAK,mBAAmB;EACtC,QAAQ;GAEP;EACD;CACD;CAEA,MAAc,iBAA+C;EAC5D,IAAI,KAAK,iBAAiB,MAAM,OAAO,KAAA;EAEvC,IAAI;GACH,OAAO,MAAM,KAAK,cAAc;EACjC,QAAQ;GAEP;EACD;CACD;CAEA,MAAc,4BAAyD;EACtE,IAAI,KAAK,yBAAyB,MAAM,OAAO,KAAA;EAE/C,IAAI;GACH,OAAO,MAAM,KAAK,sBAAsB;EACzC,QAAQ;GAEP;EACD;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"gitIgnoreFilter.js","names":[],"sources":["../../../../git/src/watching/gitIgnoreFilter.ts"],"sourcesContent":["import type { Ignore } from 'ignore';\nimport ignore from 'ignore';\nimport { getScopedCounter } from '@gitlens/utils/counter.js';\nimport { isLinux } from '@gitlens/utils/platform.js';\nimport { getSettledValue } from '@gitlens/utils/promise.js';\nimport { fileUri } from '@gitlens/utils/uri.js';\nimport type { FileSystemProvider } from '../context.js';\n\n/**\n * Case sensitivity when `core.ignorecase` is unset or unreadable. `ignore` matches case-insensitively by default, but\n * git follows `core.ignorecase` — false on Linux (and on a case-sensitive macOS volume), where matching `Build/`\n * against `build/` would call a real change ignored and drop it.\n */\nconst defaultIgnoreCase = !isLinux;\n\ninterface IgnoreFilterConfig {\n\treadonly globalExcludesPath?: string;\n\treadonly ignoreCase?: boolean;\n}\n\nexport interface GitIgnoreFilterOptions {\n\t/** Absolute path to the repository root (working tree) */\n\treadonly repoPath: string;\n\t/** Absolute path to the .git directory (for info/exclude when `getInfoExcludePath` isn't provided) */\n\treadonly gitDirPath: string;\n\t/** File system provider for reading ignore files */\n\treadonly fs: FileSystemProvider;\n\t/**\n\t * Returns the path to the global excludes file (core.excludesFile).\n\t * May return undefined if not configured.\n\t */\n\treadonly getGlobalExcludesPath?: () => Promise<string | undefined>;\n\treadonly getConfig?: () => Promise<IgnoreFilterConfig>;\n\treadonly invalidateConfig?: () => void;\n\t/**\n\t * Returns the absolute path to `info/exclude`, which lives in the COMMON git dir for a linked worktree.\n\t * When provided, replaces the `gitDirPath`-based resolution; undefined means there is none to read.\n\t */\n\treadonly getInfoExcludePath?: () => Promise<string | undefined>;\n\t/**\n\t * Returns the repo-relative, `/`-separated paths of every `.gitignore` git reads (root included).\n\t * Without it, only the root `.gitignore` is honoured.\n\t */\n\treadonly getGitIgnorePaths?: () => Promise<readonly string[]>;\n\t/**\n\t * Returns `core.ignorecase`, which decides whether patterns match case-insensitively. Undefined (or a failed read)\n\t * falls back to the platform default (case-sensitive on Linux only).\n\t */\n\treadonly getIgnoreCase?: () => Promise<boolean | undefined>;\n}\n\n/** What a committed load was built from, which {@link GitIgnoreFilter.revalidate} compares against */\ninterface LoadedSources {\n\treadonly ignoreCase: boolean;\n\treadonly globalExcludesPath: string | undefined;\n\treadonly infoExcludePath: string | undefined;\n\t/** Every ignore file the load read, by absolute path, with its {@link GitIgnoreFilter.stamp} taken before the read */\n\treadonly stamps: ReadonlyMap<string, string | undefined>;\n}\n\n/**\n * In-memory gitignore filter using the `ignore` npm package.\n * Fully library-owned — no VS Code dependencies.\n *\n * Loads patterns eagerly on creation, in git's precedence order (lowest first):\n * 1. Global excludes file (`core.excludesFile`)\n * 2. `info/exclude`\n * 3. `<repoPath>/.gitignore`\n * 4. Nested `.gitignore` files (via `getGitIgnorePaths`), deeper overriding shallower\n *\n * Once loaded, all checks are **synchronous** for maximum performance.\n * Call `ready()` before first use to ensure patterns are loaded.\n */\nexport class GitIgnoreFilter {\n\tprivate ig: Ignore = ignore({ ignorecase: defaultIgnoreCase });\n\t/** Matchers for nested `.gitignore` files, keyed by their repo-relative directory (no trailing slash) */\n\tprivate nested: Map<string, Ignore> | undefined;\n\t/** The newest load, which {@link ready} waits for; cleared once it settles */\n\tprivate loading: Promise<void> | undefined;\n\t/** The load running now; at most one runs at a time */\n\tprivate inflight: Promise<void> | undefined;\n\t/** The one load queued behind {@link inflight}, which every refresh made meanwhile shares */\n\tprivate trailing: Promise<void> | undefined;\n\t/** The running {@link revalidate}, which {@link ready} also waits for */\n\tprivate revalidating: Promise<boolean> | undefined;\n\tprivate sources: LoadedSources | undefined;\n\tprivate readonly _generation = getScopedCounter();\n\n\t// Reused across `isIgnored` calls (which are synchronous, so never interleave) to avoid per-event allocations\n\tprivate readonly _scratchMatchers: Ignore[] = [];\n\tprivate readonly _scratchBases: number[] = [];\n\n\tprivate readonly repoPath: string;\n\tprivate readonly gitDirPath: string;\n\tprivate readonly fs: FileSystemProvider;\n\tprivate readonly getConfig: () => Promise<IgnoreFilterConfig>;\n\tprivate readonly invalidateConfig?: () => void;\n\tprivate readonly getInfoExcludePath?: () => Promise<string | undefined>;\n\tprivate readonly getGitIgnorePaths?: () => Promise<readonly string[]>;\n\n\tget canInvalidateConfig(): boolean {\n\t\treturn this.invalidateConfig != null;\n\t}\n\n\tconstructor(options: GitIgnoreFilterOptions) {\n\t\tthis.repoPath = options.repoPath;\n\t\tthis.gitDirPath = options.gitDirPath;\n\t\tthis.fs = options.fs;\n\t\tthis.getConfig = async () => {\n\t\t\tif (options.getConfig != null) return options.getConfig();\n\n\t\t\tconst [path, ignoreCase] = await Promise.allSettled([\n\t\t\t\tPromise.resolve().then(() => options.getGlobalExcludesPath?.()),\n\t\t\t\tPromise.resolve().then(() => options.getIgnoreCase?.()),\n\t\t\t]);\n\t\t\treturn { globalExcludesPath: getSettledValue(path), ignoreCase: getSettledValue(ignoreCase) };\n\t\t};\n\t\tthis.invalidateConfig = options.invalidateConfig;\n\t\tthis.getInfoExcludePath = options.getInfoExcludePath;\n\t\tthis.getGitIgnorePaths = options.getGitIgnorePaths;\n\n\t\t// Start loading immediately\n\t\tvoid this.startLoad();\n\t}\n\n\t/** Resolves when patterns are loaded and any {@link revalidate} has settled. Safe to call multiple times. */\n\tasync ready(): Promise<void> {\n\t\tif (this.revalidating != null) {\n\t\t\tawait this.revalidating;\n\t\t}\n\t\t// Read after the revalidation: a refresh made during it supersedes it\n\t\tif (this.loading != null) {\n\t\t\tawait this.loading;\n\t\t}\n\t}\n\n\t/**\n\t * Check if a path is ignored. Must be called after `ready()`.\n\t * Errs toward \"not ignored\": a false \"ignored\" drops a real change, a false \"not ignored\" only costs a refresh.\n\t * @param relativePath Path relative to the repository root (forward slashes; a trailing slash marks a directory)\n\t * @returns true if the path should be ignored\n\t */\n\tisIgnored(relativePath: string): boolean {\n\t\tif (!relativePath) return false;\n\n\t\ttry {\n\t\t\tif (this.nested == null) return this.ig.ignores(relativePath);\n\n\t\t\treturn this.isIgnoredNested(relativePath, this.nested);\n\t\t} catch {\n\t\t\t// `ignore` can throw on edge-case paths\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Filter an array of relative paths, returning only non-ignored ones.\n\t * Must be called after `ready()`.\n\t */\n\tfilter(relativePaths: readonly string[]): string[] {\n\t\treturn relativePaths.filter(p => !this.isIgnored(p));\n\t}\n\n\t/**\n\t * Reload all patterns (e.g., after a .gitignore or info/exclude changes), rediscovering nested `.gitignore` files.\n\t * Returns a promise that resolves when a reload started after this call is complete.\n\t *\n\t * Single-flight: an idle filter reloads at once, but while a reload runs, every further call shares one reload\n\t * queued behind it — a checkout touching many `.gitignore` files costs two reloads, not one per file.\n\t */\n\trefresh(options?: { configChanged?: boolean }): Promise<void> {\n\t\tif (options?.configChanged) {\n\t\t\tthis.invalidateConfig?.();\n\t\t}\n\t\tif (this.inflight == null) return this.startLoad();\n\n\t\tif (this.trailing == null) {\n\t\t\tconst run = (): Promise<void> => {\n\t\t\t\tthis.trailing = undefined;\n\t\t\t\treturn this.startLoad();\n\t\t\t};\n\t\t\tthis.trailing = this.inflight.then(run, run);\n\t\t}\n\t\tthis.loading = this.trailing;\n\t\treturn this.trailing;\n\t}\n\n\t/**\n\t * Reloads when an ignore source changed since the last load, for a caller that stopped watching them for a while.\n\t * Resolves true once that reload has committed; false when nothing changed, when no load has committed yet, or when\n\t * a load is running, queued, or started meanwhile (it reads the sources afresh).\n\t *\n\t * Only the sources the last load read are stat'ed — the nested list isn't rediscovered, which would cost a git\n\t * spawn — so a nested `.gitignore` created since then goes unseen until the next {@link refresh}.\n\t */\n\trevalidate(): Promise<boolean> {\n\t\tif (this.revalidating != null) return this.revalidating;\n\n\t\tconst sources = this.sources;\n\t\tif (sources == null || this.loading != null) return Promise.resolve(false);\n\n\t\tconst generation = this._generation.current;\n\t\tconst revalidation: Promise<boolean> = this.sourcesChanged(sources)\n\t\t\t.then(async changed => {\n\t\t\t\tif (!changed || this._generation.current !== generation) return false;\n\n\t\t\t\tawait this.refresh();\n\t\t\t\treturn true;\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\tif (this.revalidating === revalidation) {\n\t\t\t\t\tthis.revalidating = undefined;\n\t\t\t\t}\n\t\t\t});\n\t\tthis.revalidating = revalidation;\n\t\treturn revalidation;\n\t}\n\n\tprivate startLoad(): Promise<void> {\n\t\tconst load: Promise<void> = this.loadPatterns().finally(() => {\n\t\t\tif (this.inflight === load) {\n\t\t\t\tthis.inflight = undefined;\n\t\t\t}\n\t\t\tif (this.loading === load) {\n\t\t\t\tthis.loading = undefined;\n\t\t\t}\n\t\t});\n\t\tthis.inflight = load;\n\t\tthis.loading = load;\n\t\treturn load;\n\t}\n\n\t/**\n\t * Mirrors git's directory walk: each ancestor directory is checked shallow→deep, and the first one found ignored\n\t * ignores the whole path (git never descends into it, so nothing below can re-include it). At each level, the\n\t * matchers whose directory is a proper ancestor apply, and the deepest decisive one wins, falling back to the root.\n\t */\n\tprivate isIgnoredNested(path: string, nested: Map<string, Ignore>): boolean {\n\t\tconst matchers = this._scratchMatchers;\n\t\tconst bases = this._scratchBases;\n\n\t\ttry {\n\t\t\t// A trailing slash belongs to the path itself (a directory form), not to an ancestor\n\t\t\tconst last = path.length - 1;\n\n\t\t\tlet slash = path.indexOf('/');\n\t\t\twhile (slash !== -1 && slash < last) {\n\t\t\t\tif (this.isLevelIgnored(path, slash + 1, matchers, bases)) return true;\n\n\t\t\t\t// A directory's own `.gitignore` applies below it, never to the directory itself\n\t\t\t\tconst matcher = nested.get(path.slice(0, slash));\n\t\t\t\tif (matcher != null) {\n\t\t\t\t\tmatchers.push(matcher);\n\t\t\t\t\tbases.push(slash + 1);\n\t\t\t\t}\n\n\t\t\t\tslash = path.indexOf('/', slash + 1);\n\t\t\t}\n\n\t\t\treturn this.isLevelIgnored(path, path.length, matchers, bases);\n\t\t} finally {\n\t\t\tmatchers.length = 0;\n\t\t\tbases.length = 0;\n\t\t}\n\t}\n\n\t/** Whether `path.slice(0, end)` is ignored, given its ancestors aren't */\n\tprivate isLevelIgnored(path: string, end: number, matchers: readonly Ignore[], bases: readonly number[]): boolean {\n\t\tfor (let i = matchers.length - 1; i >= 0; i--) {\n\t\t\tconst verdict = this.testLevel(matchers[i], path.slice(bases[i], end));\n\t\t\tif (verdict != null) return verdict;\n\t\t}\n\n\t\treturn this.testLevel(this.ig, path.slice(0, end)) ?? false;\n\t}\n\n\t/** Returns the matcher's decisive verdict for `path`, or undefined when it has none */\n\tprivate testLevel(matcher: Ignore, path: string): boolean | undefined {\n\t\tconst result = matcher.test(path);\n\t\tif (result.unignored) return false;\n\t\tif (!result.ignored) return undefined;\n\n\t\t// `ignore` folds its own verdict for each ancestor into a path's result: once the matcher considers a parent\n\t\t// ignored, every child reports that parent's result. Reaching here means a deeper matcher re-included that\n\t\t// parent, so this result says nothing about the path itself — the matcher's own rules are unknowable, so\n\t\t// answer \"not ignored\" rather than risk dropping a real change.\n\t\tconst parentEnd = path.lastIndexOf('/', path.length - 2);\n\t\tif (parentEnd !== -1 && matcher.test(path.slice(0, parentEnd + 1)).ignored) return false;\n\n\t\treturn true;\n\t}\n\n\tprivate async loadPatterns(): Promise<void> {\n\t\tconst id = this._generation.next();\n\t\tconst stamps = new Map<string, string | undefined>();\n\n\t\tconst config = this.getConfig();\n\t\tconst infoExcludePath = this.resolveInfoExcludePath();\n\t\tconst [globalResult, infoResult, rootResult, nestedResult, configResult, infoPathResult] =\n\t\t\tawait Promise.allSettled([\n\t\t\t\tconfig.then(({ globalExcludesPath }) => this.readSource(globalExcludesPath, stamps)),\n\t\t\t\tinfoExcludePath.then(path => this.readSource(path, stamps)),\n\t\t\t\tthis.readSource(`${this.repoPath}/.gitignore`, stamps),\n\t\t\t\tthis.loadNested(stamps),\n\t\t\t\tconfig,\n\t\t\t\tinfoExcludePath,\n\t\t\t]);\n\n\t\t// Only commit results if no newer refresh has started\n\t\tif (id !== this._generation.current) return;\n\n\t\tconst options = { ignorecase: getSettledValue(configResult)?.ignoreCase ?? defaultIgnoreCase };\n\n\t\t// Added in git's precedence order (lowest first), since the last matching pattern wins\n\t\tconst ig = ignore(options);\n\t\tfor (const content of [\n\t\t\tgetSettledValue(globalResult),\n\t\t\tgetSettledValue(infoResult),\n\t\t\tgetSettledValue(rootResult),\n\t\t]) {\n\t\t\tif (!content) continue;\n\n\t\t\ttry {\n\t\t\t\tig.add(content);\n\t\t\t} catch {\n\t\t\t\t// A source `ignore` can't parse is skipped rather than failing the whole load\n\t\t\t}\n\t\t}\n\n\t\tlet nested: Map<string, Ignore> | undefined;\n\t\tconst nestedContents = getSettledValue(nestedResult);\n\t\tif (nestedContents?.size) {\n\t\t\tnested = new Map();\n\t\t\tfor (const [dir, content] of nestedContents) {\n\t\t\t\ttry {\n\t\t\t\t\tnested.set(dir, ignore(options).add(content));\n\t\t\t\t} catch {\n\t\t\t\t\t// A file `ignore` can't parse is skipped rather than failing the whole load\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.ig = ig;\n\t\tthis.nested = nested?.size ? nested : undefined;\n\t\tthis.sources = {\n\t\t\tignoreCase: options.ignorecase,\n\t\t\tglobalExcludesPath: getSettledValue(configResult)?.globalExcludesPath,\n\t\t\tinfoExcludePath: getSettledValue(infoPathResult),\n\t\t\tstamps: stamps,\n\t\t};\n\t}\n\n\t/** Whether anything {@link loadPatterns} built `sources` from differs now; a source that can't be stat'ed has */\n\tprivate async sourcesChanged(sources: LoadedSources): Promise<boolean> {\n\t\tconst [config, infoExcludePath, unchanged] = await Promise.allSettled([\n\t\t\tthis.getConfig(),\n\t\t\tthis.resolveInfoExcludePath(),\n\t\t\tPromise.allSettled(\n\t\t\t\tArray.from(\n\t\t\t\t\tsources.stamps,\n\t\t\t\t\tasync ([path, stamp]) => stamp != null && stamp === (await this.stamp(path)),\n\t\t\t\t),\n\t\t\t),\n\t\t]);\n\n\t\treturn (\n\t\t\tgetSettledValue(config)?.globalExcludesPath !== sources.globalExcludesPath ||\n\t\t\tgetSettledValue(infoExcludePath) !== sources.infoExcludePath ||\n\t\t\t(getSettledValue(config)?.ignoreCase ?? defaultIgnoreCase) !== sources.ignoreCase ||\n\t\t\tgetSettledValue(unchanged)?.every(r => getSettledValue(r) === true) !== true\n\t\t);\n\t}\n\n\t/** Reads every nested `.gitignore`, keyed by its repo-relative directory (no trailing slash) */\n\tprivate async loadNested(stamps: Map<string, string | undefined>): Promise<Map<string, string> | undefined> {\n\t\tif (this.getGitIgnorePaths == null) return undefined;\n\n\t\tlet paths: readonly string[];\n\t\ttry {\n\t\t\tpaths = await this.getGitIgnorePaths();\n\t\t} catch {\n\t\t\t// Discovery failed — fall back to the root `.gitignore` alone\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst suffix = '/.gitignore';\n\t\tconst dirs = new Set<string>();\n\t\tfor (const path of paths) {\n\t\t\t// The root `.gitignore` (no directory) is loaded with the other root sources\n\t\t\tif (path.length <= suffix.length || !path.endsWith(suffix)) continue;\n\n\t\t\tdirs.add(path.slice(0, -suffix.length));\n\t\t}\n\t\tif (!dirs.size) return undefined;\n\n\t\tconst entries = await Promise.allSettled(\n\t\t\tArray.from(dirs, async dir => {\n\t\t\t\tconst content = await this.readSource(`${this.repoPath}/${dir}${suffix}`, stamps);\n\t\t\t\treturn content ? ([dir, content] as const) : undefined;\n\t\t\t}),\n\t\t);\n\n\t\tconst nested = new Map<string, string>();\n\t\tfor (const entry of entries) {\n\t\t\tconst value = getSettledValue(entry);\n\t\t\tif (value != null) {\n\t\t\t\tnested.set(value[0], value[1]);\n\t\t\t}\n\t\t}\n\t\treturn nested;\n\t}\n\n\t/** Stamps an ignore file, then reads it — stamped first, so an edit landing in between reads as a change later */\n\tprivate async readSource(\n\t\tpath: string | undefined,\n\t\tstamps: Map<string, string | undefined>,\n\t): Promise<string | undefined> {\n\t\tif (path == null) return undefined;\n\n\t\tstamps.set(path, await this.stamp(path));\n\t\treturn this.readFile(path);\n\t}\n\n\t/** `mtime:size`, `''` when the file is absent, or undefined when it can't be stat'ed */\n\tprivate async stamp(path: string): Promise<string | undefined> {\n\t\ttry {\n\t\t\tconst stat = await this.fs.stat(fileUri(path));\n\t\t\treturn stat != null ? `${stat.mtime}:${stat.size}` : '';\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate async readFile(path: string): Promise<string | undefined> {\n\t\ttry {\n\t\t\tconst data = await this.fs.readFile(fileUri(path));\n\t\t\treturn new TextDecoder().decode(data);\n\t\t} catch {\n\t\t\t// File might not exist or be unreadable — that's fine\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate async resolveInfoExcludePath(): Promise<string | undefined> {\n\t\tif (this.getInfoExcludePath == null) return `${this.gitDirPath}/info/exclude`;\n\n\t\ttry {\n\t\t\treturn await this.getInfoExcludePath();\n\t\t} catch {\n\t\t\t// The git dir couldn't be resolved\n\t\t\treturn undefined;\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;AAaA,MAAM,oBAAoB,CAAC;;;;;;;;;;;;;;AA4D3B,IAAa,kBAAb,MAA6B;CAC5B,KAAqB,OAAO,EAAE,YAAY,kBAAkB,CAAC;;CAE7D;;CAEA;;CAEA;;CAEA;;CAEA;CACA;CACA,cAA+B,iBAAiB;CAGhD,mBAA8C,CAAC;CAC/C,gBAA2C,CAAC;CAE5C;CACA;CACA;CACA;CACA;CACA;CACA;CAEA,IAAI,sBAA+B;EAClC,OAAO,KAAK,oBAAoB;CACjC;CAEA,YAAY,SAAiC;EAC5C,KAAK,WAAW,QAAQ;EACxB,KAAK,aAAa,QAAQ;EAC1B,KAAK,KAAK,QAAQ;EAClB,KAAK,YAAY,YAAY;GAC5B,IAAI,QAAQ,aAAa,MAAM,OAAO,QAAQ,UAAU;GAExD,MAAM,CAAC,MAAM,cAAc,MAAM,QAAQ,WAAW,CACnD,QAAQ,QAAQ,CAAC,CAAC,WAAW,QAAQ,wBAAwB,CAAC,GAC9D,QAAQ,QAAQ,CAAC,CAAC,WAAW,QAAQ,gBAAgB,CAAC,CACvD,CAAC;GACD,OAAO;IAAE,oBAAoB,gBAAgB,IAAI;IAAG,YAAY,gBAAgB,UAAU;GAAE;EAC7F;EACA,KAAK,mBAAmB,QAAQ;EAChC,KAAK,qBAAqB,QAAQ;EAClC,KAAK,oBAAoB,QAAQ;EAGjC,KAAU,UAAU;CACrB;;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BAAS,IAAI,IAAoB;EACvC,KAAK,MAAM,SAAS,SAAS;GAC5B,MAAM,QAAQ,gBAAgB,KAAK;GACnC,IAAI,SAAS,MACZ,OAAO,IAAI,MAAM,IAAI,MAAM,EAAE;EAE/B;EACA,OAAO;CACR;;CAGA,MAAc,WACb,MACA,QAC8B;EAC9B,IAAI,QAAQ,MAAM,OAAO,KAAA;EAEzB,OAAO,IAAI,MAAM,MAAM,KAAK,MAAM,IAAI,CAAC;EACvC,OAAO,KAAK,SAAS,IAAI;CAC1B;;CAGA,MAAc,MAAM,MAA2C;EAC9D,IAAI;GACH,MAAM,OAAO,MAAM,KAAK,GAAG,KAAK,QAAQ,IAAI,CAAC;GAC7C,OAAO,QAAQ,OAAO,GAAG,KAAK,MAAM,GAAG,KAAK,SAAS;EACtD,QAAQ;GACP;EACD;CACD;CAEA,MAAc,SAAS,MAA2C;EACjE,IAAI;GACH,MAAM,OAAO,MAAM,KAAK,GAAG,SAAS,QAAQ,IAAI,CAAC;GACjD,OAAO,IAAI,YAAY,CAAC,CAAC,OAAO,IAAI;EACrC,QAAQ;GAEP;EACD;CACD;CAEA,MAAc,yBAAsD;EACnE,IAAI,KAAK,sBAAsB,MAAM,OAAO,GAAG,KAAK,WAAW;EAE/D,IAAI;GACH,OAAO,MAAM,KAAK,mBAAmB;EACtC,QAAQ;GAEP;EACD;CACD;AACD"}
|
|
@@ -23,9 +23,13 @@ export type GitIgnoreRefreshReason = 'initial' | 'worktree' | 'metadata' | 'reco
|
|
|
23
23
|
export interface GitIgnoreWatchInputs {
|
|
24
24
|
readonly infoExcludePath: string;
|
|
25
25
|
readonly excludesFilePath: string | null;
|
|
26
|
+
/** Absolute system and global Git config candidates, including missing files. An empty array confirms none apply. */
|
|
27
|
+
readonly configWatchPaths?: readonly string[];
|
|
26
28
|
readonly ignoreCase: boolean;
|
|
27
29
|
/** Checkout-relative directories, with `/` separators and no trailing slash. Fixed exclusions take precedence. */
|
|
28
30
|
readonly protectedDirectories: readonly string[];
|
|
31
|
+
/** Literal, slash-separated indexed entries matched by Git ignores, relative to this checkout. Absent for legacy inputs. */
|
|
32
|
+
readonly protectedPaths?: readonly string[];
|
|
29
33
|
}
|
|
30
34
|
/** A working-tree watch with provider-managed Git ignore pruning. */
|
|
31
35
|
export interface GitIgnoringFileWatcher extends FileWatcher {
|
|
@@ -57,8 +61,8 @@ export interface FileWatcherOptions {
|
|
|
57
61
|
*/
|
|
58
62
|
readonly excludes?: readonly string[];
|
|
59
63
|
/**
|
|
60
|
-
* Reports this watcher's {@link FileWatcherReliability} whenever it changes; passed
|
|
61
|
-
*
|
|
64
|
+
* Reports this watcher's {@link FileWatcherReliability} whenever it changes; passed for polling and for working-tree and metadata watches
|
|
65
|
+
* with tracked pruning support. May be called synchronously inside `createWatcher`, and again later
|
|
62
66
|
* (a watch going down, or coming back). Each watcher reports its own state, so one created on a path that is
|
|
63
67
|
* already down reports `unwatchable` itself. Going from `unwatchable` to anything else makes core rescan.
|
|
64
68
|
*/
|
|
@@ -67,7 +71,7 @@ export interface FileWatcherOptions {
|
|
|
67
71
|
* Called once, when a watch the provider places asynchronously goes live: whatever changed under `basePath` between
|
|
68
72
|
* `createWatcher` and then went unseen, so core rescans. A provider whose watch is live when `createWatcher` returns
|
|
69
73
|
* needn't call it, unless it declares `callsOnDidStart`: then it calls it inside `createWatcher`, which costs no
|
|
70
|
-
* rescan.
|
|
74
|
+
* rescan. Also passed to metadata watches for providers declaring supportsTrackedGitIgnorePaths.
|
|
71
75
|
*/
|
|
72
76
|
readonly onDidStart?: () => void;
|
|
73
77
|
}
|
|
@@ -97,6 +101,17 @@ export interface FileWatchingProvider {
|
|
|
97
101
|
* set for a provider that can use it.
|
|
98
102
|
*/
|
|
99
103
|
readonly supportsExcludes?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Preserves events for protectedPaths and their ancestors (including renames), subject to fixed exclusions.
|
|
106
|
+
* Honor ignoreCase and literal path characters. Acknowledge each metadata and delegated watch via onDidStart
|
|
107
|
+
* once live, and report each watch’s reliability changes even without polling. Observe configWatchPaths and the
|
|
108
|
+
* effective excludesFilePath across creation, removal and atomic replacement before acknowledging a refresh.
|
|
109
|
+
* Report external source changes via overflow so Core can refresh both rules and tracked paths. Reject a
|
|
110
|
+
* refresh when coverage is incomplete. Report discovered nested `.gitignore` files, including those in moved
|
|
111
|
+
* or imported directories and those discovered lazily, or signal overflow. New rules may already have pruned
|
|
112
|
+
* events before discovery. Core reconciles the checkout after refreshing its protections.
|
|
113
|
+
*/
|
|
114
|
+
readonly supportsTrackedGitIgnorePaths?: boolean;
|
|
100
115
|
/**
|
|
101
116
|
* True when the provider calls `options.onDidStart` for every working-tree watch once it goes live (unless the watch
|
|
102
117
|
* reports `unwatchable` first). Core then leaves to that rescan what it would otherwise read at once (a newly
|
|
@@ -19,8 +19,9 @@ export interface WatchGroupHooks {
|
|
|
19
19
|
* worktree's HEAD may have moved.
|
|
20
20
|
*/
|
|
21
21
|
readonly onRepoChanged: (repoPath: string, changes: RepositoryChange[], ref?: string | false, overflow?: boolean, configBranches?: ReadonlySet<string>, movedWorktree?: string) => void;
|
|
22
|
+
readonly onMetadataCoverageChanged?: (live: boolean) => void;
|
|
22
23
|
readonly onFetchHeadChanged?: (repoPath: string) => void;
|
|
23
|
-
readonly onIgnoresChanged?: (repoPath: string) => void;
|
|
24
|
+
readonly onIgnoresChanged?: (repoPath: string, overflow?: boolean) => void;
|
|
24
25
|
/** The refs whose loose files a poll stats for this session, read at each poll */
|
|
25
26
|
readonly getProbeRefs?: () => Iterable<string>;
|
|
26
27
|
/** A watcher this session hears through went `unwatchable`, or stopped being it (see {@link WatchGroup.isUnwatchable}) */
|
|
@@ -39,6 +40,8 @@ interface SessionEntry {
|
|
|
39
40
|
/** For a linked session, its `<n>` in `<common>/worktrees/<n>`; otherwise `undefined` */
|
|
40
41
|
readonly worktreeId: string | undefined;
|
|
41
42
|
readonly hooks: WatchGroupHooks;
|
|
43
|
+
metadataLive: boolean;
|
|
44
|
+
coverage: boolean;
|
|
42
45
|
reliability: FileWatcherReliability;
|
|
43
46
|
/** Polls in place of (or beside) the root watcher while it isn't `reliable` */
|
|
44
47
|
target?: GitDirProbeTarget;
|
|
@@ -111,6 +114,7 @@ export declare class WatchGroup implements UnifiedDisposable {
|
|
|
111
114
|
*/
|
|
112
115
|
private readonly readDirectory?;
|
|
113
116
|
private readonly _sessions;
|
|
117
|
+
private _commonLive;
|
|
114
118
|
private _commonWatcher;
|
|
115
119
|
private _commonReliability;
|
|
116
120
|
private _commonTarget;
|
|
@@ -200,7 +204,8 @@ export declare class WatchGroup implements UnifiedDisposable {
|
|
|
200
204
|
private endAllRetiring;
|
|
201
205
|
private isRetiringTarget;
|
|
202
206
|
private disposeCommonWatcher;
|
|
203
|
-
|
|
207
|
+
hasLiveMetadataCoverage(repoPath: string): boolean;
|
|
208
|
+
private updateMetadataCoverage;
|
|
204
209
|
private getWatcherOptions;
|
|
205
210
|
/**
|
|
206
211
|
* The ignored worktrees' folders join the `.git` excludes of a watcher over the common git dir: a tool that keeps its
|
|
@@ -89,6 +89,7 @@ var WatchGroup = class {
|
|
|
89
89
|
readFile;
|
|
90
90
|
readDirectory;
|
|
91
91
|
_sessions = /* @__PURE__ */ new Map();
|
|
92
|
+
_commonLive = false;
|
|
92
93
|
_commonWatcher;
|
|
93
94
|
_commonReliability = "reliable";
|
|
94
95
|
_commonTarget;
|
|
@@ -190,6 +191,7 @@ var WatchGroup = class {
|
|
|
190
191
|
const rootPattern = isStandard ? dotGitGlobCombined : dotGitGlobRoot;
|
|
191
192
|
const commonReliability = isStandard ? this.getCommonReliability() : void 0;
|
|
192
193
|
let entry;
|
|
194
|
+
let metadataLive = false;
|
|
193
195
|
let initialReliability = "reliable";
|
|
194
196
|
const rootWatcher = this.provider.createWatcher(gitDir.uri.fsPath, rootPattern, (event) => {
|
|
195
197
|
if (entry == null) return;
|
|
@@ -200,6 +202,12 @@ var WatchGroup = class {
|
|
|
200
202
|
}, this.getWatcherOptions(gitDir.uri.fsPath, (state) => {
|
|
201
203
|
if (entry == null) initialReliability = state;
|
|
202
204
|
else if (this._sessions.get(repoPath) === entry) this.setRootReliability(entry, state);
|
|
205
|
+
}, (live) => {
|
|
206
|
+
metadataLive = live;
|
|
207
|
+
if (entry != null && this._sessions.get(repoPath) === entry) {
|
|
208
|
+
entry.metadataLive = live;
|
|
209
|
+
this.updateMetadataCoverage();
|
|
210
|
+
}
|
|
203
211
|
}));
|
|
204
212
|
const entryGitDirPath = gitDir.uri.fsPath;
|
|
205
213
|
entry = {
|
|
@@ -209,6 +217,8 @@ var WatchGroup = class {
|
|
|
209
217
|
coversCommon: isStandard,
|
|
210
218
|
worktreeId: isStandard ? void 0 : this.getWorktreeId(entryGitDirPath),
|
|
211
219
|
hooks,
|
|
220
|
+
metadataLive,
|
|
221
|
+
coverage: false,
|
|
212
222
|
reliability: "reliable"
|
|
213
223
|
};
|
|
214
224
|
this._sessions.set(repoPath, entry);
|
|
@@ -217,6 +227,7 @@ var WatchGroup = class {
|
|
|
217
227
|
this.retireCommonWatcher();
|
|
218
228
|
this.handOverCommon(commonReliability);
|
|
219
229
|
} else if (!some(this._sessions.values(), (e) => e.coversCommon)) this.ensureCommonWatcher();
|
|
230
|
+
this.updateMetadataCoverage();
|
|
220
231
|
}
|
|
221
232
|
/** Remove a session from this group. Disposes its root watcher. */
|
|
222
233
|
removeSession(repoPath) {
|
|
@@ -236,6 +247,7 @@ var WatchGroup = class {
|
|
|
236
247
|
this.disposeCommonWatcher();
|
|
237
248
|
this.endAllRetiring();
|
|
238
249
|
} else if (commonReliability != null) this.handOverCommon(commonReliability);
|
|
250
|
+
this.updateMetadataCoverage();
|
|
239
251
|
}
|
|
240
252
|
getWorktreeId(gitDirPath) {
|
|
241
253
|
return getWorktreeAdminId(gitDirPath, this.commonGitDir);
|
|
@@ -245,14 +257,22 @@ var WatchGroup = class {
|
|
|
245
257
|
if (this._commonWatcher != null || this._disposed) return;
|
|
246
258
|
let watcher;
|
|
247
259
|
let initialReliability = "reliable";
|
|
260
|
+
let metadataLive = false;
|
|
248
261
|
const options = this.getWatcherOptions(this.commonGitDir, (state) => {
|
|
249
262
|
if (watcher == null) initialReliability = state;
|
|
250
263
|
else if (this._commonWatcher === watcher) this.setCommonReliability(state);
|
|
264
|
+
}, (live) => {
|
|
265
|
+
metadataLive = live;
|
|
266
|
+
if (watcher != null && this._commonWatcher === watcher) {
|
|
267
|
+
this._commonLive = live;
|
|
268
|
+
this.updateMetadataCoverage();
|
|
269
|
+
}
|
|
251
270
|
});
|
|
252
271
|
watcher = this.provider.createWatcher(this.commonGitDir, dotGitGlobCommon, (event) => {
|
|
253
272
|
if (event.reason !== "overflow") this._commonTarget?.forget(event.path);
|
|
254
273
|
this.onCommonEvent(event);
|
|
255
274
|
}, options);
|
|
275
|
+
this._commonLive = metadataLive;
|
|
256
276
|
this._commonWatcher = watcher;
|
|
257
277
|
if (initialReliability !== "reliable") {
|
|
258
278
|
if (handingOver) this.setCommonPolling(initialReliability);
|
|
@@ -306,9 +326,37 @@ var WatchGroup = class {
|
|
|
306
326
|
this._commonTarget = void 0;
|
|
307
327
|
}
|
|
308
328
|
}
|
|
309
|
-
|
|
310
|
-
|
|
329
|
+
hasLiveMetadataCoverage(repoPath) {
|
|
330
|
+
return this._sessions.get(repoPath)?.coverage === true;
|
|
331
|
+
}
|
|
332
|
+
updateMetadataCoverage() {
|
|
333
|
+
if (!this.provider.supportsTrackedGitIgnorePaths) return;
|
|
334
|
+
const commonLive = this._commonWatcher != null && this._commonLive || some(this._sessions.values(), (entry) => entry.coversCommon && entry.metadataLive);
|
|
335
|
+
for (const entry of this._sessions.values()) {
|
|
336
|
+
const covered = entry.metadataLive && commonLive;
|
|
337
|
+
if (entry.coverage === covered) continue;
|
|
338
|
+
entry.coverage = covered;
|
|
339
|
+
entry.hooks.onMetadataCoverageChanged?.(covered);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
getWatcherOptions(basePath, onDidChangeReliability, onCoverage) {
|
|
311
343
|
const excludes = this.getExcludes(basePath);
|
|
344
|
+
if (this.provider.supportsTrackedGitIgnorePaths) {
|
|
345
|
+
let started = false;
|
|
346
|
+
let reliable = true;
|
|
347
|
+
return {
|
|
348
|
+
excludes,
|
|
349
|
+
onDidStart: () => {
|
|
350
|
+
started = true;
|
|
351
|
+
onCoverage(reliable);
|
|
352
|
+
},
|
|
353
|
+
onDidChangeReliability: (state) => {
|
|
354
|
+
reliable = state === "reliable";
|
|
355
|
+
onCoverage(started && reliable);
|
|
356
|
+
if (this.poller != null) onDidChangeReliability(state);
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
}
|
|
312
360
|
return this.poller != null ? {
|
|
313
361
|
excludes,
|
|
314
362
|
onDidChangeReliability
|
|
@@ -476,7 +524,7 @@ var WatchGroup = class {
|
|
|
476
524
|
deliverOverflow(entry) {
|
|
477
525
|
entry.hooks.onRepoChanged(entry.repoPath, [...allWatchedRepositoryChanges], void 0, true);
|
|
478
526
|
entry.hooks.onFetchHeadChanged?.(entry.repoPath);
|
|
479
|
-
entry.hooks.onIgnoresChanged?.(entry.repoPath);
|
|
527
|
+
entry.hooks.onIgnoresChanged?.(entry.repoPath, true);
|
|
480
528
|
}
|
|
481
529
|
onRootEvent(event, entry) {
|
|
482
530
|
if (event.reason === "overflow") {
|