@gitkraken/core-gitlens 0.29.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -1
- package/dist/git/cache.d.ts +39 -1
- package/dist/git/cache.js +108 -7
- package/dist/git/cache.js.map +1 -1
- package/dist/git/models/issue.d.ts +3 -2
- package/dist/git/models/issue.js +3 -1
- package/dist/git/models/issue.js.map +1 -1
- package/dist/git/models/issueOrPullRequest.d.ts +21 -0
- package/dist/git/models/pullRequest.d.ts +7 -3
- package/dist/git/models/pullRequest.js +3 -1
- package/dist/git/models/pullRequest.js.map +1 -1
- package/dist/git/utils/issue.utils.js +3 -1
- package/dist/git/utils/issue.utils.js.map +1 -1
- package/dist/git/utils/issueOrPullRequest.utils.d.ts +3 -1
- package/dist/git/utils/issueOrPullRequest.utils.js +12 -1
- package/dist/git/utils/issueOrPullRequest.utils.js.map +1 -1
- package/dist/git/utils/pullRequest.utils.js +2 -0
- package/dist/git/utils/pullRequest.utils.js.map +1 -1
- package/dist/git/watching/worktreeSummary.d.ts +16 -7
- package/dist/git/watching/worktreeSummary.js +44 -14
- package/dist/git/watching/worktreeSummary.js.map +1 -1
- package/dist/git-cli/exec/gitDirResolver.d.ts +6 -1
- package/dist/git-cli/exec/gitDirResolver.js +9 -4
- package/dist/git-cli/exec/gitDirResolver.js.map +1 -1
- package/dist/git-cli/providers/branches.d.ts +9 -0
- package/dist/git-cli/providers/branches.js +183 -105
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/dist/git-cli/providers/config.js +1 -1
- package/dist/git-cli/providers/config.js.map +1 -1
- package/dist/plus/git-github/api/github.js +16 -0
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/models.d.ts +12 -0
- package/dist/plus/git-github/models.js +14 -3
- package/dist/plus/git-github/models.js.map +1 -1
- package/dist/plus/integrations/fieldPresence.d.ts +6 -2
- package/dist/plus/integrations/fieldPresence.js +47 -16
- package/dist/plus/integrations/fieldPresence.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/gitlab.js +7 -5
- package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/models.d.ts +1 -0
- package/dist/plus/integrations/providers/gitlab/models.js +8 -6
- package/dist/plus/integrations/providers/gitlab/models.js.map +1 -1
- package/dist/plus/integrations/providers/models.js +18 -3
- package/dist/plus/integrations/providers/models.js.map +1 -1
- package/dist/plus/integrations/reads/pullRequestBranches.d.ts +2 -1
- package/dist/plus/integrations/reads/pullRequestBranches.js.map +1 -1
- package/dist/plus/integrations/reads/resolveRepository.js +3 -2
- package/dist/plus/integrations/reads/resolveRepository.js.map +1 -1
- package/dist/plus/integrations/results.d.ts +8 -3
- package/dist/plus/integrations/results.js.map +1 -1
- package/docs/integrations.md +28 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,36 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.31.0] - 2026-11-06
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Adds `milestone` to `IssueOrPullRequest` (so to issues and pull requests) and a trailing `milestone` constructor parameter to `Issue` and `PullRequest`: an `IssueMilestone` with `id`, `title`, `state` (`open`/`closed`), `dueDate` and `url`, `null` when the read asked and the item has none, `undefined` when it didn't ask. GitLens' own GitHub/GHE issue and pull request fragments select it, and the provider-apis rows map the one GitHub, GitLab and Linear (a project milestone) already normalize. `id` is the GitHub node id or GitLab global id, unique on the host, never the per-repository number. Adds a `milestone` field presence group for issues and pull requests: `fetched` on every GitHub/GHE read, on GitLab's provider-apis reads and on Linear, `not-requested` on GitLens' own GitLab merge request reads and GitLab's account-wide issue read (its REST normalizer drops it), `unavailable` elsewhere. `serializeIssue` and `serializePullRequest` copy it (git, plus/git-github, plus/integrations)
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- **Breaking (plus/integrations)** — `refs.head.repo` and `refs.base.repo` on GitLab's `getPullRequest` and `searchPullRequests` rows hold the repository's name rather than its whole path, on flat paths too: `r`, was `group/r`. The whole path sat beside an owner that was already the namespace, so `getRepositoryIdentityForPullRequest` named `group/group/r`; it now names `group/r`, and these rows match the provider-apis rows. A consumer using either field as the whole path should join `owner` and `repo`
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- Fixes GitLab's `getPullRequest` and `searchPullRequests` naming the wrong repository for a merge request in a nested group: `acme/platform/kepler` read as owner `acme` and repo `platform`, dropping `kepler`. `repository` now carries owner `acme/platform` and repo `kepler`, as `resolveRepository` and the provider-apis reads do. `getPullRequestForBranch` and `getPullRequestForCommit` named `repository` however the caller split the path, which for a remote's descriptor is owner `acme` and repo `platform/kepler`; they now name the same owner and repo as the other reads (plus/integrations)
|
|
22
|
+
|
|
23
|
+
## [0.30.0] - 2026-11-05
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
|
|
27
|
+
- Changes `getGitDir` to walk the folders above a checkout once for all the checkouts in one folder resolved within a few seconds of each other, rather than once each, when deciding whether a repository above could track the checkout as a submodule. The git dir and common git dir it reports aren't affected. A checkout resolved within those seconds can take a sibling's answer from before a superproject was created around them, and so report no `parentUri`. As before, `getGitDir` keeps each checkout's answer until it is unregistered or the cache is reset, so a superproject created after a checkout was resolved isn't seen either way. Adds `Cache.superprojects`, cleared wherever `gitDir` is, and an optional `superprojects` cache to `readGitDirs` (git, git-cli)
|
|
28
|
+
- Changes `getBranch`, with or without a name, to answer from the branch list a repository's worktrees share and copy only the branch it returns, rather than keeping a copy of the whole list for each worktree it was asked about, so memory for these reads no longer grows as worktrees times branches. It answers as `getBranches` does for that worktree. A named read from a linked worktree now returns a new object on each call, where it returned the same one until the list was read again; from the main checkout, a branch that isn't current is still the shared list's own object. `getBranches` still keeps a list for each worktree it is asked about. Adds `Cache.getSharedBranches`, which reads that shared list, and `Cache.isSharedBranchesKept`, which tells whether a list it returned is still the cached one, so a current branch answered from a list that was refused isn't cached; in a repository with no commits, where the list is never kept, the current branch is now cached rather than read again on every call (git, git-cli)
|
|
29
|
+
- Changes `Cache.setCurrentBranchReferenceIfAbsent` to take the ref record the reference was read from (a record from `Cache.getRefs`), rather than the whole listing, and to seed only when that listing started after the worktree's reference was last dropped, so a listing read across a checkout no longer brings the old branch back. A record from a copy of the listing still seeds; a record `Cache.getRefs` didn't return seeds nothing (git)
|
|
30
|
+
|
|
31
|
+
### Fixed
|
|
32
|
+
|
|
33
|
+
- Fixes `WorktreeSummaryService` treating a git command that ran past its time limit, or was killed from outside, as a caller cancelling, which dropped the read. A first read cut short that way left the worktree with no summary and no error, so every `getSummary`/`getSummarySnapshot` threw a bare "No summary available" until some git event queued another read. It now counts as the read's failure: a reader with no summary to answer reads once more, joining a read in flight, then rejects with the `CancellationError` (reason `timeout`) if that read is cut short too; a new subscriber reads once more too. A refresh cut short that way now marks the value `stale` and fires once, as any failed refresh does, where it left the value looking current without the change it was reading until the next event; the next event reads everything. A base read cut short fails only the base, as any failed base read does, so the summary still comes back with the other fields, `stale`, and a cut-short read of the base's config inputs or a remote's `HEAD` symref counts as unknown, where either dropped the whole read. A reader's own cancellation still rejects only that reader, as a cancellation, and aborts no read (git)
|
|
34
|
+
- Fixes `IntegrationManager.resolveRepository` reporting every GitLab repository in a nested group as `renamed: true`, on gitlab.com and self-managed: the remote split `acme/platform/kepler` into owner `acme` and name `platform/kepler` where the provider names owner `acme/platform` and name `kepler`, and the two were compared part by part. It now compares the whole path (ignoring case), so `renamed` is `true` only when the path the provider answers with differs. GitLab's lookup doesn't follow a renamed or moved path, so a stale GitLab remote still resolves as `not-found` (plus/integrations)
|
|
35
|
+
- Fixes `IntegrationManager.resolveRepository` misreading a remote URL with a trailing slash, which git accepts: GitLab resolved it as `not-found` and Bitbucket Cloud as `renamed: true`. The slash is now dropped before the path is read (plus/integrations)
|
|
36
|
+
- Fixes a worktree read before it was registered keeping its own copies of what its repository's checkouts share (branch list, refs, tags, the `.git/gk/config` reconcile baseline and so on) after `registerRepoPath`, where nothing reads them again: registering it now drops them, and a read still in flight at that point no longer puts back the `.git/gk/config` baseline or merge target tracking under its own path (git)
|
|
37
|
+
- Fixes `getBranch()` and `getBranches()` naming the old branch as current after a `'branch'` eviction (a rebase, merge or revert that pauses, or a caller's own `evictCaches(path, 'branch')`) when that worktree's branch list was cached, since only a `'branches'` eviction cleared it. A `'branch'` eviction now drops that worktree's list and keeps the list its repository's worktrees share, so it reads no refs again; until a `'branches'` eviction, `getBranches` marks the new current branch, and every other branch, with the `worktree` the last list read gave it (so `false` for a branch that wasn't checked out then), while `getBranch` names the worktree for the current branch. A repository-wide `clearCaches(undefined, 'branch')` drops every worktree's list too, and a read issued after the eviction no longer joins one already in flight (git, git-cli)
|
|
38
|
+
|
|
9
39
|
## [0.29.0] - 2026-11-04
|
|
10
40
|
|
|
11
41
|
### Added
|
|
@@ -1105,7 +1135,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
|
|
|
1105
1135
|
|
|
1106
1136
|
- 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.
|
|
1107
1137
|
|
|
1108
|
-
[unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.
|
|
1138
|
+
[unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.31.0...HEAD
|
|
1139
|
+
[0.31.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.30.0...gitkraken:releases/core/v0.31.0
|
|
1140
|
+
[0.30.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.29.0...gitkraken:releases/core/v0.30.0
|
|
1109
1141
|
[0.29.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.28.0...gitkraken:releases/core/v0.29.0
|
|
1110
1142
|
[0.28.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.27.0...gitkraken:releases/core/v0.28.0
|
|
1111
1143
|
[0.27.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.26.0...gitkraken:releases/core/v0.27.0
|
package/dist/git/cache.d.ts
CHANGED
|
@@ -128,6 +128,14 @@ export declare class Cache implements Disposable {
|
|
|
128
128
|
private _mergeTargetCheckoutGeneration;
|
|
129
129
|
/** Each merge target answer's entry as `mergeTargets` stored it, so dropping a stale answer can't drop its successor */
|
|
130
130
|
private _mergeTargetStored;
|
|
131
|
+
/** Advanced each time current branch references are dropped (see {@link setCurrentBranchReferenceIfAbsent}) */
|
|
132
|
+
private _currentBranchDrops;
|
|
133
|
+
/** Per worktree path, the value of {@link _currentBranchDrops} when its current branch reference was last dropped */
|
|
134
|
+
private _currentBranchDroppedAt;
|
|
135
|
+
/** The value of {@link _currentBranchDrops} when every current branch reference was last dropped */
|
|
136
|
+
private _allCurrentBranchesDroppedAt;
|
|
137
|
+
/** Each ref listing's records checked out in a worktree, by the value of {@link _currentBranchDrops} when it started */
|
|
138
|
+
private _refsReadAt;
|
|
131
139
|
/**
|
|
132
140
|
* Per-commonPath snapshot of the subset of `.git/gk/config` that derived caches depend on — merge-relevant keys
|
|
133
141
|
* ({@link branchOverviewGkConfigKeysRegex}) and branch metadata keys ({@link parseBranchMetadataGkConfigKey}) —
|
|
@@ -180,7 +188,14 @@ export declare class Cache implements Disposable {
|
|
|
180
188
|
private get configPatterns();
|
|
181
189
|
private get gkConfigMap();
|
|
182
190
|
get currentBranchReference(): PromiseCache<RepoPath, GitBranchReference | undefined>;
|
|
183
|
-
|
|
191
|
+
/**
|
|
192
|
+
* Seeds `worktreePath`'s current branch reference from a ref listing's `%(worktreepath)`, unless the reference was
|
|
193
|
+
* dropped after the listing started: the listing may predate the checkout that dropped it, so the seed would bring
|
|
194
|
+
* the old branch back until the next HEAD change. `record` must be the record of a listing {@link getRefs} returned
|
|
195
|
+
* that `reference` was read from; any other seeds nothing
|
|
196
|
+
*/
|
|
197
|
+
setCurrentBranchReferenceIfAbsent(worktreePath: string, reference: GitBranchReference | undefined, record: RefRecord): void;
|
|
198
|
+
private onCurrentBranchReferencesDropped;
|
|
184
199
|
get conflictDetection(): RepoPromiseCacheMap<ConflictDetectionCacheKey, ConflictDetectionResult>;
|
|
185
200
|
get contributors(): RepoPromiseCacheMap<string, GitContributorsResult>;
|
|
186
201
|
get contributorsLite(): RepoPromiseCacheMap<string, GitContributor[]>;
|
|
@@ -217,6 +232,13 @@ export declare class Cache implements Disposable {
|
|
|
217
232
|
get tags(): PromiseMap<RepoPath, PagedResult<GitTag>>;
|
|
218
233
|
get fileExistence(): RepoPromiseCacheMap<string, boolean>;
|
|
219
234
|
get ignoreRevsFile(): PromiseCache<string, boolean>;
|
|
235
|
+
/**
|
|
236
|
+
* Keyed by a checkout's parent folder, not a repository path: whether a repository above it could track checkouts
|
|
237
|
+
* there as submodules. Short-lived, so a checkout resolved within a few seconds of a sibling reuses its walk, and one
|
|
238
|
+
* resolved later walks again. It only bounds how old a reused answer can be: `gitDir` keeps each checkout's answer
|
|
239
|
+
* until it is unregistered. Cleared whole wherever `gitDir` is, since a per-path clear can't find its keys.
|
|
240
|
+
*/
|
|
241
|
+
get superprojects(): PromiseCache<string, boolean>;
|
|
220
242
|
get trackedPaths(): RepoPromiseCacheMap<string, [string, string] | false>;
|
|
221
243
|
get worktrees(): PromiseMap<RepoPath, GitWorktree[]>;
|
|
222
244
|
clearCaches(repoPath: string | undefined, ...types: CachedGitTypes[]): void;
|
|
@@ -283,6 +305,13 @@ export declare class Cache implements Disposable {
|
|
|
283
305
|
/** Clears file-scoped caches (blame, diff, fileLog) for a specific path within a repo */
|
|
284
306
|
clearForPath(repoPath: string, path: string, ...types: UriScopedCachedGitTypes[]): void;
|
|
285
307
|
registerRepoPath(repoPath: Uri, gitDir: GitDir): void;
|
|
308
|
+
/**
|
|
309
|
+
* A checkout read before it was registered was its own common path, so it holds its own copy of what its
|
|
310
|
+
* repository's checkouts share, and reads from here on go by the common path. Config stays: it is kept by checkout.
|
|
311
|
+
* Its gk config baseline and merge target tracking go too, or a read after it is unregistered would reconcile
|
|
312
|
+
* against a baseline from before it was registered.
|
|
313
|
+
*/
|
|
314
|
+
private evictReadsBeforeRegistration;
|
|
286
315
|
/**
|
|
287
316
|
* Symmetric companion to `registerRepoPath`. Clears cache entries specific to `repoPath`
|
|
288
317
|
* and removes the path from the registry.
|
|
@@ -343,6 +372,13 @@ export declare class Cache implements Disposable {
|
|
|
343
372
|
needsGkConfigSnapshot(repoPath: string, key: string): boolean;
|
|
344
373
|
/** The gk config snapshot currently serving as the reconcile baseline. */
|
|
345
374
|
getGkConfigSnapshot(repoPath: string): ReadonlyMap<string, string> | undefined;
|
|
375
|
+
/**
|
|
376
|
+
* The raw branch list shared by `repoPath`'s worktrees. It holds entries for the common path, so a caller maps what
|
|
377
|
+
* it needs for `repoPath`; {@link getBranches} keeps a mapped copy per worktree.
|
|
378
|
+
*/
|
|
379
|
+
getSharedBranches(repoPath: string, factory: (commonPath: string, cacheable: CacheController, cancellation?: AbortSignal) => PromiseOrValue<PagedResult<GitBranch>>, cancellation?: AbortSignal): Promise<PagedResult<GitBranch>>;
|
|
380
|
+
/** Whether `result`, from {@link getSharedBranches}, is still the list kept for `repoPath`: not refused, replaced or evicted */
|
|
381
|
+
isSharedBranchesKept(repoPath: string, result: PagedResult<GitBranch>): boolean;
|
|
346
382
|
getBranches(repoPath: string, factory: (commonPath: string, cacheable: CacheController, cancellation?: AbortSignal) => PromiseOrValue<PagedResult<GitBranch>>, mapper: (branches: PagedResult<GitBranch>, targetRepoPath: string, commonPath: string, cancellation?: AbortSignal) => PromiseOrValue<PagedResult<GitBranch>>, cancellation?: AbortSignal): Promise<PagedResult<GitBranch>>;
|
|
347
383
|
private static readonly globalConfigKey;
|
|
348
384
|
/**
|
|
@@ -363,6 +399,8 @@ export declare class Cache implements Disposable {
|
|
|
363
399
|
* `reconcileGkConfigMap`; later refreshes of that snapshot are owned by the reconcile itself.
|
|
364
400
|
*/
|
|
365
401
|
getGkConfigMap(repoPath: string, factory: (cacheable: CacheController) => PromiseOrValue<Map<string, string>>): Promise<Map<string, string>>;
|
|
402
|
+
/** Whether a read that started under the common path `path` may still seed state for it: not registered or closed since */
|
|
403
|
+
private isReadPathCurrent;
|
|
366
404
|
/** Extracts the subset of a gk config map that the reconcile baseline tracks (see {@link _gkConfigSnapshots}). */
|
|
367
405
|
private extractReconciledGkConfig;
|
|
368
406
|
/**
|
package/dist/git/cache.js
CHANGED
|
@@ -34,6 +34,8 @@ const baseBranchNameTTL = 3e5;
|
|
|
34
34
|
* documents be owned by their active tracked-document snapshot instead of retaining a second long-lived owner.
|
|
35
35
|
*/
|
|
36
36
|
const maxCachedBlameLines = 5e3;
|
|
37
|
+
/** Worktree paths whose last current branch drop is tracked; the oldest beyond this folds into the all-paths floor */
|
|
38
|
+
const currentBranchDropsTracked = 128;
|
|
37
39
|
async function shouldEvictBlameCacheEntry(progressive) {
|
|
38
40
|
if (progressive == null) return false;
|
|
39
41
|
try {
|
|
@@ -134,6 +136,7 @@ function createEmptyCaches() {
|
|
|
134
136
|
remotes: void 0,
|
|
135
137
|
sharedBranches: void 0,
|
|
136
138
|
stashes: void 0,
|
|
139
|
+
superprojects: void 0,
|
|
137
140
|
tags: void 0,
|
|
138
141
|
trackedPaths: void 0,
|
|
139
142
|
worktrees: void 0
|
|
@@ -154,6 +157,14 @@ var Cache = class Cache {
|
|
|
154
157
|
_mergeTargetCheckoutGeneration = 0;
|
|
155
158
|
/** Each merge target answer's entry as `mergeTargets` stored it, so dropping a stale answer can't drop its successor */
|
|
156
159
|
_mergeTargetStored = /* @__PURE__ */ new WeakMap();
|
|
160
|
+
/** Advanced each time current branch references are dropped (see {@link setCurrentBranchReferenceIfAbsent}) */
|
|
161
|
+
_currentBranchDrops = 0;
|
|
162
|
+
/** Per worktree path, the value of {@link _currentBranchDrops} when its current branch reference was last dropped */
|
|
163
|
+
_currentBranchDroppedAt = /* @__PURE__ */ new Map();
|
|
164
|
+
/** The value of {@link _currentBranchDrops} when every current branch reference was last dropped */
|
|
165
|
+
_allCurrentBranchesDroppedAt = 0;
|
|
166
|
+
/** Each ref listing's records checked out in a worktree, by the value of {@link _currentBranchDrops} when it started */
|
|
167
|
+
_refsReadAt = /* @__PURE__ */ new WeakMap();
|
|
157
168
|
/**
|
|
158
169
|
* Per-commonPath snapshot of the subset of `.git/gk/config` that derived caches depend on — merge-relevant keys
|
|
159
170
|
* ({@link branchOverviewGkConfigKeysRegex}) and branch metadata keys ({@link parseBranchMetadataGkConfigKey}) —
|
|
@@ -198,6 +209,8 @@ var Cache = class Cache {
|
|
|
198
209
|
usage["cache.statusGenerations.entries.count"] = this._statusGenerations.size;
|
|
199
210
|
usage["cache.closeGenerations.entries.count"] = this._closeGenerations.size;
|
|
200
211
|
usage["cache.gkConfigSnapshots.entries.count"] = this._gkConfigSnapshots.size;
|
|
212
|
+
usage["cache.mergeTargetsEvictedOnCheckout.entries.count"] = this._mergeTargetsEvictedOnCheckout.size;
|
|
213
|
+
usage["cache.currentBranchDroppedAt.entries.count"] = this._currentBranchDroppedAt.size;
|
|
201
214
|
return usage;
|
|
202
215
|
}
|
|
203
216
|
get aheadOfBaseConfigKey() {
|
|
@@ -271,9 +284,32 @@ var Cache = class Cache {
|
|
|
271
284
|
get currentBranchReference() {
|
|
272
285
|
return this._caches.currentBranchReference ??= new PromiseCache();
|
|
273
286
|
}
|
|
274
|
-
|
|
287
|
+
/**
|
|
288
|
+
* Seeds `worktreePath`'s current branch reference from a ref listing's `%(worktreepath)`, unless the reference was
|
|
289
|
+
* dropped after the listing started: the listing may predate the checkout that dropped it, so the seed would bring
|
|
290
|
+
* the old branch back until the next HEAD change. `record` must be the record of a listing {@link getRefs} returned
|
|
291
|
+
* that `reference` was read from; any other seeds nothing
|
|
292
|
+
*/
|
|
293
|
+
setCurrentBranchReferenceIfAbsent(worktreePath, reference, record) {
|
|
294
|
+
const readAt = this._refsReadAt.get(record);
|
|
295
|
+
if (readAt == null || readAt < this._allCurrentBranchesDroppedAt || readAt < (this._currentBranchDroppedAt.get(worktreePath) ?? 0)) return;
|
|
275
296
|
if (this.currentBranchReference.get(worktreePath) == null) this.currentBranchReference.set(worktreePath, Promise.resolve(reference));
|
|
276
297
|
}
|
|
298
|
+
onCurrentBranchReferencesDropped(repoPath) {
|
|
299
|
+
this._currentBranchDrops++;
|
|
300
|
+
if (repoPath == null) {
|
|
301
|
+
this._allCurrentBranchesDroppedAt = this._currentBranchDrops;
|
|
302
|
+
this._currentBranchDroppedAt.clear();
|
|
303
|
+
} else {
|
|
304
|
+
this._currentBranchDroppedAt.delete(repoPath);
|
|
305
|
+
this._currentBranchDroppedAt.set(repoPath, this._currentBranchDrops);
|
|
306
|
+
if (this._currentBranchDroppedAt.size > currentBranchDropsTracked) {
|
|
307
|
+
const [oldestPath, oldestAt] = this._currentBranchDroppedAt.entries().next().value;
|
|
308
|
+
this._currentBranchDroppedAt.delete(oldestPath);
|
|
309
|
+
this._allCurrentBranchesDroppedAt = Math.max(this._allCurrentBranchesDroppedAt, oldestAt);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
277
313
|
get conflictDetection() {
|
|
278
314
|
return this._caches.conflictDetection ??= new RepoPromiseCacheMap({ createTTL: 3e4 });
|
|
279
315
|
}
|
|
@@ -397,6 +433,18 @@ var Cache = class Cache {
|
|
|
397
433
|
expireOnError: true
|
|
398
434
|
});
|
|
399
435
|
}
|
|
436
|
+
/**
|
|
437
|
+
* Keyed by a checkout's parent folder, not a repository path: whether a repository above it could track checkouts
|
|
438
|
+
* there as submodules. Short-lived, so a checkout resolved within a few seconds of a sibling reuses its walk, and one
|
|
439
|
+
* resolved later walks again. It only bounds how old a reused answer can be: `gitDir` keeps each checkout's answer
|
|
440
|
+
* until it is unregistered. Cleared whole wherever `gitDir` is, since a per-path clear can't find its keys.
|
|
441
|
+
*/
|
|
442
|
+
get superprojects() {
|
|
443
|
+
return this._caches.superprojects ??= new PromiseCache({
|
|
444
|
+
createTTL: 5e3,
|
|
445
|
+
capacity: 64
|
|
446
|
+
});
|
|
447
|
+
}
|
|
400
448
|
get trackedPaths() {
|
|
401
449
|
return this._caches.trackedPaths ??= new RepoPromiseCacheMap({
|
|
402
450
|
createTTL: 6e4,
|
|
@@ -517,10 +565,11 @@ var Cache = class Cache {
|
|
|
517
565
|
if (types.includes("worktrees") || types.includes("worktreeList")) keysToClear.add("worktrees");
|
|
518
566
|
if (types.some((t) => t !== "gitignore" && t !== "gkConfig" && t !== "providers" && t !== "worktreeList")) keysToClear.add("gitResults");
|
|
519
567
|
}
|
|
568
|
+
if (keysToClear.has("currentBranchReference")) this.onCurrentBranchReferencesDropped(repoPath);
|
|
520
569
|
for (const key of keysToClear) {
|
|
521
570
|
const cache = this._caches[key];
|
|
522
571
|
if (cache == null) continue;
|
|
523
|
-
if (repoPath == null) cache.clear();
|
|
572
|
+
if (repoPath == null || key === "superprojects") cache.clear();
|
|
524
573
|
else if (key === "aheadOfBaseConfigKey" && !worktreeOnly && (!types.length || types.includes("config"))) this.evictShared(key, repoPath, "evict");
|
|
525
574
|
else if (sharedCacheKeys.has(key)) {
|
|
526
575
|
if (!worktreeOnly) {
|
|
@@ -529,6 +578,10 @@ var Cache = class Cache {
|
|
|
529
578
|
}
|
|
530
579
|
} else cache.delete(repoPath);
|
|
531
580
|
}
|
|
581
|
+
if (types.includes("branch") && !types.includes("branches")) {
|
|
582
|
+
if (repoPath == null) this._caches.branches?.clear();
|
|
583
|
+
else this._caches.branches?.delete(repoPath);
|
|
584
|
+
}
|
|
532
585
|
}
|
|
533
586
|
/**
|
|
534
587
|
* Evicts a single shared (commonPath-keyed) cache entry for `repoPath` and its sibling worktrees.
|
|
@@ -643,6 +696,7 @@ var Cache = class Cache {
|
|
|
643
696
|
}
|
|
644
697
|
this._caches.gitResults?.delete(normalizedPath);
|
|
645
698
|
}
|
|
699
|
+
if (previousCommonPath == null && normalizedPath !== commonPath) this.evictReadsBeforeRegistration(normalizedPath);
|
|
646
700
|
this._commonPathRegistry.set(normalizedPath, commonPath);
|
|
647
701
|
let worktrees = this._worktreesByCommonPath.get(commonPath);
|
|
648
702
|
if (worktrees == null) {
|
|
@@ -652,6 +706,24 @@ var Cache = class Cache {
|
|
|
652
706
|
worktrees.add(normalizedPath);
|
|
653
707
|
}
|
|
654
708
|
/**
|
|
709
|
+
* A checkout read before it was registered was its own common path, so it holds its own copy of what its
|
|
710
|
+
* repository's checkouts share, and reads from here on go by the common path. Config stays: it is kept by checkout.
|
|
711
|
+
* Its gk config baseline and merge target tracking go too, or a read after it is unregistered would reconcile
|
|
712
|
+
* against a baseline from before it was registered.
|
|
713
|
+
*/
|
|
714
|
+
evictReadsBeforeRegistration(repoPath) {
|
|
715
|
+
this._gkConfigSnapshots.delete(repoPath);
|
|
716
|
+
this._mergeTargetsEvictedOnCheckout.delete(repoPath);
|
|
717
|
+
for (const key of sharedCacheKeys) {
|
|
718
|
+
if (key === "configKeys" || key === "configPatterns") continue;
|
|
719
|
+
const cache = this._caches[key];
|
|
720
|
+
if (cache == null) continue;
|
|
721
|
+
const invalidate = cache.invalidate;
|
|
722
|
+
if (typeof invalidate === "function") invalidate.call(cache, repoPath);
|
|
723
|
+
else cache.delete(repoPath);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
655
727
|
* Symmetric companion to `registerRepoPath`. Clears cache entries specific to `repoPath`
|
|
656
728
|
* and removes the path from the registry.
|
|
657
729
|
*
|
|
@@ -673,12 +745,17 @@ var Cache = class Cache {
|
|
|
673
745
|
unregisterRepoPath(repoPath) {
|
|
674
746
|
this.incrementStatusGeneration(repoPath);
|
|
675
747
|
this._closeGenerations.set(repoPath, this.getCloseGeneration(repoPath) + 1);
|
|
748
|
+
this.onCurrentBranchReferencesDropped(repoPath);
|
|
676
749
|
const commonPath = this._commonPathRegistry.get(repoPath) ?? repoPath;
|
|
677
750
|
const worktrees = this._worktreesByCommonPath.get(commonPath);
|
|
678
751
|
const isLastWorktree = worktrees == null || worktrees.size <= 1;
|
|
679
752
|
for (const key of Object.keys(this._caches)) {
|
|
680
753
|
const cache = this._caches[key];
|
|
681
754
|
if (cache == null) continue;
|
|
755
|
+
if (key === "superprojects") {
|
|
756
|
+
cache.clear();
|
|
757
|
+
continue;
|
|
758
|
+
}
|
|
682
759
|
if (key === "aheadOfBaseConfigKey" || key === "gitResults") {
|
|
683
760
|
cache.delete(repoPath);
|
|
684
761
|
if (key === "gitResults" && isLastWorktree && repoPath !== commonPath) cache.delete(commonPath);
|
|
@@ -714,6 +791,7 @@ var Cache = class Cache {
|
|
|
714
791
|
this._mergeTargetsEvictedOnCheckout.clear();
|
|
715
792
|
this._gkConfigReconciler = void 0;
|
|
716
793
|
this._caches = createEmptyCaches();
|
|
794
|
+
this.onCurrentBranchReferencesDropped(void 0);
|
|
717
795
|
}
|
|
718
796
|
/** Applies a watcher-observed change, sharing reads still in flight (see {@link applyRepositoryChanges}). */
|
|
719
797
|
onRepositoryChanged(repoPath, changes) {
|
|
@@ -834,9 +912,13 @@ var Cache = class Cache {
|
|
|
834
912
|
getGkConfigSnapshot(repoPath) {
|
|
835
913
|
return this._gkConfigSnapshots.get(this.getCommonPath(repoPath));
|
|
836
914
|
}
|
|
837
|
-
|
|
915
|
+
/**
|
|
916
|
+
* The raw branch list shared by `repoPath`'s worktrees. It holds entries for the common path, so a caller maps what
|
|
917
|
+
* it needs for `repoPath`; {@link getBranches} keeps a mapped copy per worktree.
|
|
918
|
+
*/
|
|
919
|
+
getSharedBranches(repoPath, factory, cancellation) {
|
|
838
920
|
const commonPath = this.getCommonPath(repoPath);
|
|
839
|
-
|
|
921
|
+
return this.sharedBranches.getOrCreate(commonPath, (cacheable, signal) => {
|
|
840
922
|
const p = Promise.resolve(factory(commonPath, cacheable, signal));
|
|
841
923
|
p.finally(() => {
|
|
842
924
|
if (cacheable.invalidated) {
|
|
@@ -846,6 +928,14 @@ var Cache = class Cache {
|
|
|
846
928
|
}).catch(() => {});
|
|
847
929
|
return p;
|
|
848
930
|
}, cancellation);
|
|
931
|
+
}
|
|
932
|
+
/** Whether `result`, from {@link getSharedBranches}, is still the list kept for `repoPath`: not refused, replaced or evicted */
|
|
933
|
+
isSharedBranchesKept(repoPath, result) {
|
|
934
|
+
return this._caches.sharedBranches?.getSettled(this.getCommonPath(repoPath))?.value === result;
|
|
935
|
+
}
|
|
936
|
+
getBranches(repoPath, factory, mapper, cancellation) {
|
|
937
|
+
const commonPath = this.getCommonPath(repoPath);
|
|
938
|
+
const registration = this.getSharedBranches(repoPath, factory, cancellation);
|
|
849
939
|
registration.catch(() => {});
|
|
850
940
|
return this.branches.getOrCreate(repoPath, (_cacheable, mapperSignal) => {
|
|
851
941
|
const rawShared = this.sharedBranches.get(commonPath) ?? registration;
|
|
@@ -901,11 +991,16 @@ var Cache = class Cache {
|
|
|
901
991
|
*/
|
|
902
992
|
getGkConfigMap(repoPath, factory) {
|
|
903
993
|
return this.getSharedSimple(this.gkConfigMap, repoPath, async (commonPath, cacheable) => {
|
|
994
|
+
const closeGeneration = this.getCloseGeneration(commonPath);
|
|
904
995
|
const map = await factory(cacheable);
|
|
905
|
-
if (!this._gkConfigSnapshots.has(commonPath)) this._gkConfigSnapshots.set(commonPath, this.extractReconciledGkConfig(map));
|
|
996
|
+
if (!this._gkConfigSnapshots.has(commonPath) && this.isReadPathCurrent(commonPath, closeGeneration)) this._gkConfigSnapshots.set(commonPath, this.extractReconciledGkConfig(map));
|
|
906
997
|
return map;
|
|
907
998
|
});
|
|
908
999
|
}
|
|
1000
|
+
/** Whether a read that started under the common path `path` may still seed state for it: not registered or closed since */
|
|
1001
|
+
isReadPathCurrent(path, closeGeneration) {
|
|
1002
|
+
return this.getCommonPath(path) === path && this.getCloseGeneration(path) === closeGeneration;
|
|
1003
|
+
}
|
|
909
1004
|
/** Extracts the subset of a gk config map that the reconcile baseline tracks (see {@link _gkConfigSnapshots}). */
|
|
910
1005
|
extractReconciledGkConfig(map) {
|
|
911
1006
|
const subset = /* @__PURE__ */ new Map();
|
|
@@ -1223,9 +1318,10 @@ var Cache = class Cache {
|
|
|
1223
1318
|
getMergeTarget(repoPath, cacheKey, factory, cancellation) {
|
|
1224
1319
|
const pending = this.getSharedSimpleWithKey(this.mergeTargets, repoPath, cacheKey, async (commonPath, cacheable, signal) => {
|
|
1225
1320
|
const generation = this._mergeTargetCheckoutGeneration;
|
|
1321
|
+
const closeGeneration = this.getCloseGeneration(commonPath);
|
|
1226
1322
|
const entry = await factory(commonPath, cacheable, signal);
|
|
1227
1323
|
if (entry.evictOnCheckout) {
|
|
1228
|
-
if (this._mergeTargetCheckoutGeneration !== generation) {
|
|
1324
|
+
if (this._mergeTargetCheckoutGeneration !== generation || !this.isReadPathCurrent(commonPath, closeGeneration)) {
|
|
1229
1325
|
cacheable.invalidate();
|
|
1230
1326
|
return entry;
|
|
1231
1327
|
}
|
|
@@ -1281,7 +1377,12 @@ var Cache = class Cache {
|
|
|
1281
1377
|
}
|
|
1282
1378
|
getRefs(repoPath, factory, cancellation) {
|
|
1283
1379
|
const commonPath = this.getCommonPath(repoPath);
|
|
1284
|
-
return this.refs.getOrCreate(commonPath, (cacheable, signal) =>
|
|
1380
|
+
return this.refs.getOrCreate(commonPath, async (cacheable, signal) => {
|
|
1381
|
+
const readAt = this._currentBranchDrops;
|
|
1382
|
+
const records = await factory(commonPath, cacheable, signal);
|
|
1383
|
+
for (const record of records) if (record.worktreePath) this._refsReadAt.set(record, readAt);
|
|
1384
|
+
return records;
|
|
1385
|
+
}, cancellation);
|
|
1285
1386
|
}
|
|
1286
1387
|
getRefTips(repoPath, factory, cancellation) {
|
|
1287
1388
|
const commonPath = this.getCommonPath(repoPath);
|