@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
|
@@ -34,6 +34,12 @@ const maxConcurrentReadsPerRepository = 4;
|
|
|
34
34
|
const maxConcurrentReads = 8;
|
|
35
35
|
const maxUnwatchedReads = 256;
|
|
36
36
|
const maxDeferredDirtyMs = 1e4;
|
|
37
|
+
const minBaseRetryDelayMs = 5e3;
|
|
38
|
+
const maxBaseRetryDelayMs = 3e5;
|
|
39
|
+
const maxCarriedBaseAgeMs = 3e5;
|
|
40
|
+
const maxCarriedBaseAnswers = 20;
|
|
41
|
+
/** The clock a failed base read's wait, and the age of a base kept by a shortcut, are read from; exported for testing */
|
|
42
|
+
const baseRetryClock = { now: () => Date.now() };
|
|
37
43
|
const emptyRefs = Object.freeze([]);
|
|
38
44
|
const noRemotes = /* @__PURE__ */ new Set();
|
|
39
45
|
const noBaseKeys = [
|
|
@@ -148,8 +154,12 @@ var SummarySubscription = class {
|
|
|
148
154
|
* **Value-change-only notification.** {@link WorktreeSummarySubscription.onDidChange} and {@link onDidChangeSummary}
|
|
149
155
|
* fire only when some field's value differs from the previous summary — a recompute that reads the same answer is
|
|
150
156
|
* silent, so a consumer can re-render on every event without diffing. A failed recompute keeps the last values and
|
|
151
|
-
* sets `stale` (firing once); the next successful one clears it
|
|
152
|
-
*
|
|
157
|
+
* sets `stale` (firing once); the next successful one clears it, reading every group. A failed read of only the base
|
|
158
|
+
* keeps the rest and leaves the next events to read what they map to: the base again at once when what it depends on
|
|
159
|
+
* changed (a ref, HEAD, its stored values or config inputs), and else only once a wait since the failure is over,
|
|
160
|
+
* doubling with each failure in a row; until a base read succeeds, `stale` stays set. A summary still showing the
|
|
161
|
+
* dirty flag of a read without a subscription fires again, unchanged, once that flag is read again (its `dirtyReadAt`
|
|
162
|
+
* cleared).
|
|
153
163
|
*
|
|
154
164
|
* **Worktrees without a subscription.** {@link getSummary} and {@link getSummarySnapshot} answer one from its last read
|
|
155
165
|
* (kept for the {@link maxUnwatchedReads} most recently asked), re-reading only the groups whose inputs moved since:
|
|
@@ -260,7 +270,8 @@ var WorktreeSummaryService = class {
|
|
|
260
270
|
* {@link getSummary} does, with `dirtyReadAt` `undefined` once its summary follows its working tree, and until then
|
|
261
271
|
* the saved read's (see {@link WorktreeSummarySubscription.dirtyReadAt}), which `probeDirty` reads again. Any other
|
|
262
272
|
* answers from its last read, re-reading only the groups whose inputs moved since (no git when none did), and in
|
|
263
|
-
* full the first time, or after a failed
|
|
273
|
+
* full the first time, or after a failed read; a base that failed to read is read again as a subscribed worktree's
|
|
274
|
+
* is (see {@link WorktreeSummary.stale}). Its working tree is unwatched, so the dirty flag is re-read
|
|
264
275
|
* only when the index file moved, or with `probeDirty`; a rejection drops the last read, unless the read was cut
|
|
265
276
|
* short, which says nothing against it. Its inputs are core's cached answers, which only a `.git` watch of the
|
|
266
277
|
* worktree (or core's own writes) keeps current.
|
|
@@ -360,8 +371,7 @@ var WorktreeSummaryService = class {
|
|
|
360
371
|
const { key } = flight;
|
|
361
372
|
const signal = flight.abort.signal;
|
|
362
373
|
if (flight.disposed) throw new CancellationError();
|
|
363
|
-
|
|
364
|
-
if (last?.result.summary.stale) last = void 0;
|
|
374
|
+
const last = this.unwatchedReads.get(key);
|
|
365
375
|
try {
|
|
366
376
|
const repo = this.getRepository(key);
|
|
367
377
|
if (repo == null) throw new Error(`No repository found for '${key}'`);
|
|
@@ -374,6 +384,7 @@ var WorktreeSummaryService = class {
|
|
|
374
384
|
else {
|
|
375
385
|
({fields, baseMoves} = await getMovedFields(repo, last, probe, flight.probeDirty, signal));
|
|
376
386
|
if (flight.disposed) throw new CancellationError();
|
|
387
|
+
if (last.result.summary.stale && isBaseRetryDue(last.baseRetry)) fields |= baseField;
|
|
377
388
|
if (fields === 0) {
|
|
378
389
|
this.unwatchedReads.touch(key);
|
|
379
390
|
return last;
|
|
@@ -383,7 +394,7 @@ var WorktreeSummaryService = class {
|
|
|
383
394
|
await readRemoteHeads(repo, probe.remoteHeads, void 0, signal);
|
|
384
395
|
if (flight.disposed) throw new CancellationError();
|
|
385
396
|
}
|
|
386
|
-
let result = await readSummary(repo, key, fields, last?.result.summary, last?.result.baseKeys, last?.result.baseConfigKey, last?.result.baseDefaultBranch, baseMoves, signal, this.verifyBaseRemeasure);
|
|
397
|
+
let result = await readSummary(repo, key, fields, last?.result.summary, last?.result.baseKeys, last?.result.baseConfigKey, last?.result.baseDefaultBranch, last?.result.baseFullRead, baseMoves, signal, this.verifyBaseRemeasure, last?.inputs.baseTips, probe);
|
|
387
398
|
const kept = last?.result.summary;
|
|
388
399
|
if (kept != null && summariesEqual(kept, result.summary)) result = {
|
|
389
400
|
...result,
|
|
@@ -393,7 +404,8 @@ var WorktreeSummaryService = class {
|
|
|
393
404
|
result,
|
|
394
405
|
dirtyReadAt: result.dirtyReadAt ?? last?.dirtyReadAt ?? Date.now(),
|
|
395
406
|
inputs: toUnwatchedInputs(probe, result.summary),
|
|
396
|
-
due: flight.due
|
|
407
|
+
due: flight.due,
|
|
408
|
+
baseRetry: getBaseRetry(last?.baseRetry, result)
|
|
397
409
|
};
|
|
398
410
|
if (this.unwatchedFlights.get(key) === flight && !this.entries.has(key)) this.unwatchedReads.set(key, read);
|
|
399
411
|
return read;
|
|
@@ -448,7 +460,8 @@ var WorktreeSummaryService = class {
|
|
|
448
460
|
probed.refs = await probeRefs(repo, remotes, signal);
|
|
449
461
|
return {
|
|
450
462
|
fields,
|
|
451
|
-
baseMoves
|
|
463
|
+
baseMoves,
|
|
464
|
+
refs: probed.refs
|
|
452
465
|
};
|
|
453
466
|
}
|
|
454
467
|
const probe = await this.probeUnwatched(repo, remotes, false, signal);
|
|
@@ -457,14 +470,16 @@ var WorktreeSummaryService = class {
|
|
|
457
470
|
if (!check) return {
|
|
458
471
|
fields,
|
|
459
472
|
baseMoves,
|
|
460
|
-
head
|
|
473
|
+
head,
|
|
474
|
+
refs: probe
|
|
461
475
|
};
|
|
462
476
|
const moved = getTipCheckFields(probe, previous, tips);
|
|
463
477
|
if (moved.baseMoves != null && baseMoves != null) for (const ref of baseMoves) moved.baseMoves.add(ref);
|
|
464
478
|
return {
|
|
465
479
|
fields: fields | moved.fields,
|
|
466
480
|
baseMoves: moved.baseMoves ?? baseMoves,
|
|
467
|
-
head
|
|
481
|
+
head,
|
|
482
|
+
refs: probe
|
|
468
483
|
};
|
|
469
484
|
} catch (ex) {
|
|
470
485
|
if (isCancellationError(ex)) throw ex;
|
|
@@ -495,14 +510,18 @@ var WorktreeSummaryService = class {
|
|
|
495
510
|
this.fail(entry, /* @__PURE__ */ new Error(`Unable to watch '${entry.key}': no repository or git directory`));
|
|
496
511
|
return;
|
|
497
512
|
}
|
|
498
|
-
|
|
513
|
+
const last = this.unwatchedReads.get(entry.key);
|
|
499
514
|
this.unwatchedReads.delete(entry.key);
|
|
500
|
-
if (last?.result.summary.stale) last = void 0;
|
|
501
515
|
if (last != null) {
|
|
502
516
|
entry.seed = last.result.summary;
|
|
517
|
+
if (entry.seed.stale) {
|
|
518
|
+
entry.staleFields = baseField;
|
|
519
|
+
entry.baseRetry = last.baseRetry;
|
|
520
|
+
}
|
|
503
521
|
entry.baseKeys = last.result.baseKeys;
|
|
504
522
|
entry.baseConfigKey = last.result.baseConfigKey;
|
|
505
523
|
entry.baseDefaultBranch = last.result.baseDefaultBranch;
|
|
524
|
+
entry.baseFullRead = last.result.baseFullRead;
|
|
506
525
|
entry.tips = { base: last.inputs.baseTips };
|
|
507
526
|
} else entry.pending |= 23;
|
|
508
527
|
entry.handle = handle;
|
|
@@ -551,6 +570,7 @@ var WorktreeSummaryService = class {
|
|
|
551
570
|
entry.pending |= 23;
|
|
552
571
|
return;
|
|
553
572
|
}
|
|
573
|
+
if ((entry.staleFields & baseField) !== 0 && isBaseRetryDue(entry.baseRetry)) moved.fields |= baseField;
|
|
554
574
|
if (deferDirty) {
|
|
555
575
|
entry.pending |= moved.fields & -2;
|
|
556
576
|
entry.dirtyReadAt = last.dirtyReadAt;
|
|
@@ -636,7 +656,7 @@ var WorktreeSummaryService = class {
|
|
|
636
656
|
queue(entry, fields, baseMoves) {
|
|
637
657
|
if (entry.disposed || fields === 0) return;
|
|
638
658
|
const value = entry.value ?? entry.seed;
|
|
639
|
-
entry.pending |= value == null ||
|
|
659
|
+
entry.pending |= value == null || (entry.staleFields & -5) !== 0 ? fields | 23 : fields;
|
|
640
660
|
if (baseMoves != null) {
|
|
641
661
|
entry.baseMoves ??= /* @__PURE__ */ new Set();
|
|
642
662
|
for (const ref of baseMoves) entry.baseMoves.add(ref);
|
|
@@ -700,14 +720,15 @@ var WorktreeSummaryService = class {
|
|
|
700
720
|
async run(entry, fields, baseMoves) {
|
|
701
721
|
const { value, seed, tips } = entry;
|
|
702
722
|
const previous = value ?? seed;
|
|
703
|
-
if (
|
|
723
|
+
if ((entry.staleFields & -5) !== 0) fields |= 23;
|
|
724
|
+
else if ((entry.staleFields & baseField) !== 0 && isBaseRetryDue(entry.baseRetry)) fields |= baseField;
|
|
704
725
|
const probed = {};
|
|
705
726
|
let result;
|
|
706
727
|
try {
|
|
707
728
|
const repo = this.getRepository(entry.key);
|
|
708
729
|
if (repo == null) throw new Error(`No repository found for '${entry.key}'`);
|
|
709
730
|
const signal = entry.abort.signal;
|
|
710
|
-
result = await readSummary(repo, entry.key, fields, previous, entry.baseKeys, entry.baseConfigKey, entry.baseDefaultBranch, baseMoves, signal, this.verifyBaseRemeasure, (due, moves) => this.probeRead(repo, previous, tips, due, moves, probed, signal));
|
|
731
|
+
result = await readSummary(repo, entry.key, fields, previous, entry.baseKeys, entry.baseConfigKey, entry.baseDefaultBranch, entry.baseFullRead, baseMoves, signal, this.verifyBaseRemeasure, tips?.base, void 0, (due, moves) => this.probeRead(repo, previous, tips, due, moves, probed, signal));
|
|
711
732
|
} catch (ex) {
|
|
712
733
|
if (entry.disposed) return;
|
|
713
734
|
this.fail(entry, ex);
|
|
@@ -721,6 +742,9 @@ var WorktreeSummaryService = class {
|
|
|
721
742
|
entry.baseKeys = result.baseKeys;
|
|
722
743
|
entry.baseConfigKey = entry.pending & baseConfigField ? void 0 : result.baseConfigKey;
|
|
723
744
|
entry.baseDefaultBranch = result.baseDefaultBranch;
|
|
745
|
+
entry.baseFullRead = result.baseFullRead;
|
|
746
|
+
entry.staleFields = result.summary.stale ? baseField : 0;
|
|
747
|
+
entry.baseRetry = getBaseRetry(entry.baseRetry, result);
|
|
724
748
|
const dirtyConfirmed = result.dirtyReadAt != null && entry.dirtyReadAt != null;
|
|
725
749
|
if (dirtyConfirmed) clearDeferredDirty(entry);
|
|
726
750
|
if (value != null && summariesEqual(value, result.summary)) {
|
|
@@ -742,6 +766,7 @@ var WorktreeSummaryService = class {
|
|
|
742
766
|
entry.error = ex instanceof Error ? ex : new Error(String(ex));
|
|
743
767
|
return;
|
|
744
768
|
}
|
|
769
|
+
entry.staleFields = allFields;
|
|
745
770
|
if (previous.stale) return;
|
|
746
771
|
_logger.warn(`WorktreeSummaryService: refreshing '${entry.key}' failed: ${String(ex)}`);
|
|
747
772
|
const summary = {
|
|
@@ -777,7 +802,10 @@ var WorktreeSummaryService = class {
|
|
|
777
802
|
entry.baseKeys = void 0;
|
|
778
803
|
entry.baseConfigKey = void 0;
|
|
779
804
|
entry.baseDefaultBranch = void 0;
|
|
805
|
+
entry.baseFullRead = void 0;
|
|
780
806
|
entry.tips = void 0;
|
|
807
|
+
entry.staleFields = 0;
|
|
808
|
+
entry.baseRetry = void 0;
|
|
781
809
|
entry.pending = 0;
|
|
782
810
|
entry.baseMoves = void 0;
|
|
783
811
|
entry.running = void 0;
|
|
@@ -800,7 +828,10 @@ function dropSeed(entry) {
|
|
|
800
828
|
entry.baseKeys = void 0;
|
|
801
829
|
entry.baseConfigKey = void 0;
|
|
802
830
|
entry.baseDefaultBranch = void 0;
|
|
831
|
+
entry.baseFullRead = void 0;
|
|
803
832
|
entry.tips = void 0;
|
|
833
|
+
entry.staleFields = 0;
|
|
834
|
+
entry.baseRetry = void 0;
|
|
804
835
|
}
|
|
805
836
|
function clearDeferredDirty(entry) {
|
|
806
837
|
entry.dirtyReadAt = void 0;
|
|
@@ -822,8 +853,11 @@ function createEntry(key) {
|
|
|
822
853
|
baseKeys: void 0,
|
|
823
854
|
baseConfigKey: void 0,
|
|
824
855
|
baseDefaultBranch: void 0,
|
|
856
|
+
baseFullRead: void 0,
|
|
825
857
|
tips: void 0,
|
|
826
858
|
error: void 0,
|
|
859
|
+
staleFields: 0,
|
|
860
|
+
baseRetry: void 0,
|
|
827
861
|
pending: 0,
|
|
828
862
|
baseMoves: void 0,
|
|
829
863
|
running: void 0,
|
|
@@ -837,10 +871,15 @@ function createEntry(key) {
|
|
|
837
871
|
* from `previousBaseKeys` read the base group. A base due only because `baseMoves` moved, with HEAD, the stored
|
|
838
872
|
* values and the config inputs as before, is first re-measured from `previous` and the default branch its read
|
|
839
873
|
* resolved, `previousBaseDefaultBranch` (see `getAheadOfBaseAfterBaseMove`), and read in full only when that can't
|
|
840
|
-
* answer. A
|
|
841
|
-
*
|
|
874
|
+
* answer. A base due because HEAD moved on the same branch, with the upstream, the stored values and the config inputs
|
|
875
|
+
* as before, and every ref the base depends on but the branch's own where `previousBaseTips` has it (as the probe's
|
|
876
|
+
* refs, or `probedRefs` without a probe, find them), is first carried past the commit (see `getAheadOfBaseAfterCommit`)
|
|
877
|
+
* the same way. Neither shortcut is tried once `previousBaseFullRead`, the base's last full read, is past its bounds
|
|
878
|
+
* (see {@link getCarriableBaseRead}). A failed base read doesn't fail the rest: the summary comes back stale, keeping
|
|
879
|
+
* the previous base and `baseDependsOn` only while the branch is the same. A stale `previous` stays stale unless the
|
|
880
|
+
* base is read, and its base is read in full, never re-measured.
|
|
842
881
|
*/
|
|
843
|
-
async function readSummary(repo, key, fields, previous, previousBaseKeys, previousBaseConfigKey, previousBaseDefaultBranch, baseMoves, signal, verifyBaseRemeasure, probe) {
|
|
882
|
+
async function readSummary(repo, key, fields, previous, previousBaseKeys, previousBaseConfigKey, previousBaseDefaultBranch, previousBaseFullRead, baseMoves, signal, verifyBaseRemeasure, previousBaseTips, probedRefs, probe) {
|
|
844
883
|
if (previous == null) fields |= allFields;
|
|
845
884
|
let dirtyReadAt;
|
|
846
885
|
const startDirtyRead = () => {
|
|
@@ -849,9 +888,10 @@ async function readSummary(repo, key, fields, previous, previousBaseKeys, previo
|
|
|
849
888
|
};
|
|
850
889
|
let dirtyRead = fields & dirtyField ? startDirtyRead() : void 0;
|
|
851
890
|
let head;
|
|
891
|
+
let refs = probedRefs;
|
|
852
892
|
if (probe != null && fields & 102) {
|
|
853
893
|
const probed = await probe(fields, baseMoves);
|
|
854
|
-
({fields, baseMoves, head} = probed);
|
|
894
|
+
({fields, baseMoves, head, refs} = probed);
|
|
855
895
|
if (fields & dirtyField) dirtyRead ??= startDirtyRead();
|
|
856
896
|
}
|
|
857
897
|
let branch = previous?.branch;
|
|
@@ -881,6 +921,7 @@ async function readSummary(repo, key, fields, previous, previousBaseKeys, previo
|
|
|
881
921
|
let baseConfig;
|
|
882
922
|
let baseConfigRead = false;
|
|
883
923
|
let baseDefaultBranch = previousBaseDefaultBranch;
|
|
924
|
+
let baseFullRead = previousBaseFullRead;
|
|
884
925
|
let baseFailed = false;
|
|
885
926
|
let baseError;
|
|
886
927
|
const baseReadable = repo.branches.getAheadOfBase != null && (detached || branch != null);
|
|
@@ -902,6 +943,7 @@ async function readSummary(repo, key, fields, previous, previousBaseKeys, previo
|
|
|
902
943
|
baseKeys = void 0;
|
|
903
944
|
baseConfigKey = void 0;
|
|
904
945
|
baseDefaultBranch = void 0;
|
|
946
|
+
baseFullRead = void 0;
|
|
905
947
|
} else {
|
|
906
948
|
if (!baseKeysRead) baseKeys = await readBaseKeys(repo, branch, signal);
|
|
907
949
|
if (!baseConfigRead && (previous != null || (fields & baseConfigField) !== 0)) {
|
|
@@ -910,24 +952,54 @@ async function readSummary(repo, key, fields, previous, previousBaseKeys, previo
|
|
|
910
952
|
}
|
|
911
953
|
try {
|
|
912
954
|
let aheadOfBase;
|
|
913
|
-
|
|
955
|
+
const verify = async (shortcut) => {
|
|
956
|
+
if (verifyBaseRemeasure == null) return;
|
|
957
|
+
let full;
|
|
958
|
+
try {
|
|
959
|
+
full = await repo.branches.getAheadOfBase?.(branch, void 0, signal);
|
|
960
|
+
} catch (ex) {
|
|
961
|
+
if (isReadAborted(ex, signal)) throw ex;
|
|
962
|
+
}
|
|
963
|
+
verifyBaseRemeasure(shortcut, full);
|
|
964
|
+
};
|
|
965
|
+
const carriable = getCarriableBaseRead(previousBaseFullRead);
|
|
966
|
+
if (carriable != null && !(fields & baseField) && baseMoves != null && baseMoves.size !== 0 && previous?.base != null && !previous.stale && sha != null && sha === previous.sha && baseKeys != null && previousBaseKeys != null && baseKeysEqual(baseKeys, previousBaseKeys) && getBaseConfigKey(baseConfig, previous) === previousBaseConfigKey) {
|
|
914
967
|
aheadOfBase = await repo.branches.getAheadOfBaseAfterBaseMove?.(branch, {
|
|
915
968
|
head: sha,
|
|
916
969
|
base: previous.base,
|
|
917
970
|
dependsOn: previous.baseDependsOn,
|
|
918
|
-
...previousBaseDefaultBranch !== void 0 ? { defaultBranch: previousBaseDefaultBranch } : void 0
|
|
971
|
+
...previousBaseDefaultBranch !== void 0 ? { defaultBranch: previousBaseDefaultBranch } : void 0,
|
|
972
|
+
...carriable.measuredFrom !== void 0 ? { measuredFrom: carriable.measuredFrom } : void 0
|
|
919
973
|
}, [...baseMoves], signal);
|
|
920
|
-
if (aheadOfBase != null
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
974
|
+
if (aheadOfBase != null) await verify(aheadOfBase);
|
|
975
|
+
} else if (carriable != null && repo.branches.getAheadOfBaseAfterCommit != null && (baseMoves == null || baseMoves.size === 0) && previous?.base != null && !previous.stale && sha != null && previous.sha != null && sha !== previous.sha && branch != null && branch === previous.branch && !detached && !previous.detached && upstreamsEqual(upstream, previous.upstream) && baseKeys != null && previousBaseKeys != null && baseKeysEqual(baseKeys, previousBaseKeys) && previousBaseConfigKey != null && getBaseConfigKey(baseConfig, previous) === previousBaseConfigKey && isOnlyBranchMoved(refs, previousBaseTips, previous.baseDependsOn, branch, sha)) {
|
|
976
|
+
try {
|
|
977
|
+
aheadOfBase = await repo.branches.getAheadOfBaseAfterCommit(branch, {
|
|
978
|
+
head: previous.sha,
|
|
979
|
+
base: previous.base,
|
|
980
|
+
dependsOn: previous.baseDependsOn,
|
|
981
|
+
...previousBaseDefaultBranch !== void 0 ? { defaultBranch: previousBaseDefaultBranch } : void 0,
|
|
982
|
+
...carriable.measuredFrom !== void 0 ? { measuredFrom: carriable.measuredFrom } : void 0
|
|
983
|
+
}, sha, signal);
|
|
984
|
+
} catch (ex) {
|
|
985
|
+
if (isReadAborted(ex, signal)) throw ex;
|
|
928
986
|
}
|
|
987
|
+
if (aheadOfBase != null) await verify(aheadOfBase);
|
|
988
|
+
}
|
|
989
|
+
if (aheadOfBase != null && carriable != null) baseFullRead = {
|
|
990
|
+
at: carriable.at,
|
|
991
|
+
answers: carriable.answers + 1,
|
|
992
|
+
measuredFrom: aheadOfBase.measuredFrom
|
|
993
|
+
};
|
|
994
|
+
else {
|
|
995
|
+
const readAt = baseRetryClock.now();
|
|
996
|
+
aheadOfBase = await repo.branches.getAheadOfBase?.(branch, void 0, signal);
|
|
997
|
+
baseFullRead = aheadOfBase?.provisional ? void 0 : {
|
|
998
|
+
at: readAt,
|
|
999
|
+
answers: 0,
|
|
1000
|
+
measuredFrom: aheadOfBase?.measuredFrom
|
|
1001
|
+
};
|
|
929
1002
|
}
|
|
930
|
-
aheadOfBase ??= await repo.branches.getAheadOfBase?.(branch, void 0, signal);
|
|
931
1003
|
base = aheadOfBase?.base;
|
|
932
1004
|
dependsOn = aheadOfBase?.dependsOn ?? emptyRefs;
|
|
933
1005
|
baseDefaultBranch = aheadOfBase?.defaultBranch;
|
|
@@ -938,10 +1010,8 @@ async function readSummary(repo, key, fields, previous, previousBaseKeys, previo
|
|
|
938
1010
|
const sameBranch = previous != null && branch === previous.branch && detached === previous.detached;
|
|
939
1011
|
base = sameBranch ? previous.base : void 0;
|
|
940
1012
|
dependsOn = sameBranch ? previous.baseDependsOn : emptyRefs;
|
|
941
|
-
baseKeys = void 0;
|
|
942
|
-
baseConfigRead = false;
|
|
943
|
-
baseConfigKey = void 0;
|
|
944
1013
|
baseDefaultBranch = void 0;
|
|
1014
|
+
baseFullRead = void 0;
|
|
945
1015
|
}
|
|
946
1016
|
}
|
|
947
1017
|
}
|
|
@@ -957,7 +1027,7 @@ async function readSummary(repo, key, fields, previous, previousBaseKeys, previo
|
|
|
957
1027
|
dirty,
|
|
958
1028
|
base,
|
|
959
1029
|
baseDependsOn: dependsOn,
|
|
960
|
-
stale: baseFailed
|
|
1030
|
+
stale: baseFailed || previous?.stale === true && (fields & 36) === 0
|
|
961
1031
|
};
|
|
962
1032
|
if (baseConfigRead) baseConfigKey = getBaseConfigKey(baseConfig, summary);
|
|
963
1033
|
return {
|
|
@@ -965,6 +1035,7 @@ async function readSummary(repo, key, fields, previous, previousBaseKeys, previo
|
|
|
965
1035
|
baseKeys,
|
|
966
1036
|
baseConfigKey,
|
|
967
1037
|
baseDefaultBranch,
|
|
1038
|
+
baseFullRead,
|
|
968
1039
|
baseError,
|
|
969
1040
|
dirtyReadAt,
|
|
970
1041
|
fields
|
|
@@ -1023,7 +1094,7 @@ async function getMovedFields(repo, last, probe, probeDirty, signal) {
|
|
|
1023
1094
|
fields |= getUpstreamFields(probe.current, previous);
|
|
1024
1095
|
if (probe.upstream !== inputs.upstream) fields |= 18;
|
|
1025
1096
|
else if (getUpstreamTips(probe.tips, probe.upstream) !== inputs.upstreamTips) fields |= branchField;
|
|
1026
|
-
baseMoves = getMovedBaseRefs(probe, previous.baseDependsOn, inputs.baseTips);
|
|
1097
|
+
baseMoves = getMovedBaseRefs(probe, previous.baseDependsOn, inputs.baseTips, previous.stale);
|
|
1027
1098
|
if (baseMoves != null) fields |= baseMoveField;
|
|
1028
1099
|
if ((fields & baseConfigField) === 0 && last.result.baseConfigKey != null && repo.branches.getAheadOfBase != null && (probe.detached || probe.branch != null)) {
|
|
1029
1100
|
const configKey = getBaseConfigKey(await readBaseConfig(repo, signal), previous);
|
|
@@ -1047,7 +1118,7 @@ function getTipCheckFields(probe, previous, tips) {
|
|
|
1047
1118
|
baseMoves: void 0
|
|
1048
1119
|
};
|
|
1049
1120
|
let fields = getUpstreamFields(probe.current, previous);
|
|
1050
|
-
const baseMoves = getMovedBaseRefs(probe, previous.baseDependsOn, tips?.base);
|
|
1121
|
+
const baseMoves = getMovedBaseRefs(probe, previous.baseDependsOn, tips?.base, previous.stale);
|
|
1051
1122
|
if (baseMoves != null) fields |= baseMoveField;
|
|
1052
1123
|
return {
|
|
1053
1124
|
fields,
|
|
@@ -1069,28 +1140,80 @@ function getUpstreamFields(current, previous) {
|
|
|
1069
1140
|
}
|
|
1070
1141
|
/**
|
|
1071
1142
|
* The refs of `baseDependsOn` that `probe` finds moved since `baseTips`; `undefined` when none did. A tip that's unknown
|
|
1072
|
-
* (`null`, or not kept) moved
|
|
1143
|
+
* (`null`, or not kept) moved, except for a `stale` base: it would then be retried by every check, its wait or not
|
|
1144
|
+
* (see {@link isBaseRetryDue}), while a move named exactly still retries it at once.
|
|
1073
1145
|
*/
|
|
1074
|
-
function getMovedBaseRefs(probe, baseDependsOn, baseTips) {
|
|
1146
|
+
function getMovedBaseRefs(probe, baseDependsOn, baseTips, stale) {
|
|
1075
1147
|
let baseMoves;
|
|
1076
1148
|
for (const ref of baseDependsOn) {
|
|
1077
1149
|
const value = getBaseInput(probe, ref);
|
|
1078
|
-
|
|
1150
|
+
const kept = baseTips?.get(ref);
|
|
1151
|
+
if (value !== null && kept !== null && baseTips?.has(ref) === true ? value === kept : stale) continue;
|
|
1079
1152
|
baseMoves ??= /* @__PURE__ */ new Set();
|
|
1080
1153
|
baseMoves.add(ref);
|
|
1081
1154
|
}
|
|
1082
1155
|
return baseMoves;
|
|
1083
1156
|
}
|
|
1084
1157
|
/**
|
|
1158
|
+
* Whether, of the refs in `baseDependsOn`, only `branch`'s own moved since `baseTips`, to `sha`, as `refs` finds them. A
|
|
1159
|
+
* tip that's unknown (`null`, or not kept) counts as moved, and so does a ref that appeared or went.
|
|
1160
|
+
*/
|
|
1161
|
+
function isOnlyBranchMoved(refs, baseTips, baseDependsOn, branch, sha) {
|
|
1162
|
+
if (refs == null || baseTips == null) return false;
|
|
1163
|
+
const own = `refs/heads/${branch}`;
|
|
1164
|
+
for (const ref of baseDependsOn) {
|
|
1165
|
+
const value = getBaseInput(refs, ref);
|
|
1166
|
+
if (ref === own) {
|
|
1167
|
+
if (value !== sha) return false;
|
|
1168
|
+
continue;
|
|
1169
|
+
}
|
|
1170
|
+
const kept = baseTips.get(ref);
|
|
1171
|
+
if (value === null || kept === null || !baseTips.has(ref) || value !== kept) return false;
|
|
1172
|
+
}
|
|
1173
|
+
return true;
|
|
1174
|
+
}
|
|
1175
|
+
/**
|
|
1085
1176
|
* The tips a subscribed run leaves its summary read from: from the refs its probe found (`refs`) when it read the base,
|
|
1086
1177
|
* unknown when it read it without a probe, and else `last`'s
|
|
1087
1178
|
*/
|
|
1088
1179
|
function getReadTips(last, refs, result) {
|
|
1089
1180
|
const { summary, fields } = result;
|
|
1090
1181
|
let base = last?.base;
|
|
1091
|
-
if (fields & 36) base = refs != null
|
|
1182
|
+
if (fields & 36) base = refs != null ? getBaseTips(refs, summary.baseDependsOn) : void 0;
|
|
1092
1183
|
return { base };
|
|
1093
1184
|
}
|
|
1185
|
+
/**
|
|
1186
|
+
* Whether a stale base whose read failed is due to be read again with any change: once the wait `retry` set since its
|
|
1187
|
+
* last failure is over, or with no wait set
|
|
1188
|
+
*/
|
|
1189
|
+
function isBaseRetryDue(retry) {
|
|
1190
|
+
if (retry == null) return true;
|
|
1191
|
+
const remaining = retry.at - baseRetryClock.now();
|
|
1192
|
+
return remaining <= 0 || remaining > retry.delay;
|
|
1193
|
+
}
|
|
1194
|
+
/**
|
|
1195
|
+
* The wait a read leaves its base with: `last` when it didn't read the base, none when the base read succeeded, and,
|
|
1196
|
+
* when it failed, double `last`'s, from {@link minBaseRetryDelayMs} up to {@link maxBaseRetryDelayMs}
|
|
1197
|
+
*/
|
|
1198
|
+
function getBaseRetry(last, result) {
|
|
1199
|
+
if ((result.fields & 36) === 0) return last;
|
|
1200
|
+
if (!result.summary.stale) return void 0;
|
|
1201
|
+
const delay = last != null ? Math.min(last.delay * 2, maxBaseRetryDelayMs) : minBaseRetryDelayMs;
|
|
1202
|
+
return {
|
|
1203
|
+
at: baseRetryClock.now() + delay,
|
|
1204
|
+
delay
|
|
1205
|
+
};
|
|
1206
|
+
}
|
|
1207
|
+
/**
|
|
1208
|
+
* `read` while a shortcut may still answer from it: less than {@link maxCarriedBaseAgeMs} old, by a clock that hasn't
|
|
1209
|
+
* gone back since, and followed by fewer than {@link maxCarriedBaseAnswers} shortcut answers; else `undefined`, as for
|
|
1210
|
+
* an unknown one
|
|
1211
|
+
*/
|
|
1212
|
+
function getCarriableBaseRead(read) {
|
|
1213
|
+
if (read == null || read.answers >= maxCarriedBaseAnswers) return void 0;
|
|
1214
|
+
const age = baseRetryClock.now() - read.at;
|
|
1215
|
+
return age >= 0 && age < maxCarriedBaseAgeMs ? read : void 0;
|
|
1216
|
+
}
|
|
1094
1217
|
/** The upstream's tips as a remote-tracking and as a local branch, since its short name doesn't say which */
|
|
1095
1218
|
function getUpstreamTips(tips, upstream) {
|
|
1096
1219
|
if (upstream == null) return void 0;
|
|
@@ -1262,6 +1385,6 @@ function summariesEqual(a, b) {
|
|
|
1262
1385
|
return a.repoPath === b.repoPath && a.branch === b.branch && a.detached === b.detached && a.sha === b.sha && a.ahead === b.ahead && a.behind === b.behind && a.dirty === b.dirty && a.stale === b.stale && areEqual(a.baseDependsOn, b.baseDependsOn) && upstreamsEqual(a.upstream, b.upstream) && (a.base === b.base || a.base != null && b.base != null && a.base.ref === b.base.ref && a.base.ahead === b.base.ahead && a.base.sha === b.base.sha && a.base.forkPoint === b.base.forkPoint && a.base.tier === b.base.tier);
|
|
1263
1386
|
}
|
|
1264
1387
|
//#endregion
|
|
1265
|
-
export { WorktreeSummaryService };
|
|
1388
|
+
export { WorktreeSummaryService, baseRetryClock };
|
|
1266
1389
|
|
|
1267
1390
|
//# sourceMappingURL=worktreeSummary.js.map
|