@gitkraken/core-gitlens 0.37.1 → 0.38.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +69 -1
- package/dist/git/cache.d.ts +128 -8
- package/dist/git/cache.js +425 -46
- package/dist/git/cache.js.map +1 -1
- package/dist/git/features.d.ts +1 -1
- package/dist/git/features.js +3 -0
- package/dist/git/features.js.map +1 -1
- package/dist/git/providers/branches.d.ts +42 -1
- package/dist/git/providers/diff.d.ts +17 -0
- package/dist/git/providers/provider.d.ts +7 -0
- package/dist/git/providers/shared/remotes.js +8 -4
- package/dist/git/providers/shared/remotes.js.map +1 -1
- package/dist/git/remotes/matcher.js +2 -2
- package/dist/git/remotes/matcher.js.map +1 -1
- package/dist/git/repositoryService.d.ts +16 -1
- package/dist/git/repositoryService.js +51 -3
- package/dist/git/repositoryService.js.map +1 -1
- package/dist/git/run.types.d.ts +1 -0
- package/dist/git/service.js +6 -2
- package/dist/git/service.js.map +1 -1
- package/dist/git/utils/fileStatus.utils.d.ts +5 -0
- package/dist/git/utils/fileStatus.utils.js +18 -1
- package/dist/git/utils/fileStatus.utils.js.map +1 -1
- package/dist/git/watching/changeEvent.d.ts +13 -3
- package/dist/git/watching/changeEvent.js +15 -4
- package/dist/git/watching/changeEvent.js.map +1 -1
- package/dist/git/watching/changeOrdinal.d.ts +9 -0
- package/dist/git/watching/changeOrdinal.js +14 -0
- package/dist/git/watching/changeOrdinal.js.map +1 -0
- package/dist/git/watching/unwatchedCacheValidator.d.ts +38 -5
- package/dist/git/watching/unwatchedCacheValidator.js +180 -36
- package/dist/git/watching/unwatchedCacheValidator.js.map +1 -1
- package/dist/git/watching/watchGroup.d.ts +63 -14
- package/dist/git/watching/watchGroup.js +213 -74
- package/dist/git/watching/watchGroup.js.map +1 -1
- package/dist/git/watching/watchService.js +4 -3
- package/dist/git/watching/watchService.js.map +1 -1
- package/dist/git/watching/watchSession.d.ts +10 -2
- package/dist/git/watching/watchSession.js +18 -4
- package/dist/git/watching/watchSession.js.map +1 -1
- package/dist/git/watching/watcherPatterns.d.ts +18 -4
- package/dist/git/watching/watcherPatterns.js +39 -8
- package/dist/git/watching/watcherPatterns.js.map +1 -1
- package/dist/git/watching/worktreeSummary.d.ts +23 -12
- package/dist/git/watching/worktreeSummary.js +164 -41
- package/dist/git/watching/worktreeSummary.js.map +1 -1
- package/dist/git-cli/cliGitProvider.d.ts +1 -0
- package/dist/git-cli/cliGitProvider.js +11 -2
- package/dist/git-cli/cliGitProvider.js.map +1 -1
- package/dist/git-cli/exec/git.d.ts +7 -2
- package/dist/git-cli/exec/git.js +46 -10
- package/dist/git-cli/exec/git.js.map +1 -1
- package/dist/git-cli/exec/headState.d.ts +24 -0
- package/dist/git-cli/exec/headState.js +46 -6
- package/dist/git-cli/exec/headState.js.map +1 -1
- package/dist/git-cli/parsers/logParser.js +6 -3
- package/dist/git-cli/parsers/logParser.js.map +1 -1
- package/dist/git-cli/providers/branches.d.ts +135 -10
- package/dist/git-cli/providers/branches.js +622 -80
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/dist/git-cli/providers/commits.d.ts +16 -0
- package/dist/git-cli/providers/commits.js +80 -28
- package/dist/git-cli/providers/commits.js.map +1 -1
- package/dist/git-cli/providers/config.d.ts +10 -0
- package/dist/git-cli/providers/config.js +50 -12
- package/dist/git-cli/providers/config.js.map +1 -1
- package/dist/git-cli/providers/contributors.js +11 -7
- package/dist/git-cli/providers/contributors.js.map +1 -1
- package/dist/git-cli/providers/diff.d.ts +12 -0
- package/dist/git-cli/providers/diff.js +107 -15
- package/dist/git-cli/providers/diff.js.map +1 -1
- package/dist/git-cli/providers/graph.js +32 -25
- package/dist/git-cli/providers/graph.js.map +1 -1
- package/dist/git-cli/providers/operations.d.ts +37 -3
- package/dist/git-cli/providers/operations.js +124 -46
- package/dist/git-cli/providers/operations.js.map +1 -1
- package/dist/git-cli/providers/patch.js +1 -1
- package/dist/git-cli/providers/patch.js.map +1 -1
- package/dist/git-cli/providers/refs.d.ts +1 -1
- package/dist/git-cli/providers/refs.js +10 -11
- package/dist/git-cli/providers/refs.js.map +1 -1
- package/dist/git-cli/providers/status.d.ts +4 -5
- package/dist/git-cli/providers/status.js +36 -33
- package/dist/git-cli/providers/status.js.map +1 -1
- package/dist/git-cli/providers/tags.d.ts +8 -0
- package/dist/git-cli/providers/tags.js +53 -34
- package/dist/git-cli/providers/tags.js.map +1 -1
- package/dist/git-cli/service.d.ts +15 -0
- package/dist/git-cli/service.js +19 -1
- package/dist/git-cli/service.js.map +1 -1
- package/dist/plus/git-github/providers/github/diff.d.ts +1 -0
- package/dist/plus/git-github/providers/github/diff.js +6 -1
- package/dist/plus/git-github/providers/github/diff.js.map +1 -1
- package/dist/plus/integrations/integrationService.js +9 -0
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/providers/jira-server.js +1 -1
- package/dist/plus/integrations/providers/jira-server.js.map +1 -1
- package/dist/plus/integrations/providers/jira.d.ts +20 -9
- package/dist/plus/integrations/providers/jira.js +114 -99
- package/dist/plus/integrations/providers/jira.js.map +1 -1
- package/dist/plus/integrations/providers/linear.d.ts +11 -4
- package/dist/plus/integrations/providers/linear.js +75 -32
- package/dist/plus/integrations/providers/linear.js.map +1 -1
- package/dist/plus/integrations/providers/utils/discoveryCache.d.ts +35 -4
- package/dist/plus/integrations/providers/utils/discoveryCache.js +45 -11
- package/dist/plus/integrations/providers/utils/discoveryCache.js.map +1 -1
- package/dist/utils/env/node/exec.d.ts +8 -4
- package/dist/utils/env/node/exec.js +115 -9
- package/dist/utils/env/node/exec.js.map +1 -1
- package/dist/utils/holdOffMap.d.ts +23 -0
- package/dist/utils/holdOffMap.js +43 -0
- package/dist/utils/holdOffMap.js.map +1 -0
- package/dist/utils/promiseCache.d.ts +15 -2
- package/dist/utils/promiseCache.js +34 -4
- package/dist/utils/promiseCache.js.map +1 -1
- package/package.json +1 -1
|
@@ -25,6 +25,21 @@ const validationWindowMs = 250;
|
|
|
25
25
|
const unresolvableRetryMs = 3e4;
|
|
26
26
|
/** Targets kept per kind; one dropped just takes a new baseline */
|
|
27
27
|
const maxTargets = 512;
|
|
28
|
+
/**
|
|
29
|
+
* Other worktrees' first baselines one validation takes with its own. Their stats run one at a time per repository
|
|
30
|
+
* inside the read that triggered them, so the batch is kept small enough that a slow file system doesn't push that read
|
|
31
|
+
* past its timeout; the worktrees left out batch the rest at their own first validation. Never more than fit under
|
|
32
|
+
* {@link maxTargets}, as a target dropped for them would clear the shared entries again
|
|
33
|
+
*/
|
|
34
|
+
const maxSiblingBaselines = 64;
|
|
35
|
+
/**
|
|
36
|
+
* Linked worktrees' first baselines one validation clears only their own entries for, when the common git dir vouches
|
|
37
|
+
* for each one's HEAD; past it, they clear the shared entries too, once. Clearing the shared entries costs a ref listing,
|
|
38
|
+
* a default branch read and the reader's current branch, and that listing seeds every worktree's current branch again;
|
|
39
|
+
* clearing a worktree's own entries costs it a read of its own current branch. So past a few worktrees, one clear of the
|
|
40
|
+
* shared entries is the cheaper
|
|
41
|
+
*/
|
|
42
|
+
const maxOwnBaselines = 3;
|
|
28
43
|
/** Polls one validation runs to take the baselines of the directories it finds; the next validation resumes from there */
|
|
29
44
|
const maxDiscoveryPolls = 16;
|
|
30
45
|
/**
|
|
@@ -110,7 +125,8 @@ const commonGatedProbes = commonProbes.filter((p) => commonGatedPaths.has(p.path
|
|
|
110
125
|
* files a watcher would have reported (see {@link UnwatchedCacheValidatorOptions.stat}) and applies what moved to the
|
|
111
126
|
* cache as a watcher event would have. Both a worktree's own git dir and the common one are validated while that
|
|
112
127
|
* worktree is unwatched; while another worktree's watcher covers the common one, what moved there clears only the
|
|
113
|
-
* unwatched worktrees' own entries
|
|
128
|
+
* unwatched worktrees' own entries, but for a linked worktree's HEAD moving, which is applied as that worktree's own
|
|
129
|
+
* report would be (see {@link apply}). A repository whose git dir nothing resolved yet is validated once
|
|
114
130
|
* {@link UnwatchedCacheValidatorOptions.resolveGitDir} resolves one; a repository whose files can't show it is looked at
|
|
115
131
|
* again rarely, and one whose resolution failed within the validation window. A read waits at most
|
|
116
132
|
* {@link UnwatchedCacheValidatorOptions.timeoutMs} for a validation (and a resolution before it); one that outlasts it
|
|
@@ -144,7 +160,10 @@ var UnwatchedCacheValidator = class {
|
|
|
144
160
|
resolutions = /* @__PURE__ */ new Map();
|
|
145
161
|
/** The validation {@link onWatched} ran as a watcher attached, by repo path, which reads wait for while it runs */
|
|
146
162
|
handoffs = /* @__PURE__ */ new Map();
|
|
147
|
-
/**
|
|
163
|
+
/**
|
|
164
|
+
* By the repo path of a watched worktree, what moved in its common git dir that its watcher was left to clear, and
|
|
165
|
+
* whether its own HEAD's move, which the common git dir saw, was left to it to report (see {@link applyMovedHeads})
|
|
166
|
+
*/
|
|
148
167
|
deferred = /* @__PURE__ */ new Map();
|
|
149
168
|
constructor(options) {
|
|
150
169
|
this.cache = options.cache;
|
|
@@ -219,15 +238,22 @@ var UnwatchedCacheValidator = class {
|
|
|
219
238
|
}
|
|
220
239
|
/**
|
|
221
240
|
* A watcher left `repoPath`, dropping what it held back unreported. What moved in its common git dir that an
|
|
222
|
-
* unwatched sibling's validation left to it is applied now, since that validation took the shared baseline past it
|
|
223
|
-
*
|
|
241
|
+
* unwatched sibling's validation left to it is applied now, since that validation took the shared baseline past it,
|
|
242
|
+
* and so is its own HEAD's move that the common git dir saw, as its watcher would have reported it; whatever else it
|
|
243
|
+
* dropped is still ahead of its own baselines.
|
|
224
244
|
*/
|
|
225
245
|
onUnwatched(repoPath) {
|
|
226
246
|
const deferred = this.deferred.get(repoPath);
|
|
227
247
|
if (deferred == null) return;
|
|
228
248
|
this.deferred.delete(repoPath);
|
|
229
|
-
|
|
230
|
-
|
|
249
|
+
if (deferred.changes.size) {
|
|
250
|
+
this.cache.onRepositoryChanged(deferred.commonPath, deferred.changes);
|
|
251
|
+
if (repoPath !== deferred.commonPath && this.cache.isRegistered(repoPath)) this.cache.applyRepositoryChanges(repoPath, deferred.changes, "share", { worktreeOnly: true });
|
|
252
|
+
}
|
|
253
|
+
if (deferred.headMoved) {
|
|
254
|
+
const registered = this.cache.getCommonPath(repoPath) === deferred.commonPath;
|
|
255
|
+
this.cache.onRepositoryChanged(registered ? repoPath : deferred.commonPath, ["head", "heads"]);
|
|
256
|
+
}
|
|
231
257
|
}
|
|
232
258
|
run(repoPath, force) {
|
|
233
259
|
if (!force && this.isWatched(repoPath)) return void 0;
|
|
@@ -243,6 +269,7 @@ var UnwatchedCacheValidator = class {
|
|
|
243
269
|
for (const [path, deferred] of this.deferred) if (deferred.commonPath === commonPath && !this.isWatched(path)) this.onUnwatched(path);
|
|
244
270
|
const commonGitDir = (gitDir.commonUri ?? gitDir.uri).fsPath;
|
|
245
271
|
const root = this.getTarget(this.roots, repoPath, "root", gitDir.uri.fsPath, commonPath, commonGitDir);
|
|
272
|
+
const siblings = root.runs === 0 ? this.getSiblingTargets(repoPath, commonPath, commonGitDir) : [];
|
|
246
273
|
const common = this.getTarget(this.commons, commonPath, "common", commonGitDir, commonPath, commonGitDir);
|
|
247
274
|
const waits = [];
|
|
248
275
|
const previous = [];
|
|
@@ -263,10 +290,15 @@ var UnwatchedCacheValidator = class {
|
|
|
263
290
|
const startedRoot = start(root);
|
|
264
291
|
const startedCommon = start(common);
|
|
265
292
|
if (startedRoot != null || startedCommon != null) {
|
|
266
|
-
const job = this.runTargets(repoPath, commonPath, startedRoot, startedCommon, previous);
|
|
293
|
+
const job = this.runTargets(repoPath, commonPath, startedRoot, startedCommon, common, siblings, previous);
|
|
267
294
|
if (startedRoot != null) startedRoot.running = job;
|
|
268
295
|
if (startedCommon != null) startedCommon.running = job;
|
|
269
|
-
for (const
|
|
296
|
+
for (const [, state] of siblings) state.running = job;
|
|
297
|
+
for (const state of [
|
|
298
|
+
startedRoot,
|
|
299
|
+
startedCommon,
|
|
300
|
+
...siblings.map(([, s]) => s)
|
|
301
|
+
]) if (state != null) waits.push([state, job]);
|
|
270
302
|
}
|
|
271
303
|
return waits;
|
|
272
304
|
}
|
|
@@ -371,18 +403,46 @@ var UnwatchedCacheValidator = class {
|
|
|
371
403
|
}
|
|
372
404
|
return state;
|
|
373
405
|
}
|
|
374
|
-
|
|
406
|
+
/**
|
|
407
|
+
* The root targets, new, of `repoPath`'s registered sibling worktrees that never had one: unwatched (a watcher covers
|
|
408
|
+
* its own git dir, and validates it as it attaches), with a git dir the cache resolved in the same common git dir
|
|
409
|
+
*/
|
|
410
|
+
getSiblingTargets(repoPath, commonPath, commonGitDir) {
|
|
411
|
+
const siblings = [];
|
|
412
|
+
const room = Math.min(maxSiblingBaselines, maxTargets - this.roots.size);
|
|
413
|
+
for (const path of this.cache.getWorktreePaths(commonPath)) {
|
|
414
|
+
if (siblings.length >= room) break;
|
|
415
|
+
if (path === repoPath || this.roots.has(path) || this.isWatched(path)) continue;
|
|
416
|
+
if (this.cache.getCommonPath(path) !== commonPath) continue;
|
|
417
|
+
const gitDir = this.cache.gitDir.get(path);
|
|
418
|
+
if (gitDir == null || (gitDir.commonUri ?? gitDir.uri).fsPath !== commonGitDir) continue;
|
|
419
|
+
siblings.push([path, this.getTarget(this.roots, path, "root", gitDir.uri.fsPath, commonPath, commonGitDir)]);
|
|
420
|
+
}
|
|
421
|
+
return siblings;
|
|
422
|
+
}
|
|
423
|
+
async runTargets(repoPath, commonPath, root, common, commonTarget, siblings, previous) {
|
|
375
424
|
const rootRun = root != null ? ++root.runs : 0;
|
|
376
425
|
const commonRun = common != null ? ++common.runs : 0;
|
|
426
|
+
const siblingRuns = siblings.map(([, state]) => ++state.runs);
|
|
377
427
|
const watchedAtStart = new Set(this.getCommonWatchers(repoPath, commonPath));
|
|
378
428
|
try {
|
|
379
429
|
if (previous.length) await Promise.all(previous);
|
|
380
430
|
const memo = /* @__PURE__ */ new Map();
|
|
381
|
-
const [rootResult, commonResult] = await Promise.all([
|
|
431
|
+
const [rootResult, commonResult, siblingResults] = await Promise.all([
|
|
432
|
+
root?.dir.validate(memo, repoPath),
|
|
433
|
+
common?.dir.validate(memo, repoPath),
|
|
434
|
+
Promise.all(siblings.map(([path, state]) => state.dir.validate(memo, path)))
|
|
435
|
+
]);
|
|
382
436
|
this.counts.validations++;
|
|
383
437
|
if (rootResult?.changes.size || commonResult?.changes.size) this.counts.validationsApplied++;
|
|
384
|
-
this.apply(repoPath, commonPath, rootResult, commonResult,
|
|
385
|
-
|
|
438
|
+
this.apply(repoPath, commonPath, rootResult, commonResult, commonTarget.dir, siblings.map(([path, state], i) => [
|
|
439
|
+
path,
|
|
440
|
+
state,
|
|
441
|
+
siblingResults[i]
|
|
442
|
+
]), watchedAtStart);
|
|
443
|
+
} catch {
|
|
444
|
+
for (const [, state] of siblings) state.dir.reset();
|
|
445
|
+
} finally {
|
|
386
446
|
const settledAt = this.now();
|
|
387
447
|
if (root != null) {
|
|
388
448
|
root.settledAt = settledAt;
|
|
@@ -392,32 +452,47 @@ var UnwatchedCacheValidator = class {
|
|
|
392
452
|
common.settledAt = settledAt;
|
|
393
453
|
if (common.runs === commonRun) common.running = void 0;
|
|
394
454
|
}
|
|
455
|
+
for (const [i, [, state]] of siblings.entries()) if (state.runs === siblingRuns[i]) state.running = void 0;
|
|
395
456
|
}
|
|
396
457
|
}
|
|
397
458
|
/**
|
|
398
459
|
* Applies what moved to `repoPath`, and what moved in the common git dir to its other unwatched registered worktrees
|
|
399
460
|
* too, as the common watcher would have told each of them. While another worktree's watcher covers the common git
|
|
400
461
|
* dir, it already cleared the shared entries, so only the worktrees' own are. A watcher covers it only if it watched
|
|
401
|
-
* since before the stats began (`watchedAtStart`)
|
|
462
|
+
* since before the stats began (`watchedAtStart`). What each sibling whose first baseline was taken with it reports
|
|
463
|
+
* clears that sibling's own entries, as `repoPath`'s report cleared the shared ones.
|
|
464
|
+
*
|
|
465
|
+
* Once the common git dir (`commonDir`) holds a reading of a linked worktree's HEAD, it reports that HEAD's every
|
|
466
|
+
* move, and a commit on its branch as a ref directory moving. Each such move clears the shared entries, as that
|
|
467
|
+
* worktree's own report would (see {@link applyMovedHeads}), or is left to its watcher, which reports it or has it
|
|
468
|
+
* applied as it leaves. So nothing the shared entries hold of that worktree can go stale unseen: its first report (or
|
|
469
|
+
* its first after a reset) clears only its own entries, for up to {@link maxOwnBaselines} of them
|
|
402
470
|
*/
|
|
403
|
-
apply(repoPath, commonPath, root, common, watchedAtStart) {
|
|
471
|
+
apply(repoPath, commonPath, root, common, commonDir, siblings, watchedAtStart) {
|
|
404
472
|
const watchers = this.getCommonWatchers(repoPath, commonPath).filter((p) => watchedAtStart.has(p));
|
|
405
473
|
const commonWatched = watchers.length !== 0;
|
|
406
|
-
const
|
|
474
|
+
const own = this.getVouchedBaselines(repoPath, commonPath, root, commonDir, siblings);
|
|
475
|
+
if (common?.noBaseline || own.size > maxOwnBaselines) own.clear();
|
|
476
|
+
const changes = new Set(own.has(repoPath) ? void 0 : root?.changes);
|
|
407
477
|
if (!commonWatched) for (const change of common?.changes ?? []) changes.add(change);
|
|
478
|
+
if (root != null && own.has(repoPath)) this.cache.applyLinkedWorktreeChanges(repoPath, root.changes, "share");
|
|
408
479
|
if (changes.size) this.cache.onRepositoryChanged(repoPath, changes, { movedWorktrees: changes.has("worktreeHead") ? common?.movedWorktrees : void 0 });
|
|
480
|
+
this.applyMovedHeads(repoPath, commonPath, common, watchers, changes.has("head"));
|
|
481
|
+
const shared = this.cache.getCommonPath(repoPath) === commonPath;
|
|
482
|
+
for (const [path, state, result] of siblings) {
|
|
483
|
+
if (!this.cache.isRegistered(path) || this.cache.getCommonPath(path) !== commonPath) {
|
|
484
|
+
state.dir.reset();
|
|
485
|
+
continue;
|
|
486
|
+
}
|
|
487
|
+
if (own.has(path)) this.cache.applyLinkedWorktreeChanges(path, result.changes, "share");
|
|
488
|
+
else if (shared && [...result.changes].every((c) => changes.has(c))) this.cache.applyRepositoryChanges(path, result.changes, "share", { worktreeOnly: true });
|
|
489
|
+
else this.cache.onRepositoryChanged(path, result.changes);
|
|
490
|
+
}
|
|
409
491
|
if (!common?.changes.size) return;
|
|
410
492
|
if (commonWatched) {
|
|
411
493
|
this.cache.applyRepositoryChanges(repoPath, common.changes, "share", { worktreeOnly: true });
|
|
412
494
|
for (const path of watchers) {
|
|
413
|
-
|
|
414
|
-
if (deferred?.commonPath !== commonPath) {
|
|
415
|
-
deferred = {
|
|
416
|
-
commonPath,
|
|
417
|
-
changes: /* @__PURE__ */ new Set()
|
|
418
|
-
};
|
|
419
|
-
this.deferred.set(path, deferred);
|
|
420
|
-
}
|
|
495
|
+
const deferred = this.getDeferred(path, commonPath);
|
|
421
496
|
for (const change of common.changes) deferred.changes.add(change);
|
|
422
497
|
}
|
|
423
498
|
}
|
|
@@ -426,6 +501,61 @@ var UnwatchedCacheValidator = class {
|
|
|
426
501
|
this.cache.applyRepositoryChanges(path, common.changes, "share", { worktreeOnly: true });
|
|
427
502
|
}
|
|
428
503
|
}
|
|
504
|
+
/** What is left to the watcher of `path` until it leaves (see {@link onUnwatched}) */
|
|
505
|
+
getDeferred(path, commonPath) {
|
|
506
|
+
let deferred = this.deferred.get(path);
|
|
507
|
+
if (deferred?.commonPath !== commonPath) {
|
|
508
|
+
deferred = {
|
|
509
|
+
commonPath,
|
|
510
|
+
changes: /* @__PURE__ */ new Set(),
|
|
511
|
+
headMoved: false
|
|
512
|
+
};
|
|
513
|
+
this.deferred.set(path, deferred);
|
|
514
|
+
}
|
|
515
|
+
return deferred;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* The worktrees, of `repoPath` and the `siblings`, whose report without a baseline the common git dir vouches for as
|
|
519
|
+
* of now: each a linked worktree registered under `commonPath` whose HEAD `commonDir` holds a reading of
|
|
520
|
+
*/
|
|
521
|
+
getVouchedBaselines(repoPath, commonPath, root, commonDir, siblings) {
|
|
522
|
+
const vouched = (path) => {
|
|
523
|
+
if (this.cache.getCommonPath(path) !== commonPath) return false;
|
|
524
|
+
const id = this.cache.getLinkedWorktreeId(path);
|
|
525
|
+
return id != null && commonDir.holdsWorktreeHead(id);
|
|
526
|
+
};
|
|
527
|
+
const paths = /* @__PURE__ */ new Set();
|
|
528
|
+
if (root?.noBaseline && vouched(repoPath)) paths.add(repoPath);
|
|
529
|
+
for (const [path, , result] of siblings) if (result.noBaseline && vouched(path)) paths.add(path);
|
|
530
|
+
return paths;
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Applies the common git dir's sighting of linked worktrees' HEADs moving as each worktree's own report would be:
|
|
534
|
+
* the shared entries hold each one's HEAD too (where the branch list places its branch, what a checkout's reflog
|
|
535
|
+
* says a branch was based on), which a `'worktreeHead'` clears nothing of. One whose own watcher covered the common
|
|
536
|
+
* git dir reports it itself, or, should that watcher leave first, has it applied as it leaves. A move not attributed to a registered worktree is applied to `repoPath`, as is a report
|
|
537
|
+
* without a baseline (whose shared entries a watcher of the common git dir cleared, if not `repoPath`'s report),
|
|
538
|
+
* unless what `repoPath`'s report applied in full saw its own HEAD move (`appliedHead`)
|
|
539
|
+
*/
|
|
540
|
+
applyMovedHeads(repoPath, commonPath, common, watchers, appliedHead) {
|
|
541
|
+
if (common == null) return;
|
|
542
|
+
const paths = /* @__PURE__ */ new Set();
|
|
543
|
+
if (common.noBaseline || common.changes.has("worktreeHead") && common.movedWorktrees == null) paths.add(repoPath);
|
|
544
|
+
else if (common.changes.has("worktreeHead")) {
|
|
545
|
+
const pathsById = /* @__PURE__ */ new Map();
|
|
546
|
+
for (const path of this.cache.getWorktreePaths(commonPath)) {
|
|
547
|
+
const id = this.cache.getLinkedWorktreeId(path);
|
|
548
|
+
if (id != null) pathsById.set(id, path);
|
|
549
|
+
}
|
|
550
|
+
for (const id of common.movedWorktrees ?? []) {
|
|
551
|
+
const path = pathsById.get(id) ?? repoPath;
|
|
552
|
+
if (watchers.includes(path)) this.getDeferred(path, commonPath).headMoved = true;
|
|
553
|
+
else paths.add(path);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
if (appliedHead) paths.delete(repoPath);
|
|
557
|
+
for (const path of paths) this.cache.onRepositoryChanged(path, ["head", "heads"]);
|
|
558
|
+
}
|
|
429
559
|
};
|
|
430
560
|
/**
|
|
431
561
|
* Runs file-system calls at most {@link maxFsCalls} at once, and at most {@link maxFsCallsPerRepo} at once for a key;
|
|
@@ -594,24 +724,37 @@ var ProbedGitDir = class {
|
|
|
594
724
|
this.ignoredRoots = void 0;
|
|
595
725
|
}
|
|
596
726
|
if (failed || !this.baselined) {
|
|
597
|
-
if (failed)
|
|
598
|
-
|
|
599
|
-
this.gated.clear();
|
|
600
|
-
this.addGated(gitDirGatePath, this.kind === "root" ? rootGatedProbes : commonGatedProbes);
|
|
601
|
-
this.baselined = false;
|
|
602
|
-
this.refDirs.clear();
|
|
603
|
-
this.worktrees.clear();
|
|
604
|
-
this.pendingDirs.clear();
|
|
605
|
-
this.pendingEntries.clear();
|
|
606
|
-
this.reftable = false;
|
|
607
|
-
} else this.baselined = true;
|
|
727
|
+
if (failed) this.reset();
|
|
728
|
+
else this.baselined = true;
|
|
608
729
|
return {
|
|
609
730
|
changes: new Set(this.kind === "root" ? rootReportableChanges : allWatchedRepositoryChanges),
|
|
610
|
-
movedWorktrees: void 0
|
|
731
|
+
movedWorktrees: void 0,
|
|
732
|
+
noBaseline: true
|
|
611
733
|
};
|
|
612
734
|
}
|
|
613
735
|
return this.classify();
|
|
614
736
|
}
|
|
737
|
+
/**
|
|
738
|
+
* Whether it holds a reading of the HEAD of the linked worktree with the admin id `id`, so it reports that HEAD's
|
|
739
|
+
* every move from here on: a common git dir with a baseline, probing that worktree's admin entry (not ignored), whose
|
|
740
|
+
* files it read behind it
|
|
741
|
+
*/
|
|
742
|
+
holdsWorktreeHead(id) {
|
|
743
|
+
if (this.kind !== "common" || !this.baselined || this.worktrees.get(id)?.ignored !== false) return false;
|
|
744
|
+
return this.gated.get(`worktrees/${id}`)?.read === true;
|
|
745
|
+
}
|
|
746
|
+
/** Drops every reading, so the next validation has no baseline and reports everything it can */
|
|
747
|
+
reset() {
|
|
748
|
+
this.target = this.createTarget(() => this.getProbes());
|
|
749
|
+
this.gated.clear();
|
|
750
|
+
this.addGated(gitDirGatePath, this.kind === "root" ? rootGatedProbes : commonGatedProbes);
|
|
751
|
+
this.baselined = false;
|
|
752
|
+
this.refDirs.clear();
|
|
753
|
+
this.worktrees.clear();
|
|
754
|
+
this.pendingDirs.clear();
|
|
755
|
+
this.pendingEntries.clear();
|
|
756
|
+
this.reftable = false;
|
|
757
|
+
}
|
|
615
758
|
createTarget(getProbes) {
|
|
616
759
|
return new GitDirProbeTarget(this.basePath, {
|
|
617
760
|
stat: (path) => this.stat(path),
|
|
@@ -863,7 +1006,8 @@ var ProbedGitDir = class {
|
|
|
863
1006
|
}
|
|
864
1007
|
return {
|
|
865
1008
|
changes,
|
|
866
|
-
movedWorktrees: anyWorktreeMoved ? void 0 : movedWorktrees
|
|
1009
|
+
movedWorktrees: anyWorktreeMoved ? void 0 : movedWorktrees,
|
|
1010
|
+
noBaseline: false
|
|
867
1011
|
};
|
|
868
1012
|
}
|
|
869
1013
|
};
|