@gitkraken/core-gitlens 0.32.0 → 0.34.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.
Files changed (109) hide show
  1. package/CHANGELOG.md +42 -1
  2. package/dist/git/cache.d.ts +121 -15
  3. package/dist/git/cache.js +316 -74
  4. package/dist/git/cache.js.map +1 -1
  5. package/dist/git/context.d.ts +3 -1
  6. package/dist/git/context.js.map +1 -1
  7. package/dist/git/errors.d.ts +3 -1
  8. package/dist/git/errors.js +4 -1
  9. package/dist/git/errors.js.map +1 -1
  10. package/dist/git/models/pullRequest.d.ts +90 -1
  11. package/dist/git/models/pullRequest.js +18 -2
  12. package/dist/git/models/pullRequest.js.map +1 -1
  13. package/dist/git/models/repositoryIdentities.d.ts +0 -1
  14. package/dist/git/models/repositoryIdentities.js +1 -4
  15. package/dist/git/models/repositoryIdentities.js.map +1 -1
  16. package/dist/git/providers/provider.d.ts +7 -0
  17. package/dist/git/providers/shared/remotes.js +2 -0
  18. package/dist/git/providers/shared/remotes.js.map +1 -1
  19. package/dist/git/remotes/gitlab.js +15 -9
  20. package/dist/git/remotes/gitlab.js.map +1 -1
  21. package/dist/git/service.js +4 -1
  22. package/dist/git/service.js.map +1 -1
  23. package/dist/git/utils/pullRequest.utils.d.ts +72 -1
  24. package/dist/git/utils/pullRequest.utils.js +99 -1
  25. package/dist/git/utils/pullRequest.utils.js.map +1 -1
  26. package/dist/git/utils/repository.utils.d.ts +16 -0
  27. package/dist/git/utils/repository.utils.js +37 -2
  28. package/dist/git/utils/repository.utils.js.map +1 -1
  29. package/dist/git/watching/changeEvent.d.ts +13 -3
  30. package/dist/git/watching/changeEvent.js +19 -4
  31. package/dist/git/watching/changeEvent.js.map +1 -1
  32. package/dist/git/watching/gitDirPoller.d.ts +10 -1
  33. package/dist/git/watching/gitDirPoller.js +9 -3
  34. package/dist/git/watching/gitDirPoller.js.map +1 -1
  35. package/dist/git/watching/unwatchedCacheValidator.d.ts +144 -0
  36. package/dist/git/watching/unwatchedCacheValidator.js +884 -0
  37. package/dist/git/watching/unwatchedCacheValidator.js.map +1 -0
  38. package/dist/git/watching/watchGroup.d.ts +6 -2
  39. package/dist/git/watching/watchGroup.js +35 -24
  40. package/dist/git/watching/watchGroup.js.map +1 -1
  41. package/dist/git/watching/watchService.d.ts +27 -1
  42. package/dist/git/watching/watchService.js +60 -17
  43. package/dist/git/watching/watchService.js.map +1 -1
  44. package/dist/git/watching/watchSession.d.ts +29 -12
  45. package/dist/git/watching/watchSession.js +52 -21
  46. package/dist/git/watching/watchSession.js.map +1 -1
  47. package/dist/git/watching/worktreeSummary.js +7 -7
  48. package/dist/git/watching/worktreeSummary.js.map +1 -1
  49. package/dist/git-cli/cliGitProvider.d.ts +28 -2
  50. package/dist/git-cli/cliGitProvider.js +63 -20
  51. package/dist/git-cli/cliGitProvider.js.map +1 -1
  52. package/dist/git-cli/exec/commandClassifier.d.ts +31 -1
  53. package/dist/git-cli/exec/commandClassifier.js +67 -16
  54. package/dist/git-cli/exec/commandClassifier.js.map +1 -1
  55. package/dist/git-cli/exec/git.d.ts +46 -2
  56. package/dist/git-cli/exec/git.js +87 -9
  57. package/dist/git-cli/exec/git.js.map +1 -1
  58. package/dist/git-cli/exec/gitDirResolver.d.ts +11 -0
  59. package/dist/git-cli/exec/gitDirResolver.js +34 -1
  60. package/dist/git-cli/exec/gitDirResolver.js.map +1 -1
  61. package/dist/git-cli/exec/gitQueue.js +2 -28
  62. package/dist/git-cli/exec/gitQueue.js.map +1 -1
  63. package/dist/git-cli/providers/branches.d.ts +1 -0
  64. package/dist/git-cli/providers/branches.js +21 -10
  65. package/dist/git-cli/providers/branches.js.map +1 -1
  66. package/dist/git-cli/providers/config.d.ts +15 -1
  67. package/dist/git-cli/providers/config.js +67 -22
  68. package/dist/git-cli/providers/config.js.map +1 -1
  69. package/dist/git-cli/providers/pausedOperations.d.ts +1 -0
  70. package/dist/git-cli/providers/pausedOperations.js +4 -0
  71. package/dist/git-cli/providers/pausedOperations.js.map +1 -1
  72. package/dist/git-cli/providers/revision.js +2 -0
  73. package/dist/git-cli/providers/revision.js.map +1 -1
  74. package/dist/git-cli/providers/worktrees.js +36 -10
  75. package/dist/git-cli/providers/worktrees.js.map +1 -1
  76. package/dist/git-cli/service.d.ts +25 -1
  77. package/dist/git-cli/service.js +46 -1
  78. package/dist/git-cli/service.js.map +1 -1
  79. package/dist/plus/ai/errors.d.ts +8 -2
  80. package/dist/plus/ai/errors.js +15 -3
  81. package/dist/plus/ai/errors.js.map +1 -1
  82. package/dist/plus/git-github/api/github.d.ts +51 -1
  83. package/dist/plus/git-github/api/github.js +276 -3
  84. package/dist/plus/git-github/api/github.js.map +1 -1
  85. package/dist/plus/git-github/models.d.ts +54 -1
  86. package/dist/plus/git-github/models.js +48 -3
  87. package/dist/plus/git-github/models.js.map +1 -1
  88. package/dist/plus/integrations/fieldPresence.d.ts +6 -1
  89. package/dist/plus/integrations/fieldPresence.js +19 -9
  90. package/dist/plus/integrations/fieldPresence.js.map +1 -1
  91. package/dist/plus/integrations/models/gitHostIntegration.d.ts +26 -1
  92. package/dist/plus/integrations/models/gitHostIntegration.js +51 -0
  93. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  94. package/dist/plus/integrations/models/integration.d.ts +15 -2
  95. package/dist/plus/integrations/models/integration.js +1 -1
  96. package/dist/plus/integrations/models/integration.js.map +1 -1
  97. package/dist/plus/integrations/providers/github.d.ts +16 -1
  98. package/dist/plus/integrations/providers/github.js +53 -1
  99. package/dist/plus/integrations/providers/github.js.map +1 -1
  100. package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +10 -0
  101. package/dist/plus/integrations/providers/gitlab/gitlab.js +62 -15
  102. package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
  103. package/dist/plus/integrations/providers/gitlab/gitlab.utils.d.ts +8 -0
  104. package/dist/plus/integrations/providers/gitlab/gitlab.utils.js +32 -16
  105. package/dist/plus/integrations/providers/gitlab/gitlab.utils.js.map +1 -1
  106. package/dist/plus/integrations/reads/etag.js +11 -0
  107. package/dist/plus/integrations/reads/etag.js.map +1 -1
  108. package/docs/integrations.md +39 -6
  109. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -6,6 +6,45 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.34.0] - 2026-11-08
