@gitkraken/core-gitlens 0.16.3 → 0.16.4
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 +25 -1
- package/dist/git/cache.d.ts +64 -5
- package/dist/git/cache.js +75 -5
- package/dist/git/cache.js.map +1 -1
- package/dist/git/models/branch.d.ts +0 -6
- package/dist/git/models/branch.js.map +1 -1
- package/dist/git/providers/branches.d.ts +65 -1
- package/dist/git/providers/refs.d.ts +3 -2
- package/dist/git/providers/shared/remotes.js +5 -5
- package/dist/git/providers/shared/remotes.js.map +1 -1
- package/dist/git-cli/providers/branches.d.ts +135 -39
- package/dist/git-cli/providers/branches.js +846 -264
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/dist/git-cli/providers/commits.js +37 -20
- package/dist/git-cli/providers/commits.js.map +1 -1
- package/dist/git-cli/providers/config.js +16 -10
- package/dist/git-cli/providers/config.js.map +1 -1
- package/dist/git-cli/providers/contributors.js +3 -3
- package/dist/git-cli/providers/contributors.js.map +1 -1
- package/dist/git-cli/providers/diff.js +15 -12
- package/dist/git-cli/providers/diff.js.map +1 -1
- package/dist/git-cli/providers/graph.js +17 -14
- package/dist/git-cli/providers/graph.js.map +1 -1
- package/dist/git-cli/providers/maintenance.js +3 -3
- package/dist/git-cli/providers/maintenance.js.map +1 -1
- package/dist/git-cli/providers/patch.js +4 -1
- package/dist/git-cli/providers/patch.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/refs.js +16 -13
- package/dist/git-cli/providers/refs.js.map +1 -1
- package/dist/git-cli/providers/remotes.js +4 -1
- package/dist/git-cli/providers/remotes.js.map +1 -1
- package/dist/git-cli/providers/revision.js +14 -11
- package/dist/git-cli/providers/revision.js.map +1 -1
- package/dist/git-cli/providers/stash.js +2 -2
- package/dist/git-cli/providers/stash.js.map +1 -1
- package/dist/git-cli/providers/status.js +7 -7
- package/dist/git-cli/providers/status.js.map +1 -1
- package/dist/git-cli/providers/tags.js +6 -3
- package/dist/git-cli/providers/tags.js.map +1 -1
- package/dist/git-cli/providers/worktrees.js +3 -3
- package/dist/git-cli/providers/worktrees.js.map +1 -1
- package/dist/plus/git-github/providers/github/branches.d.ts +9 -1
- package/dist/plus/git-github/providers/github/branches.js +54 -8
- package/dist/plus/git-github/providers/github/branches.js.map +1 -1
- package/dist/plus/integrations/providers/issueSorts.d.ts +1 -0
- package/dist/plus/integrations/reads/drains.d.ts +1 -0
- package/dist/utils/decorators/log.d.ts +3 -1
- package/dist/utils/decorators/log.js +61 -45
- package/dist/utils/decorators/log.js.map +1 -1
- package/dist/utils/logger.d.ts +15 -1
- package/dist/utils/logger.js +30 -1
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/logger.scoped.d.ts +12 -1
- package/dist/utils/logger.scoped.js +38 -4
- package/dist/utils/logger.scoped.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,29 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.16.4] - 2026-10-23
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Adds `branches.getMergeTarget(branch, options?)`: the ref any branch, checked out or not, is measured against, by `getAheadOfBase`'s rules, so every host names the same target. It answers `{ ref, forkPoint, tier }`, where `tier` adds `'pr'` and `'inferred'` to `AheadOfBaseTier`. Beyond `skipUserTarget` and `preferredTarget` it takes a host's sources: `getAssociatedPullRequest` (read only when no stored target is usable, tried after the detected target and recorded as it unless the pull request is stacked or the branch is a remote-tracking one), `inferBase` (VS Code's `vscode-merge-base`, and for a branch created from `HEAD` the branch HEAD was on when it was first checked out, read from that branch's worktree and never stored), `defaultBranch: 'remote'` (asks the remote only when local refs name no default), `getFallbackDefaultBranch` and `keepSelfAtTip`. Answers are cached against the ref tips, stored keys and config they were read from, so a warm call runs no git and a branch moving elsewhere re-measures nothing (git, git-cli, git-github)
|
|
14
|
+
- Adds `getFallbackDefaultBranch` to `getBranchContributionsOverview`'s options (git, git-cli, git-github)
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- Changes `getBranchContributionsOverview` to measure against `getMergeTarget`, so its target follows `getAheadOfBase`'s rules: an out-of-date local target defers to its upstream, the default branch is read from local refs (`upstream`, then `origin`) before the remote, the default branch measures against its own upstream, and a branch is measured against the branch it was created from until that branch merges (git-cli, git-github)
|
|
19
|
+
- Changes `getAheadOfBase` to keep a candidate whose check failed or timed out, rather than one git confirms is gone, so its count rejects instead of quietly measuring against the next candidate (git-cli)
|
|
20
|
+
- Changes `getBaseBranchName` to no longer record its reflog guess as `gk-merge-base`, where every host read it as a base the branch was launched from (git-cli)
|
|
21
|
+
|
|
22
|
+
### Removed
|
|
23
|
+
|
|
24
|
+
- Removes `BranchTargetInfo` from `git/models/branch.js`; `branches.getMergeTarget` answers the merge target it described (git)
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- Fixes `getReflogEntries`' `grep` matching nothing when the user's `grep.patternType` is `fixed`, which left `getBaseBranchName` with no reflog guess: the pattern is now always read as a basic regular expression (git-cli)
|
|
29
|
+
- Fixes `getBaseBranchName` overwriting a recorded `gk-merge-base` with a reflog guess when checking the recorded branch failed rather than found it gone, and reading the checkout guess from the main worktree's HEAD reflog instead of the branch's own worktree (git-cli)
|
|
30
|
+
- Fixes `getAheadOfBase` measuring a branch created from a full ref (`git switch -c topic refs/heads/develop`) against that ref as-is, never against its fresher upstream: the base is now its short name (`develop`), weighed against its tracking ref like any other (git-cli)
|
|
31
|
+
|
|
9
32
|
## [0.16.3] - 2026-10-23
|
|
10
33
|
|
|
11
34
|
### Fixed
|
|
@@ -897,7 +920,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
|
|
|
897
920
|
|
|
898
921
|
- Initial release. Bundles `@gitlens/utils`, `@gitlens/git`, `@gitlens/git-cli`, `@gitlens/ai`, and `@gitlens/git-github` into a single core npm package with subpath exports.
|
|
899
922
|
|
|
900
|
-
[unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.16.
|
|
923
|
+
[unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.16.4...HEAD
|
|
924
|
+
[0.16.4]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.16.3...gitkraken:releases/core/v0.16.4
|
|
901
925
|
[0.16.3]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.16.2...gitkraken:releases/core/v0.16.3
|
|
902
926
|
[0.16.2]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.16.1...gitkraken:releases/core/v0.16.2
|
|
903
927
|
[0.16.1]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.16.0...gitkraken:releases/core/v0.16.1
|
package/dist/git/cache.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ import { GitUser } from "./models/user.js";
|
|
|
23
23
|
import { GitResult } from "./run.types.js";
|
|
24
24
|
import { GitWorktree } from "./models/worktree.js";
|
|
25
25
|
import { GitCommitReachability, LeftRightCommitCountResult } from "./providers/commits.js";
|
|
26
|
-
import { BranchContributionsOverview, GitBranchMergedStatus } from "./providers/branches.js";
|
|
26
|
+
import { BranchContributionsOverview, GitBranchMergedStatus, MergeTarget } from "./providers/branches.js";
|
|
27
27
|
import { GitContributorsResult } from "./providers/contributors.js";
|
|
28
28
|
import { ResolvedRevision } from "./providers/revision.js";
|
|
29
29
|
//#region ../git/src/cache.d.ts
|
|
@@ -64,6 +64,45 @@ export declare function shouldEvictBlameCacheEntry(progressive: ProgressiveGitBl
|
|
|
64
64
|
* naming the targets to skip via `skipInvalidation`.
|
|
65
65
|
*/
|
|
66
66
|
export type GkConfigInvalidationTarget = 'branchOverviews' | 'baseBranchName';
|
|
67
|
+
/**
|
|
68
|
+
* A `getMergeTarget` answer with what it was read from, so a later call can confirm it from cached reads rather than
|
|
69
|
+
* resolve it again (see {@link Cache.getMergeTarget})
|
|
70
|
+
*/
|
|
71
|
+
export interface CachedMergeTarget {
|
|
72
|
+
/** The answer before `keepSelfAtTip` is applied */
|
|
73
|
+
readonly result: MergeTarget | undefined;
|
|
74
|
+
/** Whether `result` is the branch itself at the branch's own commit */
|
|
75
|
+
readonly selfAtTip: boolean;
|
|
76
|
+
/** Every full ref name whose presence or tip the answer depends on, with the commit it named then (`undefined` when absent) */
|
|
77
|
+
readonly tips: ReadonlyArray<readonly [ref: string, tip: string | undefined]>;
|
|
78
|
+
/**
|
|
79
|
+
* The replace refs as read, as sorted `<name>\0<sha>` lines ('' for none): replacing a commit moves merge bases
|
|
80
|
+
* while every tip stands
|
|
81
|
+
*/
|
|
82
|
+
readonly replaced: string;
|
|
83
|
+
/**
|
|
84
|
+
* The common git directory's `shallow` file as `<size>\0<mtime>`, or `null` when the repo wasn't shallow: deepening
|
|
85
|
+
* a shallow clone moves merge bases while every tip stands
|
|
86
|
+
*/
|
|
87
|
+
readonly shallow: string | null;
|
|
88
|
+
/** The `getAheadOfBaseConfigKey` snapshot the answer was read under */
|
|
89
|
+
readonly configKey: string | undefined;
|
|
90
|
+
/** The branch's stored merge keys as read, raw; `undefined` for a remote-tracking branch, which has none */
|
|
91
|
+
readonly stored: readonly (string | undefined)[] | undefined;
|
|
92
|
+
/** Set only when resolution reached the pull request and stored nothing: the base candidate it named, or `null` for none */
|
|
93
|
+
readonly pullRequest?: string | null;
|
|
94
|
+
/** Set only when the default branch was read: the name local refs gave, or `null` for none */
|
|
95
|
+
readonly localDefault?: string | null;
|
|
96
|
+
/** Set only when the remote was asked for its default branch: that remote, and its answer or `null` for none */
|
|
97
|
+
readonly remoteDefault?: {
|
|
98
|
+
readonly remote: string;
|
|
99
|
+
readonly name: string | null;
|
|
100
|
+
};
|
|
101
|
+
/** Set only when the caller's fallback default branch was asked: its answer, or `null` for none */
|
|
102
|
+
readonly fallbackDefault?: string | null;
|
|
103
|
+
/** The answer read HEAD's reflog for the branch it was created from and found none, which a later checkout can write */
|
|
104
|
+
readonly evictOnCheckout: boolean;
|
|
105
|
+
}
|
|
67
106
|
/** A changed `branch.<branch>.<key>` gk config value for {@link Cache.patchBranchMetadata}; `undefined` is a removal */
|
|
68
107
|
export interface BranchMetadataChange {
|
|
69
108
|
readonly branch: string;
|
|
@@ -79,6 +118,12 @@ export declare class Cache implements Disposable {
|
|
|
79
118
|
private _statusGenerations;
|
|
80
119
|
/** Monotonic per-path "close clock" — see {@link getCloseGeneration}. */
|
|
81
120
|
private _closeGenerations;
|
|
121
|
+
/** Per commonPath, the `mergeTargets` keys a checkout evicts (see {@link CachedMergeTarget.evictOnCheckout}) */
|
|
122
|
+
private _mergeTargetsEvictedOnCheckout;
|
|
123
|
+
/** Bumped on each checkout eviction, so a merge target resolved across one isn't kept for the next */
|
|
124
|
+
private _mergeTargetCheckoutGeneration;
|
|
125
|
+
/** Each merge target answer's entry as `mergeTargets` stored it, so dropping a stale answer can't drop its successor */
|
|
126
|
+
private _mergeTargetStored;
|
|
82
127
|
/**
|
|
83
128
|
* Per-commonPath snapshot of the subset of `.git/gk/config` that derived caches depend on — merge-relevant keys
|
|
84
129
|
* ({@link branchOverviewGkConfigKeysRegex}) and branch metadata keys ({@link parseBranchMetadataGkConfigKey}) —
|
|
@@ -115,6 +160,7 @@ export declare class Cache implements Disposable {
|
|
|
115
160
|
get blame(): RepoPromiseCacheMap<string, ProgressiveGitBlame | undefined>;
|
|
116
161
|
get diff(): RepoPromiseCacheMap<string, ParsedGitDiffHunks | undefined>;
|
|
117
162
|
get fileLog(): RepoPromiseCacheMap<string, GitLog | undefined>;
|
|
163
|
+
private get mergeTargets();
|
|
118
164
|
private get baseBranchName();
|
|
119
165
|
get branch(): PromiseMap<RepoPath, GitBranch | undefined>;
|
|
120
166
|
get branchMergedStatus(): RepoPromiseCacheMap<string, GitBranchMergedStatus>;
|
|
@@ -319,10 +365,10 @@ export declare class Cache implements Disposable {
|
|
|
319
365
|
* (`baseBranchName`/`branchOverviews`) for the written key's ref.
|
|
320
366
|
*
|
|
321
367
|
* @param options.skipInvalidation Downstream caches the caller wants preserved despite this
|
|
322
|
-
* write. Use when the value being written is exactly what was just resolved — e.g. the
|
|
323
|
-
* `storeMergeTargetBranchName` self-write inside `
|
|
324
|
-
* `
|
|
325
|
-
*
|
|
368
|
+
* write. Use when the value being written is exactly what was just resolved — e.g. the pull request's
|
|
369
|
+
* `storeMergeTargetBranchName` self-write inside `getMergeTarget` (skip `'branchOverviews'`) or the
|
|
370
|
+
* `vscode-merge-base` migration's `storeBaseBranchName` self-write (skip both `'baseBranchName'` and
|
|
371
|
+
* `'branchOverviews'`). The bulk `gkConfigMap` map always
|
|
326
372
|
* invalidates so subsequent reads see the new value.
|
|
327
373
|
*/
|
|
328
374
|
deleteGkConfig(repoPath: string, key: string, options?: {
|
|
@@ -440,6 +486,19 @@ export declare class Cache implements Disposable {
|
|
|
440
486
|
getAheadOfBaseConfigListing(repoPath: string, factory: (commonPath: string, cacheable: CacheController, cancellation?: AbortSignal) => PromiseOrValue<string | undefined>, cancellation?: AbortSignal): Promise<string | undefined>;
|
|
441
487
|
getBranchMetadataMap(repoPath: string, factory: (commonPath: string) => PromiseOrValue<Map<string, BranchMetadata>>): Promise<Map<string, BranchMetadata>>;
|
|
442
488
|
getDefaultBranchName(repoPath: string, remote: string, factory: (commonPath: string, cacheable: CacheController, cancellation?: AbortSignal) => PromiseOrValue<string | undefined>, cancellation?: AbortSignal): Promise<string | undefined>;
|
|
489
|
+
/** The cached default branch for one `remote` key, without reading it; `undefined` when none is cached */
|
|
490
|
+
peekDefaultBranchName(repoPath: string, remote: string): Promise<string | undefined> | undefined;
|
|
491
|
+
/**
|
|
492
|
+
* No TTL and not cleared by a ref or config change: the caller confirms a hit against what the answer was read from
|
|
493
|
+
* (see {@link CachedMergeTarget}). A checkout evicts only the entries marked `evictOnCheckout`
|
|
494
|
+
*/
|
|
495
|
+
getMergeTarget(repoPath: string, cacheKey: string, factory: (commonPath: string, cacheable: CacheController, cancellation?: AbortSignal) => PromiseOrValue<CachedMergeTarget>, cancellation?: AbortSignal): Promise<CachedMergeTarget>;
|
|
496
|
+
/**
|
|
497
|
+
* Drops `stale`, an answer {@link getMergeTarget} gave for `cacheKey`, unless it was already replaced: callers that
|
|
498
|
+
* found the same answer stale then share the one that replaced it rather than each resolving their own
|
|
499
|
+
*/
|
|
500
|
+
deleteMergeTarget(repoPath: string, cacheKey: string, stale: CachedMergeTarget): void;
|
|
501
|
+
private evictMergeTargetsOnCheckout;
|
|
443
502
|
/** Clears the cached default branch for one `remote` key (the networked lookup or its `:local` variant). */
|
|
444
503
|
deleteDefaultBranchName(repoPath: string, remote: string): void;
|
|
445
504
|
getInitialCommitSha(repoPath: string, factory: (commonPath: string) => PromiseOrValue<string | undefined>): Promise<string | undefined>;
|
package/dist/git/cache.js
CHANGED
|
@@ -72,6 +72,7 @@ const sharedCacheKeys = new Set(exhaustiveArray()([
|
|
|
72
72
|
"initialCommitSha",
|
|
73
73
|
"lastFetched",
|
|
74
74
|
"logShas",
|
|
75
|
+
"mergeTargets",
|
|
75
76
|
"refs",
|
|
76
77
|
"refTips",
|
|
77
78
|
"remotes",
|
|
@@ -98,6 +99,7 @@ function createEmptyCaches() {
|
|
|
98
99
|
ignoreRevsFile: void 0,
|
|
99
100
|
leftRightCommitCount: void 0,
|
|
100
101
|
mergeBase: void 0,
|
|
102
|
+
mergeTargets: void 0,
|
|
101
103
|
patchIds: void 0,
|
|
102
104
|
configKeys: void 0,
|
|
103
105
|
configPatterns: void 0,
|
|
@@ -140,6 +142,12 @@ var Cache = class Cache {
|
|
|
140
142
|
_statusGenerations = /* @__PURE__ */ new Map();
|
|
141
143
|
/** Monotonic per-path "close clock" — see {@link getCloseGeneration}. */
|
|
142
144
|
_closeGenerations = /* @__PURE__ */ new Map();
|
|
145
|
+
/** Per commonPath, the `mergeTargets` keys a checkout evicts (see {@link CachedMergeTarget.evictOnCheckout}) */
|
|
146
|
+
_mergeTargetsEvictedOnCheckout = /* @__PURE__ */ new Map();
|
|
147
|
+
/** Bumped on each checkout eviction, so a merge target resolved across one isn't kept for the next */
|
|
148
|
+
_mergeTargetCheckoutGeneration = 0;
|
|
149
|
+
/** Each merge target answer's entry as `mergeTargets` stored it, so dropping a stale answer can't drop its successor */
|
|
150
|
+
_mergeTargetStored = /* @__PURE__ */ new WeakMap();
|
|
143
151
|
/**
|
|
144
152
|
* Per-commonPath snapshot of the subset of `.git/gk/config` that derived caches depend on — merge-relevant keys
|
|
145
153
|
* ({@link branchOverviewGkConfigKeysRegex}) and branch metadata keys ({@link parseBranchMetadataGkConfigKey}) —
|
|
@@ -213,6 +221,9 @@ var Cache = class Cache {
|
|
|
213
221
|
capacity: 50
|
|
214
222
|
});
|
|
215
223
|
}
|
|
224
|
+
get mergeTargets() {
|
|
225
|
+
return this._caches.mergeTargets ??= new RepoPromiseCacheMap();
|
|
226
|
+
}
|
|
216
227
|
get baseBranchName() {
|
|
217
228
|
return this._caches.baseBranchName ??= new RepoPromiseCacheMap();
|
|
218
229
|
}
|
|
@@ -407,6 +418,7 @@ var Cache = class Cache {
|
|
|
407
418
|
for (const key of Object.keys(this._caches)) keysToClear.add(key);
|
|
408
419
|
invalidateMemoized("providers");
|
|
409
420
|
this.incrementStatusGenerations(repoPath);
|
|
421
|
+
if (!worktreeOnly) this.evictMergeTargetsOnCheckout(repoPath);
|
|
410
422
|
} else {
|
|
411
423
|
if (types.includes("blame")) keysToClear.add("blame");
|
|
412
424
|
if (types.includes("diff")) keysToClear.add("diff");
|
|
@@ -428,6 +440,7 @@ var Cache = class Cache {
|
|
|
428
440
|
keysToClear.add("aheadOfBaseConfigListing");
|
|
429
441
|
keysToClear.add("baseBranchName");
|
|
430
442
|
}
|
|
443
|
+
if (!worktreeOnly && (types.includes("branch") || types.includes("worktrees"))) this.evictMergeTargetsOnCheckout(repoPath);
|
|
431
444
|
if (types.includes("branches")) {
|
|
432
445
|
keysToClear.add("branchMetadataMap");
|
|
433
446
|
keysToClear.add("branches");
|
|
@@ -668,7 +681,10 @@ var Cache = class Cache {
|
|
|
668
681
|
if (isLastWorktree) evict(commonPath);
|
|
669
682
|
} else evict(repoPath);
|
|
670
683
|
}
|
|
671
|
-
if (isLastWorktree)
|
|
684
|
+
if (isLastWorktree) {
|
|
685
|
+
this._gkConfigSnapshots.delete(commonPath);
|
|
686
|
+
this._mergeTargetsEvictedOnCheckout.delete(commonPath);
|
|
687
|
+
}
|
|
672
688
|
this._commonPathRegistry.delete(repoPath);
|
|
673
689
|
if (worktrees != null) {
|
|
674
690
|
worktrees.delete(repoPath);
|
|
@@ -681,6 +697,7 @@ var Cache = class Cache {
|
|
|
681
697
|
this._worktreesByCommonPath.clear();
|
|
682
698
|
this._statusGenerations.clear();
|
|
683
699
|
this._gkConfigSnapshots.clear();
|
|
700
|
+
this._mergeTargetsEvictedOnCheckout.clear();
|
|
684
701
|
this._gkConfigReconciler = void 0;
|
|
685
702
|
this._caches = createEmptyCaches();
|
|
686
703
|
}
|
|
@@ -885,10 +902,10 @@ var Cache = class Cache {
|
|
|
885
902
|
* (`baseBranchName`/`branchOverviews`) for the written key's ref.
|
|
886
903
|
*
|
|
887
904
|
* @param options.skipInvalidation Downstream caches the caller wants preserved despite this
|
|
888
|
-
* write. Use when the value being written is exactly what was just resolved — e.g. the
|
|
889
|
-
* `storeMergeTargetBranchName` self-write inside `
|
|
890
|
-
* `
|
|
891
|
-
*
|
|
905
|
+
* write. Use when the value being written is exactly what was just resolved — e.g. the pull request's
|
|
906
|
+
* `storeMergeTargetBranchName` self-write inside `getMergeTarget` (skip `'branchOverviews'`) or the
|
|
907
|
+
* `vscode-merge-base` migration's `storeBaseBranchName` self-write (skip both `'baseBranchName'` and
|
|
908
|
+
* `'branchOverviews'`). The bulk `gkConfigMap` map always
|
|
892
909
|
* invalidates so subsequent reads see the new value.
|
|
893
910
|
*/
|
|
894
911
|
deleteGkConfig(repoPath, key, options) {
|
|
@@ -1172,6 +1189,59 @@ var Cache = class Cache {
|
|
|
1172
1189
|
getDefaultBranchName(repoPath, remote, factory, cancellation) {
|
|
1173
1190
|
return this.getSharedSimpleWithKey(this.defaultBranchName, repoPath, remote, factory, { cancellation });
|
|
1174
1191
|
}
|
|
1192
|
+
/** The cached default branch for one `remote` key, without reading it; `undefined` when none is cached */
|
|
1193
|
+
peekDefaultBranchName(repoPath, remote) {
|
|
1194
|
+
return this._caches.defaultBranchName?.get(this.getCommonPath(repoPath), remote);
|
|
1195
|
+
}
|
|
1196
|
+
/**
|
|
1197
|
+
* No TTL and not cleared by a ref or config change: the caller confirms a hit against what the answer was read from
|
|
1198
|
+
* (see {@link CachedMergeTarget}). A checkout evicts only the entries marked `evictOnCheckout`
|
|
1199
|
+
*/
|
|
1200
|
+
getMergeTarget(repoPath, cacheKey, factory, cancellation) {
|
|
1201
|
+
const pending = this.getSharedSimpleWithKey(this.mergeTargets, repoPath, cacheKey, async (commonPath, cacheable, signal) => {
|
|
1202
|
+
const generation = this._mergeTargetCheckoutGeneration;
|
|
1203
|
+
const entry = await factory(commonPath, cacheable, signal);
|
|
1204
|
+
if (entry.evictOnCheckout) {
|
|
1205
|
+
if (this._mergeTargetCheckoutGeneration !== generation) {
|
|
1206
|
+
cacheable.invalidate();
|
|
1207
|
+
return entry;
|
|
1208
|
+
}
|
|
1209
|
+
let keys = this._mergeTargetsEvictedOnCheckout.get(commonPath);
|
|
1210
|
+
if (keys == null) {
|
|
1211
|
+
keys = /* @__PURE__ */ new Set();
|
|
1212
|
+
this._mergeTargetsEvictedOnCheckout.set(commonPath, keys);
|
|
1213
|
+
}
|
|
1214
|
+
keys.add(cacheKey);
|
|
1215
|
+
}
|
|
1216
|
+
return entry;
|
|
1217
|
+
}, { cancellation });
|
|
1218
|
+
const stored = this.mergeTargets.get(this.getCommonPath(repoPath), cacheKey);
|
|
1219
|
+
if (stored == null) return pending;
|
|
1220
|
+
return pending.then((entry) => {
|
|
1221
|
+
this._mergeTargetStored.set(entry, stored);
|
|
1222
|
+
return entry;
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* Drops `stale`, an answer {@link getMergeTarget} gave for `cacheKey`, unless it was already replaced: callers that
|
|
1227
|
+
* found the same answer stale then share the one that replaced it rather than each resolving their own
|
|
1228
|
+
*/
|
|
1229
|
+
deleteMergeTarget(repoPath, cacheKey, stale) {
|
|
1230
|
+
const commonPath = this.getCommonPath(repoPath);
|
|
1231
|
+
const stored = this._mergeTargetStored.get(stale);
|
|
1232
|
+
if (stored != null && this._caches.mergeTargets?.get(commonPath, cacheKey) !== stored) return;
|
|
1233
|
+
this._caches.mergeTargets?.delete(commonPath, cacheKey);
|
|
1234
|
+
}
|
|
1235
|
+
evictMergeTargetsOnCheckout(repoPath) {
|
|
1236
|
+
this._mergeTargetCheckoutGeneration++;
|
|
1237
|
+
const commonPaths = repoPath != null ? [this.getCommonPath(repoPath)] : [...this._mergeTargetsEvictedOnCheckout.keys()];
|
|
1238
|
+
for (const commonPath of commonPaths) {
|
|
1239
|
+
const keys = this._mergeTargetsEvictedOnCheckout.get(commonPath);
|
|
1240
|
+
if (keys == null) continue;
|
|
1241
|
+
this._mergeTargetsEvictedOnCheckout.delete(commonPath);
|
|
1242
|
+
for (const key of keys) this._caches.mergeTargets?.delete(commonPath, key);
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1175
1245
|
/** Clears the cached default branch for one `remote` key (the networked lookup or its `:local` variant). */
|
|
1176
1246
|
deleteDefaultBranchName(repoPath, remote) {
|
|
1177
1247
|
this._caches.defaultBranchName?.delete(this.getCommonPath(repoPath), remote);
|