@gitkraken/core-gitlens 0.32.0 → 0.33.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 +27 -1
- package/dist/git/cache.d.ts +90 -15
- package/dist/git/cache.js +215 -44
- package/dist/git/cache.js.map +1 -1
- package/dist/git/models/repositoryIdentities.d.ts +0 -1
- package/dist/git/models/repositoryIdentities.js +1 -4
- package/dist/git/models/repositoryIdentities.js.map +1 -1
- package/dist/git/providers/provider.d.ts +7 -0
- package/dist/git/remotes/gitlab.js +15 -9
- package/dist/git/remotes/gitlab.js.map +1 -1
- package/dist/git/service.js +4 -1
- package/dist/git/service.js.map +1 -1
- package/dist/git/utils/repository.utils.d.ts +10 -0
- package/dist/git/utils/repository.utils.js +25 -2
- package/dist/git/utils/repository.utils.js.map +1 -1
- package/dist/git/watching/changeEvent.d.ts +13 -3
- package/dist/git/watching/changeEvent.js +19 -4
- package/dist/git/watching/changeEvent.js.map +1 -1
- package/dist/git/watching/watchGroup.d.ts +4 -2
- package/dist/git/watching/watchGroup.js +32 -17
- package/dist/git/watching/watchGroup.js.map +1 -1
- package/dist/git/watching/watchService.d.ts +4 -1
- package/dist/git/watching/watchService.js +18 -15
- package/dist/git/watching/watchService.js.map +1 -1
- package/dist/git/watching/watchSession.d.ts +27 -12
- package/dist/git/watching/watchSession.js +49 -19
- package/dist/git/watching/watchSession.js.map +1 -1
- package/dist/git/watching/worktreeSummary.js +7 -7
- package/dist/git/watching/worktreeSummary.js.map +1 -1
- package/dist/git-cli/cliGitProvider.d.ts +28 -2
- package/dist/git-cli/cliGitProvider.js +62 -19
- package/dist/git-cli/cliGitProvider.js.map +1 -1
- package/dist/git-cli/exec/git.js +7 -2
- package/dist/git-cli/exec/git.js.map +1 -1
- package/dist/git-cli/providers/branches.js +15 -10
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/dist/git-cli/providers/config.d.ts +2 -0
- package/dist/git-cli/providers/config.js +19 -8
- package/dist/git-cli/providers/config.js.map +1 -1
- package/dist/git-cli/providers/worktrees.js +34 -10
- package/dist/git-cli/providers/worktrees.js.map +1 -1
- package/dist/git-cli/service.js +1 -1
- package/dist/git-cli/service.js.map +1 -1
- package/dist/plus/integrations/models/integration.js +1 -1
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +10 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.js +62 -15
- package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.d.ts +8 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.js +32 -16
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,31 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.33.0] - 2026-11-06
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Adds `Cache.getDropStamp` and `Cache.isDroppedSince`, with the `DropStampedCacheKey` type, so a read can tell that a `'currentBranchReference'` or `'currentUser'` entry it would cache was dropped while it ran; `getDropStamp(key, repoPath)` gives the stamp of that entry's last drop, to key a read shared by calls with no drop of it between them (git)
|
|
14
|
+
- Adds `WatcherRepoChangeEvent.movedWorktrees`: for a `'worktreeHead'` change, the admin ids (the `<id>` of `.git/worktrees/<id>`) of the linked worktrees whose `HEAD` moved outside core's own writes, `undefined` when any linked worktree's may have. `Cache.onRepositoryChanged` and `Cache.applyRepositoryChanges` take it as `options.movedWorktrees` (`applyRepositoryChanges` also takes `options.announced` for core's announcement of its own write), `WatcherRepoChangeEvent.with` takes it as a third argument, `AnnouncedRepositoryChanges.movedWorktrees` and `noteSelfWrite`'s `options.movedWorktrees` name the linked worktrees a write moved, `Cache.getLinkedWorktreeId` gives a registered linked worktree's admin id, and `utils/repository.utils.js` exports `parseWorktreeAdminPath` and `getWorktreeAdminId` (git)
|
|
15
|
+
|
|
16
|
+
### Removed
|
|
17
|
+
|
|
18
|
+
- **Breaking (git)** — Removes `getPathFromProviderIdentity` from `models/repositoryIdentities.js`: nothing called it, and it doubled the path for the identities the pull request and issue builders make, which set `repoOwnerDomain` to `repoDomain`
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- Fixes `getGitDir` answering a checkout's old git dirs after it was unregistered while they were being read: the read put its answer back, so a path re-created as another repository's checkout, or one that vanished mid-read and fell back to `<path>/.git`, kept the old answer until it was unregistered again. A read in flight across `unregisterRepoPath` or `Cache.reset()` now answers only its own caller, and a call made after either reads again rather than joining it. `Cache.getCloseGeneration` now advances on `reset()` for every path, one never registered included (git, git-cli)
|
|
23
|
+
- Fixes `getBranch(path, name)` placing a branch at `path` after `path` switched away from it, when only a `'branch'` eviction followed the checkout (a paused rebase, merge or revert, or a caller's own `evictCaches(path, 'branch')`), so the shared branch list wasn't read again. A branch that isn't current at `path` but that the list places there now has `worktree: false` (unless `path`'s current branch couldn't be read), so from the main checkout that branch is a new object rather than the shared list's own, and `getBranch` names `path` for its current branch even when the list places that branch in another worktree. No refs are read again. `getBranches` keeps the list's placements, as it already did for the current branch, since they are how a stale list is noticed against `git worktree list`, so for such a branch `getBranch` no longer answers exactly as `getBranches` does; until a `'branches'` eviction, `getBranches` and another worktree's view keep the worktree the last list read gave a branch (git-cli)
|
|
24
|
+
- Fixes `getCurrentUser` keeping the old user after a config change that landed while the user was being read: the read put its answer back after the `'config'` eviction had dropped it, so the old user (or "no user") stayed cached until the next config change. A read in flight across a `'config'` or full eviction, `unregisterRepoPath` or `Cache.reset()` now answers only its own caller, and a call made after the drop reads again rather than joining it (git-cli)
|
|
25
|
+
- Fixes `getBranch()` naming the branch a linked worktree left after a checkout there that only another worktree's watcher saw (reported as `'worktreeHead'`), which cleared only the worktree list, so the worktree's current branch, including one a ref listing seeded for an unregistered worktree, stayed until something else evicted it. A watcher's report of `worktrees/<id>/HEAD`, or of an entry added or removed, now names the worktree (`movedWorktrees`), and a registered worktree it names is cleared as its own `'head'` change would clear it; no other worktree is touched. A report that can't name one (a rescan, an overflow) drops the current branch reference, current branch and branch list of each linked worktree but the reporter, and one naming a worktree that isn't registered drops those of the unregistered worktrees the repository's latest ref listing reported; either way the main checkout's are kept, as is everything the worktrees share, and a listing read before the report no longer seeds what it dropped. An unregistered worktree also loses its current branch once its repository's ref listing stops reporting it, or the repository's last checkout is unregistered, since no report could find it after. Core's own writes (a checkout, rebase or bisect step, a worktree added or removed) name the worktree they moved, so they drop no other worktree's, and a checkout outside core in another worktree landing at the same moment is no longer taken for the write's echo (git, git-cli)
|
|
26
|
+
- Fixes `getDefaultWorktreePath` answering from a checkout's old git dirs when called after the checkout was unregistered while an earlier call was still reading them: the later call joined the earlier one rather than reading again (git-cli)
|
|
27
|
+
- Fixes GitLab's `searchPullRequests` ignoring `options.repos` and searching the whole instance: a search scoped to repositories now searches each one's project (by its whole URL-encoded path, so a nested group's too), interleaves the projects' results by relevance, drops duplicates and keeps the single search's cap of 20. A project that's gone contributes nothing, one that fails is skipped with the others still answered, and the search rejects only when every project fails (plus/integrations)
|
|
28
|
+
- Fixes `getGitLabPullRequestIdentityFromMaybeUrl` keeping only the last two segments of a merge request URL's project path, so a nested group's `acme/platform/kepler` came back as `platform/kepler`: the whole path before `/-/merge_requests/<n>` is now the project, less a host. Adds `splitOwnerAndRepo`, which splits a GitLab project path at its last slash (plus/integrations)
|
|
29
|
+
- Fixes the GitLab remote provider's autolinks, file links and cross-fork merge requests for repositories in nested groups: `acme/platform/kepler#12` linked as `platform/kepler`, `parseRemoteFileUri` returned `undefined` for a nested group's file URL, and a merge request from a fork into `acme/platform/kepler` looked up project `acme/platform` for its target. Each now takes everything before the last slash as the owner (git)
|
|
30
|
+
- Fixes `Git` remembering a failed git lookup for the rest of the process: once the locator rejected (git not installed yet, a transient spawn failure), every `path()`, `version()` and `run()` rejected with that error until restart. Callers in flight together still share one lookup, and the next call looks again (git-cli)
|
|
31
|
+
- Fixes `RepositoryWatchService` dropping the working-tree changes it held while a repository's gitignore filter loaded, when that load failed. They're now replayed through the filter as after a successful load; a filter that failed to load keeps the rules it had and errs toward "not ignored" (git)
|
|
32
|
+
- Fixes an integration that disconnected itself after too many failed requests never firing `onDidChangeConnectionState` or the `connection.onStateChanged` hook: consumers kept treating it as connected, and when it reconnected the `connected` event was swallowed as a repeat. It now fires `disconnected`, and still doesn't persist the disconnect, so the integration reconnects on the next start (plus/integrations)
|
|
33
|
+
|
|
9
34
|
## [0.32.0] - 2026-11-05
|
|
10
35
|
|
|
11
36
|
### Changed
|
|
@@ -1148,7 +1173,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
|
|
|
1148
1173
|
|
|
1149
1174
|
- 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.
|
|
1150
1175
|
|
|
1151
|
-
[unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.
|
|
1176
|
+
[unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.33.0...HEAD
|
|
1177
|
+
[0.33.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.32.0...gitkraken:releases/core/v0.33.0
|
|
1152
1178
|
[0.32.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.31.0...gitkraken:releases/core/v0.32.0
|
|
1153
1179
|
[0.31.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.30.0...gitkraken:releases/core/v0.31.0
|
|
1154
1180
|
[0.30.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.29.0...gitkraken:releases/core/v0.30.0
|
package/dist/git/cache.d.ts
CHANGED
|
@@ -60,6 +60,11 @@ export interface MergeTargetsChangeEvent {
|
|
|
60
60
|
readonly refs: ReadonlySet<string> | undefined;
|
|
61
61
|
}
|
|
62
62
|
export type ConflictDetectionCacheKey = `apply:${string}:${string}:${string}` | `merge:${string}:${string}` | `reapply:${string}:${string}`;
|
|
63
|
+
/**
|
|
64
|
+
* Per-path caches whose drops are stamped, so a read can tell its entry was dropped mid-flight
|
|
65
|
+
* (see {@link Cache.isDroppedSince})
|
|
66
|
+
*/
|
|
67
|
+
export type DropStampedCacheKey = 'currentBranchReference' | 'currentUser';
|
|
63
68
|
export declare function shouldEvictBlameCacheEntry(progressive: ProgressiveGitBlame | undefined): Promise<boolean>;
|
|
64
69
|
/**
|
|
65
70
|
* Downstream caches that `deleteGkConfig` may invalidate when a `branch.<ref>.gk-...` key changes.
|
|
@@ -122,20 +127,38 @@ export declare class Cache implements Disposable {
|
|
|
122
127
|
private _statusGenerations;
|
|
123
128
|
/** Monotonic per-path "close clock" — see {@link getCloseGeneration}. */
|
|
124
129
|
private _closeGenerations;
|
|
130
|
+
/** Advanced by {@link reset}, which moves every path's close clock, those it never saw included */
|
|
131
|
+
private _resetGeneration;
|
|
125
132
|
/** Per commonPath, the `mergeTargets` keys a checkout evicts (see {@link CachedMergeTarget.evictOnCheckout}) */
|
|
126
133
|
private _mergeTargetsEvictedOnCheckout;
|
|
127
134
|
/** Bumped on each checkout eviction, so a merge target resolved across one isn't kept for the next */
|
|
128
135
|
private _mergeTargetCheckoutGeneration;
|
|
129
136
|
/** Each merge target answer's entry as `mergeTargets` stored it, so dropping a stale answer can't drop its successor */
|
|
130
137
|
private _mergeTargetStored;
|
|
131
|
-
/** Advanced each time
|
|
132
|
-
private
|
|
133
|
-
/**
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
138
|
+
/** Advanced each time a drop-stamped cache's entries are dropped (see {@link getDropStamp}) */
|
|
139
|
+
private _drops;
|
|
140
|
+
/**
|
|
141
|
+
* Per drop-stamped cache, the value of {@link _drops} when each path's entry was last dropped (`byPath`) and when
|
|
142
|
+
* every path's entry was (`all`)
|
|
143
|
+
*/
|
|
144
|
+
private readonly _droppedAt;
|
|
145
|
+
/**
|
|
146
|
+
* Each ref listing's records checked out in a worktree, with the value of {@link _drops} when the listing started
|
|
147
|
+
* and the common path it listed
|
|
148
|
+
*/
|
|
149
|
+
private _refsRead;
|
|
150
|
+
/**
|
|
151
|
+
* Unregistered linked worktrees a ref listing reported, whether or not it seeded their current branch, with the
|
|
152
|
+
* common path of the listing (see {@link dropLinkedCurrentBranches})
|
|
153
|
+
*/
|
|
154
|
+
private _seededWorktrees;
|
|
155
|
+
/** {@link _seededWorktrees} by common path */
|
|
156
|
+
private _seededWorktreesByCommonPath;
|
|
157
|
+
/**
|
|
158
|
+
* Registered linked worktrees' admin ids (the `<id>` of `.git/worktrees/<id>`), which name the worktree a
|
|
159
|
+
* `'worktreeHead'` report says moved (see {@link applyRepositoryChanges})
|
|
160
|
+
*/
|
|
161
|
+
private _worktreeAdminIds;
|
|
139
162
|
/**
|
|
140
163
|
* Per-commonPath snapshot of the subset of `.git/gk/config` that derived caches depend on — merge-relevant keys
|
|
141
164
|
* ({@link branchOverviewGkConfigKeysRegex}) and branch metadata keys ({@link parseBranchMetadataGkConfigKey}) —
|
|
@@ -195,7 +218,38 @@ export declare class Cache implements Disposable {
|
|
|
195
218
|
* that `reference` was read from; any other seeds nothing
|
|
196
219
|
*/
|
|
197
220
|
setCurrentBranchReferenceIfAbsent(worktreePath: string, reference: GitBranchReference | undefined, record: RefRecord): void;
|
|
198
|
-
private
|
|
221
|
+
private trackSeededWorktree;
|
|
222
|
+
private untrackSeededWorktree;
|
|
223
|
+
/**
|
|
224
|
+
* Tracks exactly `reported` for `commonPath`. A path the listing no longer reports isn't tracked any more, so a
|
|
225
|
+
* HEAD change could no longer find it to drop its current branch: it goes with it
|
|
226
|
+
*/
|
|
227
|
+
private replaceSeededWorktrees;
|
|
228
|
+
/**
|
|
229
|
+
* A `'worktreeHead'` report that doesn't say which linked worktree's HEAD moved, so each one but `repoPath` loses its
|
|
230
|
+
* current branch: those registered, and those its repository's ref listings seeded. Never the main checkout: its
|
|
231
|
+
* HEAD is the common `HEAD`, which is reported as `'head'`. With `unidentifiedOnly`, the report named a worktree that
|
|
232
|
+
* isn't registered, so a registered one with an admin id of its own keeps its current branch
|
|
233
|
+
*/
|
|
234
|
+
private dropLinkedCurrentBranches;
|
|
235
|
+
/**
|
|
236
|
+
* A `'worktreeHead'` report naming, by admin id, the linked worktrees whose HEAD moved: each registered one but
|
|
237
|
+
* `repoPath` is cleared as for its own `'head'` change, and an id no registered worktree has is an unregistered
|
|
238
|
+
* worktree's (see {@link dropLinkedCurrentBranches})
|
|
239
|
+
*/
|
|
240
|
+
private applyLinkedHeadsMoved;
|
|
241
|
+
/** Drops what a `'branch'` eviction of `worktreePath` drops of its current branch, and nothing shared */
|
|
242
|
+
private dropCurrentBranch;
|
|
243
|
+
/**
|
|
244
|
+
* A stamp to take before a read, to later ask {@link isDroppedSince} whether the read's entry was dropped mid-flight.
|
|
245
|
+
* With `key` and `repoPath`, the stamp of that entry's last drop, which only a drop of it advances, so it can key a
|
|
246
|
+
* read that calls with no drop between them share
|
|
247
|
+
*/
|
|
248
|
+
getDropStamp(key?: DropStampedCacheKey, repoPath?: string): number;
|
|
249
|
+
/** Whether `key`'s entry for `repoPath` was dropped after `stamp` was taken by {@link getDropStamp} */
|
|
250
|
+
isDroppedSince(key: DropStampedCacheKey, repoPath: string, stamp: number): boolean;
|
|
251
|
+
/** Stamps a drop of `keys`' entries for `repoPath`, or for every path when `undefined` */
|
|
252
|
+
private onDropped;
|
|
199
253
|
get conflictDetection(): RepoPromiseCacheMap<ConflictDetectionCacheKey, ConflictDetectionResult>;
|
|
200
254
|
get contributors(): RepoPromiseCacheMap<string, GitContributorsResult>;
|
|
201
255
|
get contributorsLite(): RepoPromiseCacheMap<string, GitContributor[]>;
|
|
@@ -294,12 +348,17 @@ export declare class Cache implements Disposable {
|
|
|
294
348
|
isWorktree(repoPath: string): boolean;
|
|
295
349
|
/** Whether `repoPath` is currently registered (via {@link registerRepoPath}, not yet unregistered). */
|
|
296
350
|
isRegistered(repoPath: string): boolean;
|
|
351
|
+
/**
|
|
352
|
+
* The admin id (the `<id>` of `.git/worktrees/<id>`) of the registered linked worktree at `repoPath`; `undefined`
|
|
353
|
+
* for the main checkout, or a path not registered
|
|
354
|
+
*/
|
|
355
|
+
getLinkedWorktreeId(repoPath: string): string | undefined;
|
|
297
356
|
/**
|
|
298
357
|
* Monotonic per-path counter advanced whenever `repoPath` is unregistered (repo closed, worktree
|
|
299
|
-
* removed). Lets an async post-read step — e.g. the gk-config reconcile —
|
|
300
|
-
* closed (and possibly reopened) mid-flight and bail. Unlike an `isRegistered`
|
|
301
|
-
* require the caller to have registered in the first place, so it stays correct for
|
|
302
|
-
* this package that don't wire up the host's repo lifecycle.
|
|
358
|
+
* removed) or the cache is {@link reset}. Lets an async post-read step — e.g. the gk-config reconcile —
|
|
359
|
+
* detect that its target was closed (and possibly reopened) mid-flight and bail. Unlike an `isRegistered`
|
|
360
|
+
* check it doesn't require the caller to have registered in the first place, so it stays correct for
|
|
361
|
+
* consumers of this package that don't wire up the host's repo lifecycle.
|
|
303
362
|
*/
|
|
304
363
|
getCloseGeneration(repoPath: string): number;
|
|
305
364
|
/** Clears file-scoped caches (blame, diff, fileLog) for a specific path within a repo */
|
|
@@ -333,8 +392,13 @@ export declare class Cache implements Disposable {
|
|
|
333
392
|
*/
|
|
334
393
|
unregisterRepoPath(repoPath: string): void;
|
|
335
394
|
reset(): void;
|
|
336
|
-
/**
|
|
337
|
-
|
|
395
|
+
/**
|
|
396
|
+
* Applies a watcher-observed change, sharing reads still in flight (see {@link applyRepositoryChanges}).
|
|
397
|
+
* `options.movedWorktrees` is the event's `movedWorktrees`.
|
|
398
|
+
*/
|
|
399
|
+
onRepositoryChanged(repoPath: string, changes: Iterable<RepositoryChange>, options?: {
|
|
400
|
+
movedWorktrees?: ReadonlySet<string>;
|
|
401
|
+
}): void;
|
|
338
402
|
/**
|
|
339
403
|
* Clears what `changes` can have made stale for `repoPath`, advances its status clock, and reconciles a
|
|
340
404
|
* `'gkConfig'` change, returning the cache types it cleared. `inFlight` is as {@link clearCaches}
|
|
@@ -344,9 +408,20 @@ export declare class Cache implements Disposable {
|
|
|
344
408
|
* `options.worktreeOnly` clears only `repoPath`'s own entries and status clock, leaving the shared
|
|
345
409
|
* (commonPath-keyed) ones alone — for a sibling worktree once the change was applied to the worktree it ran in,
|
|
346
410
|
* which already cleared them for every worktree of the repository.
|
|
411
|
+
*
|
|
412
|
+
* `options.announced` says `changes` are core's announcement of its own write for `repoPath`, whose `'worktreeHead'`
|
|
413
|
+
* is that write's own: its rewrite of `repoPath`'s HEAD, which its `'head'` clears, or a worktree it added or
|
|
414
|
+
* removed. Other worktrees' watchers report it, so no other worktree loses its current branch for it.
|
|
415
|
+
*
|
|
416
|
+
* `options.movedWorktrees` names, by admin id (the `<id>` of `.git/worktrees/<id>`), the linked worktrees whose HEAD
|
|
417
|
+
* moved, which are all that a `'worktreeHead'` among `changes` reports: each registered one is cleared as for its
|
|
418
|
+
* own `'head'` change, and no other registered worktree with an admin id of its own is touched. Without it, any
|
|
419
|
+
* linked worktree's HEAD may have moved, so each one but `repoPath` loses its current branch.
|
|
347
420
|
*/
|
|
348
421
|
applyRepositoryChanges(repoPath: string, changes: Iterable<RepositoryChange>, inFlight: 'share' | 'evict', options?: {
|
|
422
|
+
announced?: boolean;
|
|
349
423
|
worktreeOnly?: boolean;
|
|
424
|
+
movedWorktrees?: ReadonlySet<string>;
|
|
350
425
|
}): CachedGitTypes[];
|
|
351
426
|
/**
|
|
352
427
|
* Handles a watcher-observed `'gkConfig'` change. If a reconciler is registered (see {@link setGkConfigReconciler}),
|
package/dist/git/cache.js
CHANGED
|
@@ -8,7 +8,7 @@ import { normalizePath } from "../utils/path.js";
|
|
|
8
8
|
import { PromiseCache, PromiseMap, RepoPromiseCacheMap } from "../utils/promiseCache.js";
|
|
9
9
|
import { parseBranchMetadataGkConfigKey, setBranchMetadataValue } from "./utils/branch.utils.js";
|
|
10
10
|
import { createReference } from "./utils/reference.utils.js";
|
|
11
|
-
import { getCommonRepositoryPath, getRepositoryOrWorktreePath } from "./utils/repository.utils.js";
|
|
11
|
+
import { getCommonRepositoryPath, getRepositoryOrWorktreePath, getWorktreeAdminId } from "./utils/repository.utils.js";
|
|
12
12
|
import __decorate from "../_virtual/@oxc-project+runtime/helpers/esm/decorate.js";
|
|
13
13
|
//#region ../git/src/cache.ts
|
|
14
14
|
const uriScopedCachedGitTypes = [
|
|
@@ -34,8 +34,9 @@ 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
|
-
/**
|
|
38
|
-
const
|
|
37
|
+
/** Per drop-stamped cache, paths whose last drop is tracked; the oldest beyond this folds into the all-paths floor */
|
|
38
|
+
const dropsTracked = 128;
|
|
39
|
+
const dropStampedCacheKeys = exhaustiveArray()(["currentBranchReference", "currentUser"]);
|
|
39
40
|
async function shouldEvictBlameCacheEntry(progressive) {
|
|
40
41
|
if (progressive == null) return false;
|
|
41
42
|
try {
|
|
@@ -151,20 +152,47 @@ var Cache = class Cache {
|
|
|
151
152
|
_statusGenerations = /* @__PURE__ */ new Map();
|
|
152
153
|
/** Monotonic per-path "close clock" — see {@link getCloseGeneration}. */
|
|
153
154
|
_closeGenerations = /* @__PURE__ */ new Map();
|
|
155
|
+
/** Advanced by {@link reset}, which moves every path's close clock, those it never saw included */
|
|
156
|
+
_resetGeneration = 0;
|
|
154
157
|
/** Per commonPath, the `mergeTargets` keys a checkout evicts (see {@link CachedMergeTarget.evictOnCheckout}) */
|
|
155
158
|
_mergeTargetsEvictedOnCheckout = /* @__PURE__ */ new Map();
|
|
156
159
|
/** Bumped on each checkout eviction, so a merge target resolved across one isn't kept for the next */
|
|
157
160
|
_mergeTargetCheckoutGeneration = 0;
|
|
158
161
|
/** Each merge target answer's entry as `mergeTargets` stored it, so dropping a stale answer can't drop its successor */
|
|
159
162
|
_mergeTargetStored = /* @__PURE__ */ new WeakMap();
|
|
160
|
-
/** Advanced each time
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
163
|
+
/** Advanced each time a drop-stamped cache's entries are dropped (see {@link getDropStamp}) */
|
|
164
|
+
_drops = 0;
|
|
165
|
+
/**
|
|
166
|
+
* Per drop-stamped cache, the value of {@link _drops} when each path's entry was last dropped (`byPath`) and when
|
|
167
|
+
* every path's entry was (`all`)
|
|
168
|
+
*/
|
|
169
|
+
_droppedAt = {
|
|
170
|
+
currentBranchReference: {
|
|
171
|
+
byPath: /* @__PURE__ */ new Map(),
|
|
172
|
+
all: 0
|
|
173
|
+
},
|
|
174
|
+
currentUser: {
|
|
175
|
+
byPath: /* @__PURE__ */ new Map(),
|
|
176
|
+
all: 0
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* Each ref listing's records checked out in a worktree, with the value of {@link _drops} when the listing started
|
|
181
|
+
* and the common path it listed
|
|
182
|
+
*/
|
|
183
|
+
_refsRead = /* @__PURE__ */ new WeakMap();
|
|
184
|
+
/**
|
|
185
|
+
* Unregistered linked worktrees a ref listing reported, whether or not it seeded their current branch, with the
|
|
186
|
+
* common path of the listing (see {@link dropLinkedCurrentBranches})
|
|
187
|
+
*/
|
|
188
|
+
_seededWorktrees = /* @__PURE__ */ new Map();
|
|
189
|
+
/** {@link _seededWorktrees} by common path */
|
|
190
|
+
_seededWorktreesByCommonPath = /* @__PURE__ */ new Map();
|
|
191
|
+
/**
|
|
192
|
+
* Registered linked worktrees' admin ids (the `<id>` of `.git/worktrees/<id>`), which name the worktree a
|
|
193
|
+
* `'worktreeHead'` report says moved (see {@link applyRepositoryChanges})
|
|
194
|
+
*/
|
|
195
|
+
_worktreeAdminIds = /* @__PURE__ */ new Map();
|
|
168
196
|
/**
|
|
169
197
|
* Per-commonPath snapshot of the subset of `.git/gk/config` that derived caches depend on — merge-relevant keys
|
|
170
198
|
* ({@link branchOverviewGkConfigKeysRegex}) and branch metadata keys ({@link parseBranchMetadataGkConfigKey}) —
|
|
@@ -210,7 +238,9 @@ var Cache = class Cache {
|
|
|
210
238
|
usage["cache.closeGenerations.entries.count"] = this._closeGenerations.size;
|
|
211
239
|
usage["cache.gkConfigSnapshots.entries.count"] = this._gkConfigSnapshots.size;
|
|
212
240
|
usage["cache.mergeTargetsEvictedOnCheckout.entries.count"] = this._mergeTargetsEvictedOnCheckout.size;
|
|
213
|
-
usage["cache.currentBranchDroppedAt.entries.count"] = this.
|
|
241
|
+
usage["cache.currentBranchDroppedAt.entries.count"] = this._droppedAt.currentBranchReference.byPath.size;
|
|
242
|
+
usage["cache.currentUserDroppedAt.entries.count"] = this._droppedAt.currentUser.byPath.size;
|
|
243
|
+
usage["cache.seededWorktrees.entries.count"] = this._seededWorktrees.size;
|
|
214
244
|
return usage;
|
|
215
245
|
}
|
|
216
246
|
get aheadOfBaseConfigKey() {
|
|
@@ -291,22 +321,115 @@ var Cache = class Cache {
|
|
|
291
321
|
* that `reference` was read from; any other seeds nothing
|
|
292
322
|
*/
|
|
293
323
|
setCurrentBranchReferenceIfAbsent(worktreePath, reference, record) {
|
|
294
|
-
const
|
|
295
|
-
if (
|
|
296
|
-
if (this.
|
|
324
|
+
const read = this._refsRead.get(record);
|
|
325
|
+
if (read == null || this.isDroppedSince("currentBranchReference", worktreePath, read.at)) return;
|
|
326
|
+
if (worktreePath !== read.commonPath && !this._commonPathRegistry.has(worktreePath)) this.trackSeededWorktree(worktreePath, read.commonPath);
|
|
327
|
+
if (this.currentBranchReference.get(worktreePath) != null) return;
|
|
328
|
+
this.currentBranchReference.set(worktreePath, Promise.resolve(reference));
|
|
329
|
+
}
|
|
330
|
+
trackSeededWorktree(worktreePath, commonPath) {
|
|
331
|
+
const previous = this._seededWorktrees.get(worktreePath);
|
|
332
|
+
if (previous === commonPath) return;
|
|
333
|
+
if (previous != null) this.untrackSeededWorktree(worktreePath);
|
|
334
|
+
this._seededWorktrees.set(worktreePath, commonPath);
|
|
335
|
+
let paths = this._seededWorktreesByCommonPath.get(commonPath);
|
|
336
|
+
if (paths == null) {
|
|
337
|
+
paths = /* @__PURE__ */ new Set();
|
|
338
|
+
this._seededWorktreesByCommonPath.set(commonPath, paths);
|
|
339
|
+
}
|
|
340
|
+
paths.add(worktreePath);
|
|
297
341
|
}
|
|
298
|
-
|
|
299
|
-
this.
|
|
300
|
-
if (
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
342
|
+
untrackSeededWorktree(worktreePath) {
|
|
343
|
+
const commonPath = this._seededWorktrees.get(worktreePath);
|
|
344
|
+
if (commonPath == null) return;
|
|
345
|
+
this._seededWorktrees.delete(worktreePath);
|
|
346
|
+
const paths = this._seededWorktreesByCommonPath.get(commonPath);
|
|
347
|
+
paths?.delete(worktreePath);
|
|
348
|
+
if (paths?.size === 0) this._seededWorktreesByCommonPath.delete(commonPath);
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Tracks exactly `reported` for `commonPath`. A path the listing no longer reports isn't tracked any more, so a
|
|
352
|
+
* HEAD change could no longer find it to drop its current branch: it goes with it
|
|
353
|
+
*/
|
|
354
|
+
replaceSeededWorktrees(commonPath, reported) {
|
|
355
|
+
for (const path of [...this._seededWorktreesByCommonPath.get(commonPath) ?? []]) {
|
|
356
|
+
if (reported.has(path)) continue;
|
|
357
|
+
this.untrackSeededWorktree(path);
|
|
358
|
+
this.dropCurrentBranch(path);
|
|
359
|
+
}
|
|
360
|
+
for (const path of reported) this.trackSeededWorktree(path, commonPath);
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* A `'worktreeHead'` report that doesn't say which linked worktree's HEAD moved, so each one but `repoPath` loses its
|
|
364
|
+
* current branch: those registered, and those its repository's ref listings seeded. Never the main checkout: its
|
|
365
|
+
* HEAD is the common `HEAD`, which is reported as `'head'`. With `unidentifiedOnly`, the report named a worktree that
|
|
366
|
+
* isn't registered, so a registered one with an admin id of its own keeps its current branch
|
|
367
|
+
*/
|
|
368
|
+
dropLinkedCurrentBranches(repoPath, unidentifiedOnly = false) {
|
|
369
|
+
const commonPath = this.getCommonPath(repoPath);
|
|
370
|
+
const paths = new Set(unidentifiedOnly ? this.getWorktreePaths(commonPath).filter((p) => !this._worktreeAdminIds.has(p)) : this.getWorktreePaths(commonPath));
|
|
371
|
+
for (const path of this._seededWorktreesByCommonPath.get(commonPath) ?? []) paths.add(path);
|
|
372
|
+
paths.delete(repoPath);
|
|
373
|
+
paths.delete(commonPath);
|
|
374
|
+
for (const path of paths) this.dropCurrentBranch(path);
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* A `'worktreeHead'` report naming, by admin id, the linked worktrees whose HEAD moved: each registered one but
|
|
378
|
+
* `repoPath` is cleared as for its own `'head'` change, and an id no registered worktree has is an unregistered
|
|
379
|
+
* worktree's (see {@link dropLinkedCurrentBranches})
|
|
380
|
+
*/
|
|
381
|
+
applyLinkedHeadsMoved(repoPath, ids, inFlight) {
|
|
382
|
+
const found = /* @__PURE__ */ new Set();
|
|
383
|
+
for (const path of this.getWorktreePaths(this.getCommonPath(repoPath))) {
|
|
384
|
+
const id = this._worktreeAdminIds.get(path);
|
|
385
|
+
if (id == null || !ids.has(id)) continue;
|
|
386
|
+
found.add(id);
|
|
387
|
+
if (path === repoPath) continue;
|
|
388
|
+
this.applyRepositoryChanges(path, ["head"], inFlight, { worktreeOnly: true });
|
|
389
|
+
this._caches.branches?.delete(path);
|
|
390
|
+
this._caches.gitResults?.delete(path);
|
|
391
|
+
}
|
|
392
|
+
if (found.size < ids.size) this.dropLinkedCurrentBranches(repoPath, true);
|
|
393
|
+
}
|
|
394
|
+
/** Drops what a `'branch'` eviction of `worktreePath` drops of its current branch, and nothing shared */
|
|
395
|
+
dropCurrentBranch(worktreePath) {
|
|
396
|
+
this.onDropped(worktreePath, ["currentBranchReference"]);
|
|
397
|
+
this._caches.currentBranchReference?.delete(worktreePath);
|
|
398
|
+
this._caches.branch?.delete(worktreePath);
|
|
399
|
+
this._caches.branches?.delete(worktreePath);
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* A stamp to take before a read, to later ask {@link isDroppedSince} whether the read's entry was dropped mid-flight.
|
|
403
|
+
* With `key` and `repoPath`, the stamp of that entry's last drop, which only a drop of it advances, so it can key a
|
|
404
|
+
* read that calls with no drop between them share
|
|
405
|
+
*/
|
|
406
|
+
getDropStamp(key, repoPath) {
|
|
407
|
+
if (key == null || repoPath == null) return this._drops;
|
|
408
|
+
const droppedAt = this._droppedAt[key];
|
|
409
|
+
return Math.max(droppedAt.all, droppedAt.byPath.get(repoPath) ?? 0);
|
|
410
|
+
}
|
|
411
|
+
/** Whether `key`'s entry for `repoPath` was dropped after `stamp` was taken by {@link getDropStamp} */
|
|
412
|
+
isDroppedSince(key, repoPath, stamp) {
|
|
413
|
+
const droppedAt = this._droppedAt[key];
|
|
414
|
+
return stamp < droppedAt.all || stamp < (droppedAt.byPath.get(repoPath) ?? 0);
|
|
415
|
+
}
|
|
416
|
+
/** Stamps a drop of `keys`' entries for `repoPath`, or for every path when `undefined` */
|
|
417
|
+
onDropped(repoPath, keys = dropStampedCacheKeys) {
|
|
418
|
+
if (!keys.length) return;
|
|
419
|
+
this._drops++;
|
|
420
|
+
for (const key of keys) {
|
|
421
|
+
const droppedAt = this._droppedAt[key];
|
|
422
|
+
if (repoPath == null) {
|
|
423
|
+
droppedAt.all = this._drops;
|
|
424
|
+
droppedAt.byPath.clear();
|
|
425
|
+
continue;
|
|
426
|
+
}
|
|
427
|
+
droppedAt.byPath.delete(repoPath);
|
|
428
|
+
droppedAt.byPath.set(repoPath, this._drops);
|
|
429
|
+
if (droppedAt.byPath.size > dropsTracked) {
|
|
430
|
+
const [oldestPath, oldestAt] = droppedAt.byPath.entries().next().value;
|
|
431
|
+
droppedAt.byPath.delete(oldestPath);
|
|
432
|
+
droppedAt.all = Math.max(droppedAt.all, oldestAt);
|
|
310
433
|
}
|
|
311
434
|
}
|
|
312
435
|
}
|
|
@@ -565,7 +688,7 @@ var Cache = class Cache {
|
|
|
565
688
|
if (types.includes("worktrees") || types.includes("worktreeList")) keysToClear.add("worktrees");
|
|
566
689
|
if (types.some((t) => t !== "gitignore" && t !== "gkConfig" && t !== "providers" && t !== "worktreeList")) keysToClear.add("gitResults");
|
|
567
690
|
}
|
|
568
|
-
|
|
691
|
+
this.onDropped(repoPath, dropStampedCacheKeys.filter((k) => keysToClear.has(k)));
|
|
569
692
|
for (const key of keysToClear) {
|
|
570
693
|
const cache = this._caches[key];
|
|
571
694
|
if (cache == null) continue;
|
|
@@ -667,14 +790,21 @@ var Cache = class Cache {
|
|
|
667
790
|
return this._commonPathRegistry.has(repoPath);
|
|
668
791
|
}
|
|
669
792
|
/**
|
|
793
|
+
* The admin id (the `<id>` of `.git/worktrees/<id>`) of the registered linked worktree at `repoPath`; `undefined`
|
|
794
|
+
* for the main checkout, or a path not registered
|
|
795
|
+
*/
|
|
796
|
+
getLinkedWorktreeId(repoPath) {
|
|
797
|
+
return this._worktreeAdminIds.get(repoPath);
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
670
800
|
* Monotonic per-path counter advanced whenever `repoPath` is unregistered (repo closed, worktree
|
|
671
|
-
* removed). Lets an async post-read step — e.g. the gk-config reconcile —
|
|
672
|
-
* closed (and possibly reopened) mid-flight and bail. Unlike an `isRegistered`
|
|
673
|
-
* require the caller to have registered in the first place, so it stays correct for
|
|
674
|
-
* this package that don't wire up the host's repo lifecycle.
|
|
801
|
+
* removed) or the cache is {@link reset}. Lets an async post-read step — e.g. the gk-config reconcile —
|
|
802
|
+
* detect that its target was closed (and possibly reopened) mid-flight and bail. Unlike an `isRegistered`
|
|
803
|
+
* check it doesn't require the caller to have registered in the first place, so it stays correct for
|
|
804
|
+
* consumers of this package that don't wire up the host's repo lifecycle.
|
|
675
805
|
*/
|
|
676
806
|
getCloseGeneration(repoPath) {
|
|
677
|
-
return this._closeGenerations.get(repoPath) ?? 0;
|
|
807
|
+
return (this._closeGenerations.get(repoPath) ?? 0) + this._resetGeneration;
|
|
678
808
|
}
|
|
679
809
|
/** Clears file-scoped caches (blame, diff, fileLog) for a specific path within a repo */
|
|
680
810
|
clearForPath(repoPath, path, ...types) {
|
|
@@ -698,6 +828,10 @@ var Cache = class Cache {
|
|
|
698
828
|
}
|
|
699
829
|
if (previousCommonPath == null && normalizedPath !== commonPath) this.evictReadsBeforeRegistration(normalizedPath);
|
|
700
830
|
this._commonPathRegistry.set(normalizedPath, commonPath);
|
|
831
|
+
this.untrackSeededWorktree(normalizedPath);
|
|
832
|
+
const adminId = gitDir.commonUri != null && normalizedPath !== commonPath ? getWorktreeAdminId(gitDir.uri.path, gitDir.commonUri.path) : void 0;
|
|
833
|
+
if (adminId != null) this._worktreeAdminIds.set(normalizedPath, adminId);
|
|
834
|
+
else this._worktreeAdminIds.delete(normalizedPath);
|
|
701
835
|
let worktrees = this._worktreesByCommonPath.get(commonPath);
|
|
702
836
|
if (worktrees == null) {
|
|
703
837
|
worktrees = /* @__PURE__ */ new Set();
|
|
@@ -744,8 +878,8 @@ var Cache = class Cache {
|
|
|
744
878
|
*/
|
|
745
879
|
unregisterRepoPath(repoPath) {
|
|
746
880
|
this.incrementStatusGeneration(repoPath);
|
|
747
|
-
this._closeGenerations.set(repoPath, this.
|
|
748
|
-
this.
|
|
881
|
+
this._closeGenerations.set(repoPath, (this._closeGenerations.get(repoPath) ?? 0) + 1);
|
|
882
|
+
this.onDropped(repoPath);
|
|
749
883
|
const commonPath = this._commonPathRegistry.get(repoPath) ?? repoPath;
|
|
750
884
|
const worktrees = this._worktreesByCommonPath.get(commonPath);
|
|
751
885
|
const isLastWorktree = worktrees == null || worktrees.size <= 1;
|
|
@@ -775,7 +909,13 @@ var Cache = class Cache {
|
|
|
775
909
|
if (isLastWorktree) {
|
|
776
910
|
this._gkConfigSnapshots.delete(commonPath);
|
|
777
911
|
this._mergeTargetsEvictedOnCheckout.delete(commonPath);
|
|
912
|
+
for (const path of [...this._seededWorktreesByCommonPath.get(commonPath) ?? []]) {
|
|
913
|
+
this.untrackSeededWorktree(path);
|
|
914
|
+
this.dropCurrentBranch(path);
|
|
915
|
+
}
|
|
778
916
|
}
|
|
917
|
+
this.untrackSeededWorktree(repoPath);
|
|
918
|
+
this._worktreeAdminIds.delete(repoPath);
|
|
779
919
|
this._commonPathRegistry.delete(repoPath);
|
|
780
920
|
if (worktrees != null) {
|
|
781
921
|
worktrees.delete(repoPath);
|
|
@@ -783,24 +923,30 @@ var Cache = class Cache {
|
|
|
783
923
|
}
|
|
784
924
|
}
|
|
785
925
|
reset() {
|
|
786
|
-
|
|
926
|
+
this._resetGeneration++;
|
|
787
927
|
this._commonPathRegistry.clear();
|
|
788
928
|
this._worktreesByCommonPath.clear();
|
|
789
929
|
this._statusGenerations.clear();
|
|
790
930
|
this._gkConfigSnapshots.clear();
|
|
791
931
|
this._mergeTargetsEvictedOnCheckout.clear();
|
|
932
|
+
this._seededWorktrees.clear();
|
|
933
|
+
this._seededWorktreesByCommonPath.clear();
|
|
934
|
+
this._worktreeAdminIds.clear();
|
|
792
935
|
this._gkConfigReconciler = void 0;
|
|
793
936
|
this._caches = createEmptyCaches();
|
|
794
|
-
this.
|
|
937
|
+
this.onDropped(void 0);
|
|
795
938
|
}
|
|
796
|
-
/**
|
|
797
|
-
|
|
939
|
+
/**
|
|
940
|
+
* Applies a watcher-observed change, sharing reads still in flight (see {@link applyRepositoryChanges}).
|
|
941
|
+
* `options.movedWorktrees` is the event's `movedWorktrees`.
|
|
942
|
+
*/
|
|
943
|
+
onRepositoryChanged(repoPath, changes, options) {
|
|
798
944
|
const changesSet = new Set(changes);
|
|
799
945
|
if (changesSet.has("unknown") || changesSet.has("closed")) {
|
|
800
946
|
this.unregisterRepoPath(repoPath);
|
|
801
947
|
return;
|
|
802
948
|
}
|
|
803
|
-
this.applyRepositoryChanges(repoPath, changesSet, "share");
|
|
949
|
+
this.applyRepositoryChanges(repoPath, changesSet, "share", { movedWorktrees: options?.movedWorktrees });
|
|
804
950
|
}
|
|
805
951
|
/**
|
|
806
952
|
* Clears what `changes` can have made stale for `repoPath`, advances its status clock, and reconciles a
|
|
@@ -811,6 +957,15 @@ var Cache = class Cache {
|
|
|
811
957
|
* `options.worktreeOnly` clears only `repoPath`'s own entries and status clock, leaving the shared
|
|
812
958
|
* (commonPath-keyed) ones alone — for a sibling worktree once the change was applied to the worktree it ran in,
|
|
813
959
|
* which already cleared them for every worktree of the repository.
|
|
960
|
+
*
|
|
961
|
+
* `options.announced` says `changes` are core's announcement of its own write for `repoPath`, whose `'worktreeHead'`
|
|
962
|
+
* is that write's own: its rewrite of `repoPath`'s HEAD, which its `'head'` clears, or a worktree it added or
|
|
963
|
+
* removed. Other worktrees' watchers report it, so no other worktree loses its current branch for it.
|
|
964
|
+
*
|
|
965
|
+
* `options.movedWorktrees` names, by admin id (the `<id>` of `.git/worktrees/<id>`), the linked worktrees whose HEAD
|
|
966
|
+
* moved, which are all that a `'worktreeHead'` among `changes` reports: each registered one is cleared as for its
|
|
967
|
+
* own `'head'` change, and no other registered worktree with an admin id of its own is touched. Without it, any
|
|
968
|
+
* linked worktree's HEAD may have moved, so each one but `repoPath` loses its current branch.
|
|
814
969
|
*/
|
|
815
970
|
applyRepositoryChanges(repoPath, changes, inFlight, options) {
|
|
816
971
|
const worktreeOnly = options?.worktreeOnly ?? false;
|
|
@@ -851,8 +1006,13 @@ var Cache = class Cache {
|
|
|
851
1006
|
}
|
|
852
1007
|
if (hasAny("stash")) types.add("stashes");
|
|
853
1008
|
if (hasAny("tags")) types.add("tags");
|
|
854
|
-
if (hasAny("worktreeHead"))
|
|
855
|
-
|
|
1009
|
+
if (hasAny("worktreeHead")) {
|
|
1010
|
+
types.add("worktrees");
|
|
1011
|
+
if (!worktreeOnly && !options?.announced) {
|
|
1012
|
+
if (options?.movedWorktrees != null) this.applyLinkedHeadsMoved(repoPath, options.movedWorktrees, inFlight);
|
|
1013
|
+
else this.dropLinkedCurrentBranches(repoPath);
|
|
1014
|
+
}
|
|
1015
|
+
} else if (hasAny("worktrees")) types.add("worktreeList");
|
|
856
1016
|
if (types.size) this.clearCachesCore(inFlight, repoPath, [...types], worktreeOnly);
|
|
857
1017
|
return [...types];
|
|
858
1018
|
}
|
|
@@ -1378,9 +1538,20 @@ var Cache = class Cache {
|
|
|
1378
1538
|
getRefs(repoPath, factory, cancellation) {
|
|
1379
1539
|
const commonPath = this.getCommonPath(repoPath);
|
|
1380
1540
|
return this.refs.getOrCreate(commonPath, async (cacheable, signal) => {
|
|
1381
|
-
const
|
|
1541
|
+
const read = {
|
|
1542
|
+
at: this.getDropStamp(),
|
|
1543
|
+
commonPath
|
|
1544
|
+
};
|
|
1545
|
+
const closeGeneration = this.getCloseGeneration(commonPath);
|
|
1382
1546
|
const records = await factory(commonPath, cacheable, signal);
|
|
1383
|
-
|
|
1547
|
+
const unregistered = /* @__PURE__ */ new Set();
|
|
1548
|
+
for (const record of records) {
|
|
1549
|
+
if (!record.worktreePath) continue;
|
|
1550
|
+
this._refsRead.set(record, read);
|
|
1551
|
+
const worktreePath = normalizePath(record.worktreePath);
|
|
1552
|
+
if (worktreePath !== commonPath && !this._commonPathRegistry.has(worktreePath)) unregistered.add(worktreePath);
|
|
1553
|
+
}
|
|
1554
|
+
if (!cacheable.invalidated && !signal?.aborted && this.getCloseGeneration(commonPath) === closeGeneration) this.replaceSeededWorktrees(commonPath, unregistered);
|
|
1384
1555
|
return records;
|
|
1385
1556
|
}, cancellation);
|
|
1386
1557
|
}
|