@gitkraken/core-gitlens 0.28.0 → 0.30.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 (120) hide show
  1. package/CHANGELOG.md +48 -1
  2. package/dist/git/cache.d.ts +39 -1
  3. package/dist/git/cache.js +108 -7
  4. package/dist/git/cache.js.map +1 -1
  5. package/dist/git/providers/branches.d.ts +17 -12
  6. package/dist/git/providers/revision.d.ts +4 -0
  7. package/dist/git/watching/worktreeSummary.d.ts +16 -7
  8. package/dist/git/watching/worktreeSummary.js +44 -14
  9. package/dist/git/watching/worktreeSummary.js.map +1 -1
  10. package/dist/git-cli/cliGitProvider.js +3 -3
  11. package/dist/git-cli/cliGitProvider.js.map +1 -1
  12. package/dist/git-cli/exec/exec.d.ts +2 -2
  13. package/dist/git-cli/exec/exec.js +2 -2
  14. package/dist/git-cli/exec/gitDirResolver.d.ts +6 -1
  15. package/dist/git-cli/exec/gitDirResolver.js +9 -4
  16. package/dist/git-cli/exec/gitDirResolver.js.map +1 -1
  17. package/dist/git-cli/providers/branches.d.ts +91 -13
  18. package/dist/git-cli/providers/branches.js +673 -176
  19. package/dist/git-cli/providers/branches.js.map +1 -1
  20. package/dist/git-cli/providers/config.js +1 -1
  21. package/dist/git-cli/providers/config.js.map +1 -1
  22. package/dist/git-cli/providers/revision.d.ts +4 -0
  23. package/dist/git-cli/providers/revision.js +64 -3
  24. package/dist/git-cli/providers/revision.js.map +1 -1
  25. package/dist/ipc/ipcServer.d.ts +6 -1
  26. package/dist/ipc/ipcServer.js +15 -6
  27. package/dist/ipc/ipcServer.js.map +1 -1
  28. package/dist/plus/ai/errors.js +4 -4
  29. package/dist/plus/ai/errors.js.map +1 -1
  30. package/dist/plus/ai/models/model.d.ts +1 -1
  31. package/dist/plus/ai/models/model.js.map +1 -1
  32. package/dist/plus/ai/models/promptTemplates.d.ts +45 -2
  33. package/dist/plus/ai/models/results.d.ts +41 -0
  34. package/dist/plus/ai/models/results.js +14 -0
  35. package/dist/plus/ai/models/results.js.map +1 -0
  36. package/dist/plus/ai/prompts.d.ts +6 -0
  37. package/dist/plus/ai/prompts.js +255 -5
  38. package/dist/plus/ai/prompts.js.map +1 -1
  39. package/dist/plus/ai/providers/gitkrakenProvider.js +2 -2
  40. package/dist/plus/ai/providers/gitkrakenProvider.js.map +1 -1
  41. package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -0
  42. package/dist/plus/ai/providers/openAICompatibleProviderBase.js.map +1 -1
  43. package/dist/plus/ai/utils/ai.utils.d.ts +4 -0
  44. package/dist/plus/ai/utils/ai.utils.js +8 -1
  45. package/dist/plus/ai/utils/ai.utils.js.map +1 -1
  46. package/dist/plus/ai/utils/results.utils.d.ts +15 -1
  47. package/dist/plus/ai/utils/results.utils.js +80 -4
  48. package/dist/plus/ai/utils/results.utils.js.map +1 -1
  49. package/dist/plus/integrations/authentication/integrationAuthenticationService.js +2 -0
  50. package/dist/plus/integrations/authentication/integrationAuthenticationService.js.map +1 -1
  51. package/dist/plus/integrations/authentication/models.d.ts +1 -1
  52. package/dist/plus/integrations/authentication/models.js +2 -0
  53. package/dist/plus/integrations/authentication/models.js.map +1 -1
  54. package/dist/plus/integrations/constants.d.ts +2 -1
  55. package/dist/plus/integrations/constants.js +12 -2
  56. package/dist/plus/integrations/constants.js.map +1 -1
  57. package/dist/plus/integrations/fieldPresence.js +17 -1
  58. package/dist/plus/integrations/fieldPresence.js.map +1 -1
  59. package/dist/plus/integrations/integrationService.d.ts +1 -1
  60. package/dist/plus/integrations/integrationService.js +8 -2
  61. package/dist/plus/integrations/integrationService.js.map +1 -1
  62. package/dist/plus/integrations/lite.js +5 -6
  63. package/dist/plus/integrations/lite.js.map +1 -1
  64. package/dist/plus/integrations/models/gitHostIntegration.d.ts +11 -1
  65. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  66. package/dist/plus/integrations/providers/asana.d.ts +91 -0
  67. package/dist/plus/integrations/providers/asana.js +344 -0
  68. package/dist/plus/integrations/providers/asana.js.map +1 -0
  69. package/dist/plus/integrations/providers/azure/azure.js +3 -2
  70. package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
  71. package/dist/plus/integrations/providers/azure/models.js +3 -2
  72. package/dist/plus/integrations/providers/azure/models.js.map +1 -1
  73. package/dist/plus/integrations/providers/azureDevOps.d.ts +7 -1
  74. package/dist/plus/integrations/providers/azureDevOps.js +9 -1
  75. package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
  76. package/dist/plus/integrations/providers/bitbucket-server/discovery.js +2 -1
  77. package/dist/plus/integrations/providers/bitbucket-server/discovery.js.map +1 -1
  78. package/dist/plus/integrations/providers/bitbucket-server/models.js.map +1 -1
  79. package/dist/plus/integrations/providers/github.d.ts +2 -2
  80. package/dist/plus/integrations/providers/github.js +2 -2
  81. package/dist/plus/integrations/providers/github.js.map +1 -1
  82. package/dist/plus/integrations/providers/issueSorts.d.ts +5 -0
  83. package/dist/plus/integrations/providers/issueSorts.js +6 -1
  84. package/dist/plus/integrations/providers/issueSorts.js.map +1 -1
  85. package/dist/plus/integrations/providers/jiraIssueByKey.js +2 -1
  86. package/dist/plus/integrations/providers/jiraIssueByKey.js.map +1 -1
  87. package/dist/plus/integrations/providers/models.d.ts +19 -3
  88. package/dist/plus/integrations/providers/models.js +12 -1
  89. package/dist/plus/integrations/providers/models.js.map +1 -1
  90. package/dist/plus/integrations/providers/providerApiClient.d.ts +0 -3
  91. package/dist/plus/integrations/providers/providerApiClient.js +1 -3
  92. package/dist/plus/integrations/providers/providerApiClient.js.map +1 -1
  93. package/dist/plus/integrations/providers/providersApi.d.ts +22 -1
  94. package/dist/plus/integrations/providers/providersApi.js +63 -12
  95. package/dist/plus/integrations/providers/providersApi.js.map +1 -1
  96. package/dist/plus/integrations/providers/utils.d.ts +1 -0
  97. package/dist/plus/integrations/providers/utils.js +8 -2
  98. package/dist/plus/integrations/providers/utils.js.map +1 -1
  99. package/dist/plus/integrations/reads/hierarchy.utils.d.ts +3 -3
  100. package/dist/plus/integrations/reads/hierarchy.utils.js +4 -4
  101. package/dist/plus/integrations/reads/hierarchy.utils.js.map +1 -1
  102. package/dist/plus/integrations/reads/resolveRepository.js +29 -21
  103. package/dist/plus/integrations/reads/resolveRepository.js.map +1 -1
  104. package/dist/plus/integrations/results.d.ts +18 -10
  105. package/dist/plus/integrations/results.js.map +1 -1
  106. package/dist/plus/integrations/utils/domain.utils.js +2 -1
  107. package/dist/plus/integrations/utils/domain.utils.js.map +1 -1
  108. package/dist/plus/integrations/utils/integration.utils.js +5 -13
  109. package/dist/plus/integrations/utils/integration.utils.js.map +1 -1
  110. package/dist/utils/diff.d.ts +19 -0
  111. package/dist/utils/diff.js +121 -3
  112. package/dist/utils/diff.js.map +1 -1
  113. package/dist/utils/env/node/exec.d.ts +0 -1
  114. package/dist/utils/env/node/exec.js +2 -14
  115. package/dist/utils/env/node/exec.js.map +1 -1
  116. package/dist/utils/path.d.ts +2 -0
  117. package/dist/utils/path.js +7 -1
  118. package/dist/utils/path.js.map +1 -1
  119. package/docs/integrations.md +72 -43
  120. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -6,6 +6,51 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.30.0] - 2026-11-05