10
+
11
+ ### Added
12
+
13
+ - Adds `mergeQueue` (`PullRequestMergeQueueEntry`) to pull requests read from GitHub.com, set while a pull request waits in its base branch's merge queue: its `state` (`PullRequestMergeQueueState`), `enqueuedAt`, `estimatedMergeAt` when GitHub gives an estimate (GitHub's time remaining, fixed to a date when the pull request is read, so a held entry counts down; it may be past on an entry held a while), and the queue's `url`. A queued pull request's `state` stays `opened`. Field presence gains a `mergeQueue` group, `fetched` wherever `stack` is and `unavailable` on GitHub Enterprise, which isn't asked for it, and on every other provider; absent `mergeQueue` means not queued only where that group is `fetched`. Adds `isPullRequestInMergeQueue` to tell whether an open pull request is queued. On GitHub.com a queued pull request's batch-read etag also covers its queue state and enqueue time, which GitHub changes without moving the update time, with no `etagIncludes` needed; the cheap check selects them there, and a pull request that isn't queued keeps exactly the etag it had before, under any `etagIncludes` (git, plus/git-github, plus/integrations)
14
+ - Adds `position` (1-based, in enqueue order) to `PullRequestMergeQueueEntry`, and `mergeQueueRequired` and `mergeQueueRemoval` (`PullRequestMergeQueueRemoval`: GitHub's raw `reason` and `removedAt`) to pull requests read from GitHub.com, all under the `mergeQueue` field presence group. `mergeQueueRemoval` is set only while the pull request's latest merge-queue event is a removal that didn't merge it; adds `getPullRequestMergeQueueRemovalKind` to classify its reason (`failed`, `manual`, `other`) and `isPullRequestMergeQueueRemovalCurrent` to tell whether it still describes the pull request (open, not queued, not updated since). The read selects one more connection per pull request (`timelineItems(last: 1)`) against github.com, costing one more rate-limit request per row. On GitHub.com a removed pull request's batch-read etag also covers its removal time, so a pull request that joined and left the queue between two checks reads as changed; any other pull request keeps exactly the etag it had, under any `etagIncludes`. On upgrade, a pull request whose latest merge-queue event is already such a removal gets a new etag once, so a stored etag reads it as changed one time (git, plus/git-github, plus/integrations)
15
+ - Adds `GitHubApi.enqueuePullRequest` and `dequeuePullRequest`, which add a pull request to its merge queue at the expected head and remove it, on GitHub.com only, answering a `PullRequestMergeQueueActionResult`: `queued` (with the new entry), `dequeued`, or `failed` with a `PullRequestMergeQueueActionFailureReason` (`already-queued`, `head-changed`, `not-allowed`, `permission`, `unsupported`, `unknown`) and GitHub's message, for logs. A FORBIDDEN refusal is the account's `permission` and doesn't prompt to re-authenticate. Neither is ever retried. `GitHostIntegration` gains `enqueuePullRequest` and `dequeuePullRequest` beside `mergePullRequest`, answering `unsupported` on every other host; like `mergePullRequest`, it is reachable through neither `index.js` nor `lite.js` (plus/git-github, plus/integrations)
16
+ - Adds per-repository trust: `GitOptions.isTrusted` now takes the path a run targets (`(repoPath: string) => boolean`) so a host serving several repositories can refuse one while the others run. A refused path rejects with `WorkspaceUntrustedError` before any git process starts, for `run` and `stream` alike. The path is the run's `cwd` resolved to an absolute, normalized path (the process's working directory when it has none or an empty one), so a `..` segment can't lead it out of a trusted folder, and, when a run re-scopes itself with `-C`, that target too, even behind a global option that takes a separate value such as `--attr-source`; an absolute `-C` target is asked about alone, since git applies it before reading anything, so the starting directory isn't. A working directory that no longer exists (the process's own was deleted) refuses with `WorkspaceUntrustedError`, and `WorkspaceUntrustedError.path` carries the path the host refused (none for that case). A run that moves its repository another way is asked about where it moves it as well: a leading `--git-dir` (the git dir path itself, so `/repo/.git` for a host that trusts `/repo`) or `--work-tree`, and `GIT_DIR`, `GIT_COMMON_DIR` or `GIT_WORK_TREE` in the run's own `env` (every key spelling one, without regard to case), each resolved against the directory the run ends up in, and one refused path refuses the run. Only an answer of exactly `true` trusts; a predicate that returns anything else refuses, and no predicate trusts every path. The config provider's no-git fallbacks (`getRepositoryInfo`'s empty answer, reading git dirs without git) apply per repository. A trusted bare repository inside a refused folder still resolves as bare, rather than rejecting. A refused path's fallback git dir and its current user aren't kept, and `onGitDirResolveFailed` doesn't fire for it, so once the host trusts the path the next call reads them; a host that starts trusting a path should still reset that repository's caches, since nothing tells core the answer changed. `CliGitProvider` and `createCliGitService` now keep a host's `gitOptions.isTrusted` instead of overwriting it; a `context.workspace.isTrusted` flag still wins and answers for every path, so a single-workspace host such as VS Code behaves as before. Adds `Git.isPathTrusted(repoPath)` (git-cli)
17
+ - Adds `validateUnwatchedCaches` to `createCliGitService`, off by default: before a read of a cache that only a change report, core's own writes or an explicit clear drops in time (branches, current branch and its reference, refs and their tips, tags, remotes, worktrees, stashes, gk config, paused operation, and the best remotes, default and base branch names, merge targets, branch metadata, initial commit and resolved revisions derived from them, commit counts, reachability, branch overviews, contributors, the current user, the ahead-of-base and gitignore config listings, and the git runs core caches, many keyed by ref names), a repository whose `.git` directory nothing watches has the files a watcher would report statted, with its ref directories and worktree admin entries listed, and what moved applied as a watcher event would, at most once per 250ms per repository; a watched repository costs nothing. A repository is validated even when nothing resolved its git dir yet, which is then read from its own files without running git (one only git can answer for, as a bare repository or a submodule, isn't validated until a read resolves it, and its files are looked at again for it only every 30 seconds), and adding, removing or changing a worktree under an `ignoredWorktreeFolders` folder clears nothing. A read waits at most 1000ms for those stats (`validateUnwatchedCaches: { timeoutMs }` changes it) and is then served from the cache as is, its reads not waiting again until that validation settles; the stats run one at a time per repository and two at once overall, and one outstanding past that timeout stops counting against the two, so a hung mount doesn't stop other repositories' validations, while the stats hold no more than all but two of Node's file-system threads (`UV_THREADPOOL_SIZE`, default 4; the validator's `maxFsThreads`), so at the default pool size two hung stats still stop them. A linked worktree's first validation reports only what its own git dir can, leaving the shared entries to the common git dir's. A path that can't be read counts as moved as it becomes unreadable and again once it reads, and a directory that can't be listed (or a ref folder nested too deep for one validation) is listed again at the next validation, so neither clears every cache on each read. Built from `UnwatchedCacheValidator` (`watching/unwatchedCacheValidator.js`), which validates again as a watcher attaches and, as one detaches or at the next validation once it is suspended, applies what moved in a common git dir that a sibling's validation left to it; `RepositoryWatchService.isRepoWatched` and `onDidChangeRepoWatched`, which tell when a repository's `.git` directory starts and stops being watched (a repository whose watch session is suspended counts as unwatched meanwhile, without being announced); `Cache.setReadValidator`, which registers what runs before those reads (and, as its second argument, what it costs, which `Cache.getResourceUsage` reports: `UnwatchedCacheValidator.getResourceUsage` counts the validations run and those that cleared anything, the reads served as is after a timed-out wait, the git dir lookups and file-system calls, the calls stuck on a hung mount and the git dirs kept, under `unwatchedValidation.*`), with `Cache.validateBeforeRead` for a read made without the cache's wrappers; and `ConfigGitSubProvider.resolveGitDirWithoutGit`, which caches a git dir read from a repository's own files, never running git (rejecting when its answer may differ if asked again soon: a read that failed in a way that may pass, as a share that timed out, or a repository closed mid-read). `GitDirProbeTarget` takes an `isRacy` option, under which a reading too recent to trust counts as moved at the next poll, given the path it was read from; the validator trusts a whole-second reading once two seconds passed since it first saw it, so a file system whose clock runs ahead of ours doesn't have every reading counted as moved (git, git-cli)
18
+
19
+ ### Fixed
20
+
21
+ - Fixes `getCommitReachability` keeping the tags a commit is reachable from across a tag created or deleted: a `'tags'` change now clears the reachability cache too, as a branch change does (git)
22
+
23
+ ## [0.33.0] - 2026-11-06
24
+
25
+ ### Added
26
+
27
+ - 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)
28
+ - 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)
29
+
30
+ ### Removed
31
+
32
+ - **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`
33
+
34
+ ### Fixed
35
+
36
+ - 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)
37
+ - 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)
38
+ - 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)
39
+ - 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)
40
+ - 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)
41
+ - 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)
42
+ - 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)
43
+ - 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)
44
+ - 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)
45
+ - 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)
46
+ - 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)
47
+
9
48
  ## [0.32.0] - 2026-11-05
10
49
 
11
50
  ### Changed
@@ -1148,7 +1187,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1148
1187
 
1149
1188
  - 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
1189
 
1151
- [unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.32.0...HEAD
1190
+ [unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.34.0...HEAD
1191
+ [0.34.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.33.0...gitkraken:releases/core/v0.34.0
1192
+ [0.33.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.32.0...gitkraken:releases/core/v0.33.0
1152
1193
  [0.32.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.31.0...gitkraken:releases/core/v0.32.0
1153
1194
  [0.31.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.30.0...gitkraken:releases/core/v0.31.0
1154
1195
  [0.30.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.29.0...gitkraken:releases/core/v0.30.0
@@ -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 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;
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}) —
@@ -162,8 +185,34 @@ export declare class Cache implements Disposable {
162
185
  * falls back to the coarse clear.
163
186
  */
164
187
  private _gkConfigReconciler;
188
+ /** Run before each read of a cache with no expiry (see {@link setReadValidator}) */
189
+ private _readValidator;
190
+ /** What the read validator reports among {@link getResourceUsage}'s */
191
+ private _readValidatorUsage;
165
192
  [Symbol.dispose](): void;
166
193
  dispose(): void;
194
+ /**
195
+ * Registers what runs before each read of the caches that only a change report, core's own writes or an explicit
196
+ * clear drop in time (the branches, current branch and its reference, refs and their tips, tags, remotes, worktrees,
197
+ * stashes, gk config, paused operation, and what is derived from them: default and base branch names, merge
198
+ * targets, branch metadata, the initial commit, resolved revisions, commit counts, reachability, branch overviews,
199
+ * contributors, the current user, the ahead-of-base and gitignore config listings, and the cached git runs). It
200
+ * answers `undefined` when the read can go ahead at once, or a promise that settles, never rejecting, once it
201
+ * applied whatever changed (as {@link onRepositoryChanged}), after which the read runs. A host that watches only
202
+ * some repositories registers one that checks the others' git dirs (see `UnwatchedCacheValidator`); `undefined`
203
+ * removes it. Kept across {@link reset}: it is host wiring, not cached state. `getResourceUsage` reports what it
204
+ * costs among {@link getResourceUsage}'s.
205
+ */
206
+ setReadValidator(validator: ((repoPath: string) => Promise<void> | undefined) | undefined, getResourceUsage?: () => ResourceUsage): void;
207
+ /**
208
+ * Runs the read validator (see {@link setReadValidator}) for a read of one of its caches made without the wrappers
209
+ * here: `undefined` when the read can go ahead at once, or a promise (that never rejects) to read after
210
+ */
211
+ validateBeforeRead(repoPath: string): Promise<void> | undefined;
212
+ /** Runs `read` once the read validator let `repoPath` be read, at once when it has nothing to wait for */
213
+ private readValidated;
214
+ /** A map read directly by the providers, whose every `getOrCreate` is validated as the cache's own reads are */
215
+ private createValidatedRepoPromiseCacheMap;
167
216
  /** Resource usage retained by instantiated sub-caches and their bookkeeping maps. */
168
217
  getResourceUsage(): ResourceUsage;
169
218
  get aheadOfBaseConfigKey(): PromiseMap<RepoPath, string | undefined>;
@@ -195,7 +244,38 @@ export declare class Cache implements Disposable {
195
244
  * that `reference` was read from; any other seeds nothing
196
245
  */
197
246
  setCurrentBranchReferenceIfAbsent(worktreePath: string, reference: GitBranchReference | undefined, record: RefRecord): void;
198
- private onCurrentBranchReferencesDropped;
247
+ private trackSeededWorktree;
248
+ private untrackSeededWorktree;
249
+ /**
250
+ * Tracks exactly `reported` for `commonPath`. A path the listing no longer reports isn't tracked any more, so a
251
+ * HEAD change could no longer find it to drop its current branch: it goes with it
252
+ */
253
+ private replaceSeededWorktrees;
254
+ /**
255
+ * A `'worktreeHead'` report that doesn't say which linked worktree's HEAD moved, so each one but `repoPath` loses its
256
+ * current branch: those registered, and those its repository's ref listings seeded. Never the main checkout: its
257
+ * HEAD is the common `HEAD`, which is reported as `'head'`. With `unidentifiedOnly`, the report named a worktree that
258
+ * isn't registered, so a registered one with an admin id of its own keeps its current branch
259
+ */
260
+ private dropLinkedCurrentBranches;
261
+ /**
262
+ * A `'worktreeHead'` report naming, by admin id, the linked worktrees whose HEAD moved: each registered one but
263
+ * `repoPath` is cleared as for its own `'head'` change, and an id no registered worktree has is an unregistered
264
+ * worktree's (see {@link dropLinkedCurrentBranches})
265
+ */
266
+ private applyLinkedHeadsMoved;
267
+ /** Drops what a `'branch'` eviction of `worktreePath` drops of its current branch, and nothing shared */
268
+ private dropCurrentBranch;
269
+ /**
270
+ * A stamp to take before a read, to later ask {@link isDroppedSince} whether the read's entry was dropped mid-flight.
271
+ * With `key` and `repoPath`, the stamp of that entry's last drop, which only a drop of it advances, so it can key a
272
+ * read that calls with no drop between them share
273
+ */
274
+ getDropStamp(key?: DropStampedCacheKey, repoPath?: string): number;
275
+ /** Whether `key`'s entry for `repoPath` was dropped after `stamp` was taken by {@link getDropStamp} */
276
+ isDroppedSince(key: DropStampedCacheKey, repoPath: string, stamp: number): boolean;
277
+ /** Stamps a drop of `keys`' entries for `repoPath`, or for every path when `undefined` */
278
+ private onDropped;
199
279
  get conflictDetection(): RepoPromiseCacheMap<ConflictDetectionCacheKey, ConflictDetectionResult>;
200
280
  get contributors(): RepoPromiseCacheMap<string, GitContributorsResult>;
201
281
  get contributorsLite(): RepoPromiseCacheMap<string, GitContributor[]>;
@@ -294,12 +374,17 @@ export declare class Cache implements Disposable {
294
374
  isWorktree(repoPath: string): boolean;
295
375
  /** Whether `repoPath` is currently registered (via {@link registerRepoPath}, not yet unregistered). */
296
376
  isRegistered(repoPath: string): boolean;
377
+ /**
378
+ * The admin id (the `<id>` of `.git/worktrees/<id>`) of the registered linked worktree at `repoPath`; `undefined`
379
+ * for the main checkout, or a path not registered
380
+ */
381
+ getLinkedWorktreeId(repoPath: string): string | undefined;
297
382
  /**
298
383
  * 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 — detect that its target was
300
- * closed (and possibly reopened) mid-flight and bail. Unlike an `isRegistered` check it doesn't
301
- * require the caller to have registered in the first place, so it stays correct for consumers of
302
- * this package that don't wire up the host's repo lifecycle.
384
+ * removed) or the cache is {@link reset}. Lets an async post-read step — e.g. the gk-config reconcile —
385
+ * detect that its target was closed (and possibly reopened) mid-flight and bail. Unlike an `isRegistered`
386
+ * check it doesn't require the caller to have registered in the first place, so it stays correct for
387
+ * consumers of this package that don't wire up the host's repo lifecycle.
303
388
  */
304
389
  getCloseGeneration(repoPath: string): number;
305
390
  /** Clears file-scoped caches (blame, diff, fileLog) for a specific path within a repo */
@@ -333,8 +418,13 @@ export declare class Cache implements Disposable {
333
418
  */
334
419
  unregisterRepoPath(repoPath: string): void;
335
420
  reset(): void;
336
- /** Applies a watcher-observed change, sharing reads still in flight (see {@link applyRepositoryChanges}). */
337
- onRepositoryChanged(repoPath: string, changes: Iterable<RepositoryChange>): void;
421
+ /**
422
+ * Applies a watcher-observed change, sharing reads still in flight (see {@link applyRepositoryChanges}).
423
+ * `options.movedWorktrees` is the event's `movedWorktrees`.
424
+ */
425
+ onRepositoryChanged(repoPath: string, changes: Iterable<RepositoryChange>, options?: {
426
+ movedWorktrees?: ReadonlySet<string>;
427
+ }): void;
338
428
  /**
339
429
  * Clears what `changes` can have made stale for `repoPath`, advances its status clock, and reconciles a
340
430
  * `'gkConfig'` change, returning the cache types it cleared. `inFlight` is as {@link clearCaches}
@@ -344,9 +434,20 @@ export declare class Cache implements Disposable {
344
434
  * `options.worktreeOnly` clears only `repoPath`'s own entries and status clock, leaving the shared
345
435
  * (commonPath-keyed) ones alone — for a sibling worktree once the change was applied to the worktree it ran in,
346
436
  * which already cleared them for every worktree of the repository.
437
+ *
438
+ * `options.announced` says `changes` are core's announcement of its own write for `repoPath`, whose `'worktreeHead'`
439
+ * is that write's own: its rewrite of `repoPath`'s HEAD, which its `'head'` clears, or a worktree it added or
440
+ * removed. Other worktrees' watchers report it, so no other worktree loses its current branch for it.
441
+ *
442
+ * `options.movedWorktrees` names, by admin id (the `<id>` of `.git/worktrees/<id>`), the linked worktrees whose HEAD
443
+ * moved, which are all that a `'worktreeHead'` among `changes` reports: each registered one is cleared as for its
444
+ * own `'head'` change, and no other registered worktree with an admin id of its own is touched. Without it, any
445
+ * linked worktree's HEAD may have moved, so each one but `repoPath` loses its current branch.
347
446
  */
348
447
  applyRepositoryChanges(repoPath: string, changes: Iterable<RepositoryChange>, inFlight: 'share' | 'evict', options?: {
448
+ announced?: boolean;
349
449
  worktreeOnly?: boolean;
450
+ movedWorktrees?: ReadonlySet<string>;
350
451
  }): CachedGitTypes[];
351
452
  /**
352
453
  * Handles a watcher-observed `'gkConfig'` change. If a reconciler is registered (see {@link setGkConfigReconciler}),
@@ -377,9 +478,11 @@ export declare class Cache implements Disposable {
377
478
  * it needs for `repoPath`; {@link getBranches} keeps a mapped copy per worktree.
378
479
  */
379
480
  getSharedBranches(repoPath: string, factory: (commonPath: string, cacheable: CacheController, cancellation?: AbortSignal) => PromiseOrValue<PagedResult<GitBranch>>, cancellation?: AbortSignal): Promise<PagedResult<GitBranch>>;
481
+ private getSharedBranchesCore;
380
482
  /** Whether `result`, from {@link getSharedBranches}, is still the list kept for `repoPath`: not refused, replaced or evicted */
381
483
  isSharedBranchesKept(repoPath: string, result: PagedResult<GitBranch>): boolean;
382
484
  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>>;
485
+ private getBranchesCore;
383
486
  private static readonly globalConfigKey;
384
487
  /**
385
488
  * Keyed by `repoPath` itself, not its common path: git reads a worktree's own `config.worktree` too, so worktrees
@@ -486,6 +589,7 @@ export declare class Cache implements Disposable {
486
589
  cancellation?: AbortSignal;
487
590
  }): Promise<GitContributorsStats | undefined>;
488
591
  getBaseBranchName(repoPath: string, ref: string, factory: (commonPath: string, cacheable: CacheController, cancellation?: AbortSignal) => PromiseOrValue<string | undefined>, cancellation?: AbortSignal): Promise<string | undefined>;
592
+ private getBaseBranchNameCore;
489
593
  /**
490
594
  * Clears the cached base branch for `ref`. Call from ops that create/rename/delete a branch — the
491
595
  * `'branches'` cascade no longer clears these, since tip movement can't change a branch's base.
@@ -542,6 +646,7 @@ export declare class Cache implements Disposable {
542
646
  * (see {@link CachedMergeTarget}). A checkout evicts only the entries marked `evictOnCheckout`
543
647
  */
544
648
  getMergeTarget(repoPath: string, cacheKey: string, factory: (commonPath: string, cacheable: CacheController, cancellation?: AbortSignal) => PromiseOrValue<CachedMergeTarget>, cancellation?: AbortSignal): Promise<CachedMergeTarget>;
649
+ private getMergeTargetCore;
545
650
  /**
546
651
  * Drops `stale`, an answer {@link getMergeTarget} gave for `cacheKey`, unless it was already replaced: callers that
547
652
  * found the same answer stale then share the one that replaced it rather than each resolving their own
@@ -555,6 +660,7 @@ export declare class Cache implements Disposable {
555
660
  getEmptyTreeSha(repoPath: string, factory: (commonPath: string) => PromiseOrValue<string>): Promise<string>;
556
661
  getLastFetchedTimestamp(repoPath: string, factory: (commonPath: string) => PromiseOrValue<number | undefined>): Promise<number | undefined>;
557
662
  getRefs(repoPath: string, factory: (commonPath: string, cacheable: CacheController, cancellation?: AbortSignal) => PromiseOrValue<RefRecord[]>, cancellation?: AbortSignal): Promise<RefRecord[]>;
663
+ private getRefsCore;
558
664
  getRefTips(repoPath: string, factory: (commonPath: string, cacheable: CacheController, cancellation?: AbortSignal) => PromiseOrValue<GitRefTip[]>, cancellation?: AbortSignal): Promise<GitRefTip[]>;
559
665
  getRemotes(repoPath: string, factory: (commonPath: string, cacheable: CacheController, cancellation?: AbortSignal) => PromiseOrValue<GitRemote[]>, cancellation?: AbortSignal): Promise<GitRemote[]>;
560
666
  getStash(repoPath: string, cacheKey: string, factory: (commonPath: string, cacheable: CacheController, cancellation?: AbortSignal) => PromiseOrValue<GitStash>, options?: {