@gitkraken/core-gitlens 0.60.1 → 0.61.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 +15 -1
- package/dist/git/providers/provider.d.ts +5 -1
- package/dist/git/service.js +1 -0
- package/dist/git/service.js.map +1 -1
- package/dist/git/watching/provider.d.ts +34 -4
- package/dist/git/watching/watchService.d.ts +15 -12
- package/dist/git/watching/watchService.js +214 -83
- package/dist/git/watching/watchService.js.map +1 -1
- package/dist/git/watching/watcherPatterns.d.ts +3 -3
- package/dist/git/watching/watcherPatterns.js +9 -5
- package/dist/git/watching/watcherPatterns.js.map +1 -1
- package/dist/git-cli/cliGitProvider.d.ts +5 -1
- package/dist/git-cli/cliGitProvider.js +47 -8
- package/dist/git-cli/cliGitProvider.js.map +1 -1
- package/dist/git-cli/providers/config.d.ts +8 -4
- package/dist/git-cli/providers/config.js +10 -9
- package/dist/git-cli/providers/config.js.map +1 -1
- package/dist/plus/integrations/models/publicIntegration.d.ts +0 -1
- package/dist/plus/integrations/providers/issueSorts.d.ts +0 -1
- package/dist/plus/integrations/reads/drains.d.ts +0 -1
- package/package.json +1 -1
|
@@ -12,8 +12,7 @@ import { RepositoryWatchSession } from "./watchSession.js";
|
|
|
12
12
|
* tighter bound here would mark batches incomplete when they filter down to almost nothing.
|
|
13
13
|
*/
|
|
14
14
|
const maxBufferedWorkingTreePaths = 5e3;
|
|
15
|
-
|
|
16
|
-
const ignoredDirectoriesRefreshDelayMs = 500;
|
|
15
|
+
const ignorePruningRefreshDelayMs = 500;
|
|
17
16
|
/**
|
|
18
17
|
* Global service that multiplexes repository watching across all repos.
|
|
19
18
|
*
|
|
@@ -72,6 +71,7 @@ var RepositoryWatchService = class {
|
|
|
72
71
|
defaultWorkingTreeMaxWaitMs;
|
|
73
72
|
getIgnoreFilter;
|
|
74
73
|
getIgnoredDirectories;
|
|
74
|
+
getGitIgnoreWatchInputs;
|
|
75
75
|
getIgnoredWorktreeRoots;
|
|
76
76
|
getIgnoredWorktreeFolders;
|
|
77
77
|
provider;
|
|
@@ -97,6 +97,7 @@ var RepositoryWatchService = class {
|
|
|
97
97
|
this.defaultWorkingTreeMaxWaitMs = options.defaultWorkingTreeMaxWaitMs;
|
|
98
98
|
this.getIgnoreFilter = options.getIgnoreFilter;
|
|
99
99
|
this.getIgnoredDirectories = options.getIgnoredDirectories;
|
|
100
|
+
this.getGitIgnoreWatchInputs = options.getGitIgnoreWatchInputs;
|
|
100
101
|
this.getIgnoredWorktreeRoots = options.getIgnoredWorktreeRoots;
|
|
101
102
|
this.getIgnoredWorktreeFolders = options.getIgnoredWorktreeFolders;
|
|
102
103
|
this.readFile = options.readFile;
|
|
@@ -155,7 +156,11 @@ var RepositoryWatchService = class {
|
|
|
155
156
|
},
|
|
156
157
|
onLastRepoSubscriber: () => {
|
|
157
158
|
const rec = this.sessionMap.get(repoPath);
|
|
158
|
-
if (rec != null)
|
|
159
|
+
if (rec != null) {
|
|
160
|
+
const entry = this.wtWatchers.get(repoPath);
|
|
161
|
+
if (entry?.delegation != null) this.relinquishIgnoreDelegation(entry);
|
|
162
|
+
this.disconnectFromWatchGroup(rec);
|
|
163
|
+
}
|
|
159
164
|
},
|
|
160
165
|
onFirstWorkingTreeSubscriber: () => {
|
|
161
166
|
const rec = this.sessionMap.get(repoPath);
|
|
@@ -169,6 +174,8 @@ var RepositoryWatchService = class {
|
|
|
169
174
|
},
|
|
170
175
|
onDidFireRepoChange: (event) => {
|
|
171
176
|
this._onDidChangeRepository.fire(event);
|
|
177
|
+
if (this.wtWatchers.get(repoPath)?.delegation == null) return;
|
|
178
|
+
if (event.changes.has("index") || event.changes.has("head") || event.changes.has("config") && !event.configConfined) this.refreshWorkingTreeFilter(repoPath);
|
|
172
179
|
},
|
|
173
180
|
onDidFireWorkingTreeChange: (repoPath) => {
|
|
174
181
|
this._onDidChangeWorkingTree.fire(repoPath);
|
|
@@ -269,6 +276,10 @@ var RepositoryWatchService = class {
|
|
|
269
276
|
for (const record of this.sessionMap.values()) {
|
|
270
277
|
const delayMs = getDelay?.(record.session);
|
|
271
278
|
record.session.resume(delayMs);
|
|
279
|
+
if (this.poller == null) {
|
|
280
|
+
const entry = this.wtWatchers.get(record.session.repoPath);
|
|
281
|
+
if (entry != null && entry.watcher == null) this.placeFallbackWorkingTreeWatcher(entry);
|
|
282
|
+
}
|
|
272
283
|
}
|
|
273
284
|
this.poller?.resume();
|
|
274
285
|
}
|
|
@@ -294,8 +305,11 @@ var RepositoryWatchService = class {
|
|
|
294
305
|
const group = this.getOrCreateWatchGroup(commonGitDir, session.repoPath);
|
|
295
306
|
const hooks = {
|
|
296
307
|
onRepoChanged: (_repoPath, changes, ref, overflow, configBranches, movedWorktree) => {
|
|
297
|
-
if (overflow)
|
|
298
|
-
|
|
308
|
+
if (overflow) {
|
|
309
|
+
session.pushUnfencedRepoChanges(changes);
|
|
310
|
+
const entry = this.wtWatchers.get(session.repoPath);
|
|
311
|
+
if (entry?.delegation != null) this.scheduleIgnorePruningRefresh(entry, "recovery");
|
|
312
|
+
} else session.pushRepoChanges(changes, ref, configBranches, movedWorktree);
|
|
299
313
|
if (this.poller != null && (changes.includes("index") || changes.includes("head")) && this.wtWatchers.get(session.repoPath)?.reliability === "unwatchable") session.pushWorkingTreeChanges([], true);
|
|
300
314
|
},
|
|
301
315
|
onFetchHeadChanged: (repoPath) => {
|
|
@@ -346,6 +360,7 @@ var RepositoryWatchService = class {
|
|
|
346
360
|
const connected = group?.sessions.has(repoPath) ?? false;
|
|
347
361
|
const wt = this.wtWatchers.get(repoPath);
|
|
348
362
|
if (!connected && wt == null) return void 0;
|
|
363
|
+
if (this.poller == null && wt?.watcher == null) return connected ? "events" : void 0;
|
|
349
364
|
return group?.isUnwatchable(repoPath) || wt?.reliability === "unwatchable" ? "poll" : "events";
|
|
350
365
|
}
|
|
351
366
|
updateWatchMode(record) {
|
|
@@ -387,17 +402,18 @@ var RepositoryWatchService = class {
|
|
|
387
402
|
};
|
|
388
403
|
filter.ready().then(replay, replay).catch(() => {});
|
|
389
404
|
}
|
|
390
|
-
const onIgnoreRulesChanged = (refreshFilter) => {
|
|
405
|
+
const onIgnoreRulesChanged = (refreshFilter, reason = "worktree") => {
|
|
391
406
|
if (refreshFilter && filter != null) filter.refresh();
|
|
392
|
-
if (entry != null) this.
|
|
407
|
+
if (entry != null) this.scheduleIgnorePruningRefresh(entry, reason);
|
|
393
408
|
for (const h of watchHooks) h.onGitIgnoreChanged?.(repoPath);
|
|
394
409
|
session.pushUnfencedRepoChanges(["ignores"]);
|
|
395
410
|
};
|
|
396
411
|
const isNoise = createWorkingTreeNoiseFilter(repoPath);
|
|
397
412
|
const onEvent = (event) => {
|
|
413
|
+
const startingDelegation = entry?.starting === true && entry.delegation != null;
|
|
398
414
|
if (event.reason === "overflow") {
|
|
399
415
|
session.pushWorkingTreeChanges([], true);
|
|
400
|
-
onIgnoreRulesChanged(true);
|
|
416
|
+
onIgnoreRulesChanged(true, "recovery");
|
|
401
417
|
return;
|
|
402
418
|
}
|
|
403
419
|
if (isNoise(event.path)) return;
|
|
@@ -406,7 +422,8 @@ var RepositoryWatchService = class {
|
|
|
406
422
|
onIgnoreRulesChanged(true);
|
|
407
423
|
return;
|
|
408
424
|
}
|
|
409
|
-
if (relativePath?.endsWith("/.gitignore") && !(filterReady && filter?.isIgnored(relativePath.slice(0, -10)))) onIgnoreRulesChanged(true);
|
|
425
|
+
if (relativePath?.endsWith("/.gitignore") && (entry?.delegation != null || !(filterReady && filter?.isIgnored(relativePath.slice(0, -10))))) onIgnoreRulesChanged(true);
|
|
426
|
+
if (startingDelegation) return;
|
|
410
427
|
if (!filterReady) {
|
|
411
428
|
if (buffered != null && buffered.length >= maxBufferedWorkingTreePaths) {
|
|
412
429
|
bufferIncomplete = true;
|
|
@@ -416,28 +433,30 @@ var RepositoryWatchService = class {
|
|
|
416
433
|
return;
|
|
417
434
|
}
|
|
418
435
|
if (filter != null && relativePath != null && filter.isIgnored(relativePath)) {
|
|
419
|
-
if (canPrune && entry != null) this.onIgnoredEvent(entry, filter, relativePath);
|
|
436
|
+
if (canPrune && entry != null && entry.delegation == null) this.onIgnoredEvent(entry, filter, relativePath);
|
|
420
437
|
return;
|
|
421
438
|
}
|
|
422
439
|
session.pushWorkingTreeChanges([event.path]);
|
|
423
440
|
};
|
|
424
441
|
const kept = canPrune && filter != null ? this.keptIgnoredDirectories.get(filter) : void 0;
|
|
425
|
-
const created = this.createWorkingTreeWatcher(repoPath, onEvent, kept != null ? [...workingTreeExcludes, ...kept] : workingTreeExcludes);
|
|
442
|
+
const created = this.createWorkingTreeWatcher(repoPath, onEvent, kept != null ? [...workingTreeExcludes, ...kept] : workingTreeExcludes, this.getGitIgnoreWatchInputs != null && this.isConnected(record));
|
|
426
443
|
entry = {
|
|
427
444
|
session,
|
|
428
445
|
onEvent,
|
|
429
446
|
filter,
|
|
430
447
|
watcher: created.watcher,
|
|
431
|
-
|
|
448
|
+
delegation: created.delegation,
|
|
449
|
+
ignoredDirectories: created.delegation == null ? kept ?? [] : [],
|
|
432
450
|
generation: 0,
|
|
433
451
|
reading: false,
|
|
434
452
|
rereadQueued: false,
|
|
435
453
|
reliability: "reliable",
|
|
436
|
-
starting: created.
|
|
454
|
+
starting: created.awaitingStartAck || created.delegation != null,
|
|
455
|
+
awaitingStartAck: created.awaitingStartAck
|
|
437
456
|
};
|
|
438
457
|
this.wtWatchers.set(repoPath, entry);
|
|
439
|
-
this.
|
|
440
|
-
if (canPrune && kept == null) this.
|
|
458
|
+
this.reconcileWorkingTreeLifecycle(entry, created.reliability, { initial: true });
|
|
459
|
+
if (entry.delegation != null || canPrune && kept == null) this.refreshIgnorePruning(entry);
|
|
441
460
|
revalidated?.then((changed) => {
|
|
442
461
|
if (!changed) return;
|
|
443
462
|
if (filter != null) this.keptIgnoredDirectories.delete(filter);
|
|
@@ -453,71 +472,96 @@ var RepositoryWatchService = class {
|
|
|
453
472
|
entry.generation++;
|
|
454
473
|
clearTimeout(entry.refreshTimer);
|
|
455
474
|
entry.refreshTimer = void 0;
|
|
456
|
-
|
|
475
|
+
this.wtWatchers.delete(repoPath);
|
|
476
|
+
entry.watcher?.dispose();
|
|
457
477
|
if (entry.pollTarget != null) {
|
|
458
478
|
this.poller?.delete(entry.pollTarget);
|
|
459
479
|
entry.pollTarget = void 0;
|
|
460
480
|
}
|
|
461
|
-
this.wtWatchers.delete(repoPath);
|
|
462
481
|
}
|
|
463
|
-
|
|
464
|
-
* Creates a working-tree watcher, with the reliability it reported before returning, and whether it has yet to call
|
|
465
|
-
* the `onDidStart` its provider promised
|
|
466
|
-
*/
|
|
467
|
-
createWorkingTreeWatcher(repoPath, onEvent, excludes) {
|
|
482
|
+
createWorkingTreeWatcher(repoPath, onEvent, excludes, tryDelegation = false) {
|
|
468
483
|
let watcher;
|
|
469
484
|
let started = false;
|
|
470
485
|
const onDidStart = () => {
|
|
471
486
|
if (started) return;
|
|
472
487
|
started = true;
|
|
473
|
-
if (watcher == null) return;
|
|
474
488
|
const entry = this.wtWatchers.get(repoPath);
|
|
475
|
-
if (entry?.watcher === watcher) {
|
|
476
|
-
entry.
|
|
477
|
-
|
|
489
|
+
if (watcher != null && entry?.watcher === watcher) {
|
|
490
|
+
entry.awaitingStartAck = false;
|
|
491
|
+
this.reconcileWorkingTreeLifecycle(entry, entry.reliability, { rescan: entry.delegation == null });
|
|
478
492
|
}
|
|
479
493
|
};
|
|
480
|
-
if (this.poller == null) {
|
|
481
|
-
watcher = this.provider.createWatcher(repoPath, "**", onEvent, {
|
|
482
|
-
excludes,
|
|
483
|
-
onDidStart
|
|
484
|
-
});
|
|
485
|
-
return {
|
|
486
|
-
watcher,
|
|
487
|
-
reliability: "reliable",
|
|
488
|
-
starting: this.provider.callsOnDidStart === true && !started
|
|
489
|
-
};
|
|
490
|
-
}
|
|
491
494
|
let reliability = "reliable";
|
|
495
|
+
const onDidChangeReliability = (state) => {
|
|
496
|
+
if (watcher == null) {
|
|
497
|
+
reliability = state;
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
const entry = this.wtWatchers.get(repoPath);
|
|
501
|
+
if (entry?.watcher === watcher) this.reconcileWorkingTreeLifecycle(entry, state);
|
|
502
|
+
};
|
|
492
503
|
const options = {
|
|
493
504
|
excludes,
|
|
494
505
|
onDidStart,
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
506
|
+
...this.poller == null ? void 0 : { onDidChangeReliability }
|
|
507
|
+
};
|
|
508
|
+
if (tryDelegation && this.provider.createGitIgnoringWatcher != null) {
|
|
509
|
+
let declined = false;
|
|
510
|
+
const delegated = this.provider.createGitIgnoringWatcher(repoPath, (event) => {
|
|
500
511
|
const entry = this.wtWatchers.get(repoPath);
|
|
501
|
-
if (entry?.watcher === watcher)
|
|
512
|
+
if (watcher != null && entry?.watcher === watcher && !declined) onEvent(event);
|
|
513
|
+
}, {
|
|
514
|
+
excludes: workingTreeExcludes,
|
|
515
|
+
onDidStart: () => {
|
|
516
|
+
if (!declined) onDidStart();
|
|
517
|
+
},
|
|
518
|
+
...this.poller == null ? void 0 : { onDidChangeReliability: (state) => {
|
|
519
|
+
if (!declined) onDidChangeReliability(state);
|
|
520
|
+
} }
|
|
521
|
+
});
|
|
522
|
+
if (delegated != null) {
|
|
523
|
+
watcher = delegated;
|
|
524
|
+
return {
|
|
525
|
+
watcher,
|
|
526
|
+
reliability,
|
|
527
|
+
awaitingStartAck: this.provider.callsOnDidStart === true && !started,
|
|
528
|
+
delegation: {
|
|
529
|
+
watcher: delegated,
|
|
530
|
+
initialApplied: false,
|
|
531
|
+
refreshing: false,
|
|
532
|
+
verified: false
|
|
533
|
+
}
|
|
534
|
+
};
|
|
502
535
|
}
|
|
503
|
-
|
|
536
|
+
declined = true;
|
|
537
|
+
started = false;
|
|
538
|
+
reliability = "reliable";
|
|
539
|
+
}
|
|
504
540
|
watcher = this.provider.createWatcher(repoPath, "**", onEvent, options);
|
|
505
541
|
return {
|
|
506
542
|
watcher,
|
|
507
543
|
reliability,
|
|
508
|
-
|
|
544
|
+
awaitingStartAck: this.provider.callsOnDidStart === true && !started
|
|
509
545
|
};
|
|
510
546
|
}
|
|
511
|
-
|
|
512
|
-
const
|
|
513
|
-
|
|
547
|
+
reconcileWorkingTreeLifecycle(entry, state, options) {
|
|
548
|
+
const unavailable = state === "unwatchable";
|
|
549
|
+
const availabilityChanged = !options?.initial && unavailable !== (entry.reliability === "unwatchable");
|
|
550
|
+
const delegation = entry.delegation;
|
|
514
551
|
entry.reliability = state;
|
|
515
|
-
|
|
516
|
-
if (
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
552
|
+
if (unavailable) entry.awaitingStartAck = false;
|
|
553
|
+
if (availabilityChanged && delegation != null) {
|
|
554
|
+
if (unavailable) {
|
|
555
|
+
entry.generation++;
|
|
556
|
+
if (entry.starting) delegation.verified = false;
|
|
557
|
+
} else this.refreshWorkingTreeFilter(entry.session.repoPath, "recovery");
|
|
520
558
|
}
|
|
559
|
+
const rulesVerified = delegation?.verified !== false;
|
|
560
|
+
const startupReady = entry.starting && !unavailable && !entry.awaitingStartAck && rulesVerified;
|
|
561
|
+
const reconcileAvailability = availabilityChanged && (unavailable || rulesVerified);
|
|
562
|
+
if (startupReady || availabilityChanged && unavailable && delegation == null) entry.starting = false;
|
|
563
|
+
this.updateWorkingTreePollTarget(entry);
|
|
564
|
+
if (startupReady || reconcileAvailability || options?.rescan) entry.session.pushWorkingTreeChanges([], true);
|
|
521
565
|
const record = this.sessionMap.get(entry.session.repoPath);
|
|
522
566
|
if (record != null) this.updateWatchMode(record);
|
|
523
567
|
}
|
|
@@ -525,8 +569,8 @@ var RepositoryWatchService = class {
|
|
|
525
569
|
updateWorkingTreePollTarget(entry) {
|
|
526
570
|
const poller = this.poller;
|
|
527
571
|
const getFingerprint = poller?.options.getWorkingTreeFingerprint;
|
|
528
|
-
if (poller == null
|
|
529
|
-
if (entry.reliability === "reliable") {
|
|
572
|
+
if (poller == null) return;
|
|
573
|
+
if (entry.reliability === "reliable" || getFingerprint == null && entry.watcher != null) {
|
|
530
574
|
if (entry.pollTarget != null) {
|
|
531
575
|
poller.delete(entry.pollTarget);
|
|
532
576
|
entry.pollTarget = void 0;
|
|
@@ -537,6 +581,9 @@ var RepositoryWatchService = class {
|
|
|
537
581
|
const repoPath = entry.session.repoPath;
|
|
538
582
|
let last;
|
|
539
583
|
const target = { poll: async () => {
|
|
584
|
+
if (entry.pollTarget !== target) return;
|
|
585
|
+
if (entry.watcher == null) this.placeFallbackWorkingTreeWatcher(entry);
|
|
586
|
+
if (getFingerprint == null || entry.pollTarget !== target) return;
|
|
540
587
|
let fingerprint;
|
|
541
588
|
try {
|
|
542
589
|
fingerprint = await getFingerprint(repoPath);
|
|
@@ -577,56 +624,140 @@ var RepositoryWatchService = class {
|
|
|
577
624
|
entry.rereadQueued = true;
|
|
578
625
|
return;
|
|
579
626
|
}
|
|
580
|
-
this.
|
|
627
|
+
this.armIgnorePruningRefresh(entry);
|
|
581
628
|
}
|
|
582
|
-
|
|
583
|
-
scheduleIgnoredDirectoriesRefresh(entry) {
|
|
629
|
+
scheduleIgnorePruningRefresh(entry, reason) {
|
|
584
630
|
if (entry.filter != null) this.keptIgnoredDirectories.delete(entry.filter);
|
|
585
|
-
if (!this.canPruneIgnoredDirectories()) return;
|
|
631
|
+
if (entry.delegation == null && !this.canPruneIgnoredDirectories()) return;
|
|
632
|
+
const delegation = entry.delegation;
|
|
633
|
+
if (delegation != null) {
|
|
634
|
+
if (entry.starting) delegation.verified = false;
|
|
635
|
+
if (delegation.pendingRefresh == null || delegation.pendingRefresh === "worktree" || reason === "recovery") delegation.pendingRefresh = reason;
|
|
636
|
+
}
|
|
586
637
|
entry.generation++;
|
|
587
638
|
entry.unprunable = void 0;
|
|
588
639
|
clearTimeout(entry.refreshTimer);
|
|
589
|
-
this.
|
|
640
|
+
this.armIgnorePruningRefresh(entry);
|
|
590
641
|
}
|
|
591
|
-
|
|
642
|
+
armIgnorePruningRefresh(entry) {
|
|
592
643
|
entry.refreshTimer = setTimeout(() => {
|
|
593
644
|
entry.refreshTimer = void 0;
|
|
594
645
|
const repoPath = entry.session.repoPath;
|
|
595
646
|
if (this.wtWatchers.get(repoPath) !== entry) return;
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
647
|
+
this.refreshIgnorePruning(entry);
|
|
648
|
+
}, ignorePruningRefreshDelayMs);
|
|
649
|
+
}
|
|
650
|
+
refreshIgnorePruning(entry) {
|
|
651
|
+
if (this.wtWatchers.get(entry.session.repoPath) !== entry) return;
|
|
652
|
+
const delegation = entry.delegation;
|
|
653
|
+
if (delegation != null) {
|
|
654
|
+
if (!delegation.refreshing && (!delegation.initialApplied || entry.reliability !== "unwatchable")) this.refreshDelegatedIgnores(entry, delegation);
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
if (entry.watcher == null || !this.canPruneIgnoredDirectories()) return;
|
|
658
|
+
if (entry.reading) {
|
|
659
|
+
entry.rereadQueued = true;
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
this.refreshIgnoredDirectories(entry);
|
|
602
663
|
}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
if (
|
|
664
|
+
async refreshIgnoredDirectories(entry) {
|
|
665
|
+
const getIgnoredDirectories = this.getIgnoredDirectories;
|
|
666
|
+
if (getIgnoredDirectories == null) return;
|
|
606
667
|
entry.reading = true;
|
|
607
668
|
try {
|
|
608
669
|
const generation = entry.generation;
|
|
609
670
|
const unpruned = entry.unpruned?.size ? [...entry.unpruned] : void 0;
|
|
610
671
|
let directories;
|
|
611
672
|
try {
|
|
612
|
-
directories = await
|
|
673
|
+
directories = await getIgnoredDirectories(entry.session.repoPath);
|
|
613
674
|
} catch {
|
|
614
675
|
directories = void 0;
|
|
615
676
|
}
|
|
616
677
|
if (entry.generation === generation) {
|
|
617
678
|
if (directories != null) {
|
|
618
|
-
this.swapWorkingTreeWatcher(entry,
|
|
679
|
+
this.swapWorkingTreeWatcher(entry, directories);
|
|
619
680
|
if (entry.filter != null) this.keptIgnoredDirectories.set(entry.filter, directories);
|
|
620
681
|
}
|
|
621
682
|
if (unpruned != null) this.settleUnprunedDirectories(entry, unpruned, directories);
|
|
622
683
|
}
|
|
623
684
|
} finally {
|
|
624
685
|
entry.reading = false;
|
|
686
|
+
if (entry.rereadQueued) {
|
|
687
|
+
entry.rereadQueued = false;
|
|
688
|
+
if (entry.refreshTimer == null && this.wtWatchers.get(entry.session.repoPath) === entry) this.refreshIgnorePruning(entry);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
async refreshDelegatedIgnores(entry, delegation) {
|
|
693
|
+
const repoPath = entry.session.repoPath;
|
|
694
|
+
const generation = entry.generation;
|
|
695
|
+
const initial = !delegation.initialApplied;
|
|
696
|
+
const verifyingStartup = !initial && !delegation.verified;
|
|
697
|
+
const reason = initial ? "initial" : verifyingStartup ? "recovery" : delegation.pendingRefresh ?? "worktree";
|
|
698
|
+
delegation.pendingRefresh = void 0;
|
|
699
|
+
delegation.refreshing = true;
|
|
700
|
+
try {
|
|
701
|
+
const record = this.sessionMap.get(repoPath);
|
|
702
|
+
const inputs = record == null ? void 0 : await this.getGitIgnoreWatchInputs?.(repoPath, record.gitDir, { refreshConfig: verifyingStartup });
|
|
703
|
+
if (entry.generation !== generation || entry.delegation !== delegation) return;
|
|
704
|
+
if (inputs == null) {
|
|
705
|
+
this.relinquishIgnoreDelegation(entry);
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
if (verifyingStartup) {
|
|
709
|
+
await entry.filter?.refresh();
|
|
710
|
+
if (entry.generation !== generation || entry.delegation !== delegation) return;
|
|
711
|
+
}
|
|
712
|
+
await delegation.watcher.refreshGitIgnores(reason, inputs);
|
|
713
|
+
if (entry.delegation !== delegation || this.wtWatchers.get(repoPath) !== entry) return;
|
|
714
|
+
if (initial) {
|
|
715
|
+
delegation.initialApplied = true;
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
await entry.filter?.ready().catch(() => void 0);
|
|
719
|
+
if (entry.generation !== generation || entry.delegation !== delegation) return;
|
|
720
|
+
delegation.verified = true;
|
|
721
|
+
this.reconcileWorkingTreeLifecycle(entry, entry.reliability, { rescan: !verifyingStartup && !entry.starting });
|
|
722
|
+
} catch {
|
|
723
|
+
if (this.wtWatchers.get(repoPath) === entry && entry.delegation === delegation) this.relinquishIgnoreDelegation(entry);
|
|
724
|
+
} finally {
|
|
725
|
+
delegation.refreshing = false;
|
|
726
|
+
if (entry.delegation === delegation && this.wtWatchers.get(repoPath) === entry && entry.refreshTimer == null && (delegation.pendingRefresh != null || delegation.initialApplied && !delegation.verified)) this.refreshIgnorePruning(entry);
|
|
625
727
|
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
728
|
+
}
|
|
729
|
+
relinquishIgnoreDelegation(entry) {
|
|
730
|
+
const delegation = entry.delegation;
|
|
731
|
+
if (delegation == null) return;
|
|
732
|
+
entry.delegation = void 0;
|
|
733
|
+
entry.watcher = void 0;
|
|
734
|
+
entry.starting = false;
|
|
735
|
+
entry.awaitingStartAck = false;
|
|
736
|
+
entry.generation++;
|
|
737
|
+
clearTimeout(entry.refreshTimer);
|
|
738
|
+
entry.refreshTimer = void 0;
|
|
739
|
+
delegation.watcher.dispose();
|
|
740
|
+
this.placeFallbackWorkingTreeWatcher(entry, true);
|
|
741
|
+
}
|
|
742
|
+
placeFallbackWorkingTreeWatcher(entry, withdrawing = false) {
|
|
743
|
+
let created;
|
|
744
|
+
try {
|
|
745
|
+
created = this.createWorkingTreeWatcher(entry.session.repoPath, entry.onEvent, workingTreeExcludes);
|
|
746
|
+
} catch {
|
|
747
|
+
this.reconcileWorkingTreeLifecycle(entry, "unwatchable", {
|
|
748
|
+
initial: true,
|
|
749
|
+
rescan: withdrawing
|
|
750
|
+
});
|
|
751
|
+
return;
|
|
629
752
|
}
|
|
753
|
+
entry.watcher = created.watcher;
|
|
754
|
+
entry.awaitingStartAck = created.awaitingStartAck;
|
|
755
|
+
entry.starting = created.awaitingStartAck;
|
|
756
|
+
this.reconcileWorkingTreeLifecycle(entry, created.reliability, {
|
|
757
|
+
initial: true,
|
|
758
|
+
rescan: !entry.starting || created.reliability === "unwatchable"
|
|
759
|
+
});
|
|
760
|
+
this.refreshIgnorePruning(entry);
|
|
630
761
|
}
|
|
631
762
|
/**
|
|
632
763
|
* A directory the read left unexcluded is one git won't prune (or the read failed), so it never triggers a read
|
|
@@ -640,28 +771,28 @@ var RepositoryWatchService = class {
|
|
|
640
771
|
entry.unprunable.add(dir);
|
|
641
772
|
}
|
|
642
773
|
}
|
|
643
|
-
swapWorkingTreeWatcher(entry,
|
|
774
|
+
swapWorkingTreeWatcher(entry, directories) {
|
|
644
775
|
const previous = entry.ignoredDirectories;
|
|
645
776
|
if (previous.length === directories.length && previous.every((d) => directories.includes(d))) return;
|
|
646
777
|
let created;
|
|
647
778
|
try {
|
|
648
|
-
created = this.createWorkingTreeWatcher(repoPath, entry.onEvent, [...workingTreeExcludes, ...directories]);
|
|
779
|
+
created = this.createWorkingTreeWatcher(entry.session.repoPath, entry.onEvent, [...workingTreeExcludes, ...directories]);
|
|
649
780
|
} catch {
|
|
650
781
|
return;
|
|
651
782
|
}
|
|
652
783
|
const previousWatcher = entry.watcher;
|
|
653
784
|
entry.watcher = created.watcher;
|
|
654
|
-
entry.
|
|
785
|
+
entry.awaitingStartAck = created.awaitingStartAck;
|
|
786
|
+
entry.starting = created.awaitingStartAck;
|
|
655
787
|
entry.ignoredDirectories = directories;
|
|
656
|
-
previousWatcher
|
|
657
|
-
this.
|
|
658
|
-
if (previous.some((d) => !directories.some((n) => n === d || d.startsWith(`${n}/`)))) entry.session.pushWorkingTreeChanges([], true);
|
|
788
|
+
previousWatcher?.dispose();
|
|
789
|
+
this.reconcileWorkingTreeLifecycle(entry, created.reliability, { rescan: previous.some((d) => !directories.some((n) => n === d || d.startsWith(`${n}/`))) });
|
|
659
790
|
}
|
|
660
|
-
refreshWorkingTreeFilter(repoPath) {
|
|
791
|
+
refreshWorkingTreeFilter(repoPath, reason = "metadata") {
|
|
661
792
|
const entry = this.wtWatchers.get(repoPath);
|
|
662
793
|
if (entry == null) return;
|
|
663
794
|
if (entry.filter != null) entry.filter.refresh();
|
|
664
|
-
this.
|
|
795
|
+
this.scheduleIgnorePruningRefresh(entry, reason);
|
|
665
796
|
}
|
|
666
797
|
disposeSessionRecord(record) {
|
|
667
798
|
this.stopWorkingTreeWatcher(record.session.repoPath);
|