10
+
11
+ ### Changed
12
+
13
+ - 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)
14
+ - 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)
15
+ - 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)
16
+
17
+ ### Fixed
18
+
19
+ - 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)
20
+ - 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)
21
+ - 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)
22
+ - 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)
23
+ - 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)
24
+
25
+ ## [0.29.0] - 2026-11-04
26
+
27
+ ### Added
28
+
29
+ - Adds Asana as an issue integration (`IssuesCloudHostIntegrationId.Asana`): an `AsanaIntegration` with workspaces as resources and their unarchived projects as projects, tasks mapped to the shared issue shape (open is incomplete, closed is completed), "my issues" read per workspace from the tasks assigned to the user, cloud auth via the shared provider, Asana issue entity identifiers keyed by workspace for branch associations, the `gl-provider-asana` glyph, and Asana in the supported cloud-integration descriptors/lists. Asana's task list can't be ordered, so it advertises no issue sorts, and a tracker read scoped to the user reads the user's tasks once per workspace and splits them into its projects (plus/integrations)
30
+ - Adds `trimTrailingSlashes` to `utils/path.js`, trimming every trailing `/` where `trimTrailingSlash` trims one, in a linear scan (utils)
31
+ - Adds a repository's fork status and parent to the identities `IntegrationManager.resolveRepository` returns, by bumping `@gitkraken/provider-apis` to 0.67.0: `isFork` and `parent` are now set for GitHub, GitHub Enterprise, Bitbucket Cloud, Bitbucket Data Center and Azure DevOps, where core 0.28.0 read fields the SDK didn't return yet, and for gitlab.com, where a nested group is part of the owner (`parent.owner: 'group/subgroup'`). Self-managed GitLab leaves both `undefined`, because the field that names the parent needs GitLab 17.10 and an older server rejects the whole query. A consumer patching the SDK to return these fields can drop the patch (plus/integrations)
32
+
33
+ ### Changed
34
+
35
+ - Changes how `@gitkraken/provider-apis` 0.67.0 loads for a consumer of core under Node ESM: it now ships an ESM build, so `import` resolves to `dist/*.mjs` while `require` still gets the CommonJS build, and core binds its factory through the new named `makeProviderAPIs` export, which is the same function in both (plus/integrations)
36
+ - **Breaking (git, git-cli)** — `getAheadOfBase`'s `base.ahead` counts HEAD's commits past `base.forkPoint`, the ones `<forkPoint>..HEAD` lists, so the two agree: past a fork point its base was rebased off, the commits the base replayed no longer count (a stacked branch of a rebased three-commit parent with one commit of its own is 1 ahead, was 4). Everywhere else it's the count from the merge base, as before (git-cli)
37
+ - Speeds up `getAheadOfBaseAfterBaseMove` for a base rebased off the fork point, such as the parent of a stacked branch: its forward moves are now re-measured, by the count past the fork point and the fork point settled again, rather than each worktree on it reading the base in full until the base's reflog entry for it expires. Two worktrees on such a base take 7 git processes between them besides the ref list, remotes, symref and config reads both take, where reading in full took 16, after re-measures that ran 4 before declining (git-cli)
38
+ - Speeds up `getAheadOfBaseAfterBaseMove`'s check that a base only moved forward: it reads the base's reflog from its file, sharing the read and its cache with `getAheadOfBase`, so it runs 1 git process, shared by every worktree on the base, where it ran 3 (`reflog`, a `rev-parse` of the value before its oldest entry, and the walk of what the reflog reaches); a base with no reflog file has no entries to read, as git finds too, so it runs the walk alone. A reftable repository has no reflog files, so it asks git for the reflog and the value before its oldest entry: 3 processes, as before, and the same share by every worktree, but repeated whenever any ref in the repository changes, since the table list that stamps the read changes with each; the same holds when the file can't be read (git-cli)
39
+ - Changes the cached read of a base's reflog to keep each entry's old and new value and whether its message shows a move forward, rather than the whole message (git-cli)
40
+ - Shares `getAheadOfBase`'s merge-base and patch reads of two commits between the worktrees of a repository, so worktrees on one rewritten base settle its fork point with one read of each (git-cli)
41
+
42
+ ### Removed
43
+
44
+ - Removes `getWindowsShortPath` from `utils/env/node/exec.js` and its re-export from `git-cli/exec/exec.js`; it has had no callers since 2023 (utils, git-cli)
45
+
46
+ ### Fixed
47
+
48
+ - Fixes trimming trailing slashes in `getIgnoredPaths`/`getIgnoredEntries` path handling and in self-managed host and URL normalization taking quadratic time on a long run of `/` that doesn't end the value; results are unchanged (git-cli, plus/integrations)
49
+ - Fixes `IntegrationManager.resolveRepository` reporting every Azure DevOps and Azure DevOps Server repository as `renamed: true`: it compared the provider's bare repository name with the remote's `{project}/_git/{repo}` path, which never match. It now compares the repository names and the projects (ignoring case), so `renamed` is `true` only when Azure names the repository or its project differently from the remote. A Server remote whose path the integration reads as a different collection and project than the parser did (a repository named after its project behind a virtual directory) is compared against the collection and project it was read at, so the re-read is not a rename but a later rename of either still is (plus/integrations)
50
+ - Fixes `IntegrationManager.resolveRepository` reporting a GitLab repository as `not-found` when the reply carried only GraphQL errors, such as a rejected query, because the SDK threw the same message as for a missing project. With `@gitkraken/provider-apis` 0.67.0 the SDK keeps those errors, so that reply now resolves as `undetermined` with a warning, and only a null project with no errors is `not-found` (plus/integrations)
51
+ - Fixes `getAheadOfBase` reporting a fork point past its base's tip when the base was moved back off a commit in the branch's history (a merged pull request undone by resetting `main`), which hid the branch's commits from that commit down. A base HEAD contains has its tip as the fork point. Any other base that left the commit git's `--fork-point` names behind (a rebased upstream or parent, or a base reset and moved on, including when another pull request landed before both were undone) has the commits that commit holds and the base lacks compared by patch with the base's 256 newest first-parent commits and what they merge: the fork point is the newest of them below which each has a copy of the same patch in the base, so it stays where all do (a cleanly rebased upstream or parent, or a pull request undone and re-landed by cherry-pick), and is the merge base where the oldest has none (a commit landed and dropped), which shows the dropped commits as the branch's. A merge among them, a copy deeper in the base, or a comparison that fails or runs past 10 seconds counts them as the branch's too (one that ran out of time is tried again after 10 minutes), so does a parent amended with new changes until the stacked branch is rebased; an empty commit the base dropped can still be left out while the base holds an unrelated empty one, since git takes any two empty commits as the same patch. The reflog only skips the comparison where its answer is known: read from its file, a base whose reflog shows every move since the fork point forward, or that has no reflog, adds no git process, and one moved back to a commit HEAD contains adds none. Any other base, however many moves its reflog holds (pushes, whose messages say nothing of their direction), or whose reflog has a gap or can't be read, takes one ancestry check of the fork point against its tip, cached and shared by every worktree on the base: the fork point stays when the tip holds it, and otherwise the comparison follows, then the merge base or the count past the fork point it settles on, three processes in all. A reftable repository's reflog isn't read for this, since it has no files: each tip the base moves to takes the ancestry check, to the same answers. A read that fails takes the merge base, counted from it, and isn't kept past the failure; git's answer stays only when that read fails too. (git-cli)
52
+ - Fixes `getAheadOfBase` and `getMergeTarget` choosing a base by git's `--fork-point` readings before correcting them, so a base moved back off one of the branch's commits could still win: a stacked branch whose default branch was fast-forwarded onto one of its commits and reset back was measured against the default, counting its parent's commits as its own. Candidates are now compared by their corrected fork points, so the parent stays the base, and a rebased parent keeps its fork point in the comparison. A local base wins over its tracking ref only by forking past git's reading of that ref, so a stale `main` left at a commit `origin/main` held and dropped (by `git pull` or `branch -f`) still defers to it, while one with unpushed work past that commit still wins; work pushed and then dropped from the remote reads as dropped, and shows as the branch's. `getMergeTarget`'s `forkPoint` is now corrected too, where it was git's reading; with no count taken, a tip the branch contains is its fork point too. The chosen base is settled once, for both the choice and the count. Candidates whose reflog shows they only moved forward add no git process; one moved back to a commit the branch contains adds one (the ancestry check), a local base settled below git's reading up to one more against its tracking ref, and a rewritten one its patch comparison and merge base too. In a reftable repository a candidate that only moved forward takes the ancestry check too (git-cli)
53
+
9
54
  ## [0.28.0] - 2026-11-02
10
55
 
11
56
  ### Added
@@ -1076,7 +1121,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1076
1121
 
1077
1122
  - 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.
1078
1123
 
1079
- [unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.28.0...HEAD
1124
+ [unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.30.0...HEAD
1125
+ [0.30.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.29.0...gitkraken:releases/core/v0.30.0
1126
+ [0.29.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.28.0...gitkraken:releases/core/v0.29.0
1080
1127
  [0.28.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.27.0...gitkraken:releases/core/v0.28.0
1081
1128
  [0.27.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.26.0...gitkraken:releases/core/v0.27.0
1082
1129
  [0.26.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.25.0...gitkraken:releases/core/v0.26.0
@@ -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
- setCurrentBranchReferenceIfAbsent(worktreePath: string, reference: GitBranchReference | undefined): void;
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
- setCurrentBranchReferenceIfAbsent(worktreePath, reference) {
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
- getBranches(repoPath, factory, mapper, cancellation) {
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
- const registration = this.sharedBranches.getOrCreate(commonPath, (cacheable, signal) => {
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) => Promise.resolve(factory(commonPath, cacheable, signal)), cancellation);
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);