@gitkraken/core-gitlens 0.10.7 → 0.11.1
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 +39 -1
- package/dist/git/cache.d.ts +34 -2
- package/dist/git/cache.js +55 -7
- package/dist/git/cache.js.map +1 -1
- package/dist/git/context.d.ts +1 -1
- package/dist/git/models/repository.d.ts +3 -2
- package/dist/git/models/repository.js +5 -4
- package/dist/git/models/repository.js.map +1 -1
- package/dist/git/providers/branches.d.ts +24 -0
- package/dist/git/providers/config.d.ts +3 -1
- package/dist/git/providers/provider.d.ts +13 -1
- package/dist/git/providers/staging.d.ts +1 -1
- package/dist/git/service.d.ts +17 -1
- package/dist/git/service.js +59 -8
- package/dist/git/service.js.map +1 -1
- package/dist/git/watching/changeEvent.d.ts +48 -5
- package/dist/git/watching/changeEvent.js +82 -7
- package/dist/git/watching/changeEvent.js.map +1 -1
- package/dist/git/watching/classifyChange.d.ts +13 -2
- package/dist/git/watching/classifyChange.js +40 -5
- package/dist/git/watching/classifyChange.js.map +1 -1
- package/dist/git/watching/gitIgnoreFilter.d.ts +57 -10
- package/dist/git/watching/gitIgnoreFilter.js +186 -29
- package/dist/git/watching/gitIgnoreFilter.js.map +1 -1
- package/dist/git/watching/initWatcher.d.ts +5 -1
- package/dist/git/watching/initWatcher.js +1 -1
- package/dist/git/watching/initWatcher.js.map +1 -1
- package/dist/git/watching/provider.d.ts +33 -8
- package/dist/git/watching/watchGroup.d.ts +13 -2
- package/dist/git/watching/watchGroup.js +60 -14
- package/dist/git/watching/watchGroup.js.map +1 -1
- package/dist/git/watching/watchService.d.ts +42 -1
- package/dist/git/watching/watchService.js +172 -20
- package/dist/git/watching/watchService.js.map +1 -1
- package/dist/git/watching/watchSession.d.ts +50 -17
- package/dist/git/watching/watchSession.js +274 -83
- package/dist/git/watching/watchSession.js.map +1 -1
- package/dist/git/watching/watcherPatterns.d.ts +13 -2
- package/dist/git/watching/watcherPatterns.js +22 -2
- package/dist/git/watching/watcherPatterns.js.map +1 -1
- package/dist/git/watching/worktreeSummary.d.ts +132 -0
- package/dist/git/watching/worktreeSummary.js +429 -0
- package/dist/git/watching/worktreeSummary.js.map +1 -0
- package/dist/git-cli/cliGitProvider.d.ts +6 -1
- package/dist/git-cli/cliGitProvider.js +87 -2
- package/dist/git-cli/cliGitProvider.js.map +1 -1
- package/dist/git-cli/providers/blame.js +1 -1
- package/dist/git-cli/providers/branches.d.ts +32 -1
- package/dist/git-cli/providers/branches.js +217 -0
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/dist/git-cli/providers/commits.js +1 -1
- package/dist/git-cli/providers/config.d.ts +3 -0
- package/dist/git-cli/providers/config.js +12 -6
- package/dist/git-cli/providers/config.js.map +1 -1
- package/dist/git-cli/providers/contributors.js +1 -1
- package/dist/git-cli/providers/graph.js +1 -1
- package/dist/git-cli/providers/maintenance.js +1 -1
- package/dist/git-cli/providers/refs.js +1 -1
- package/dist/git-cli/providers/staging.js +1 -1
- package/dist/git-cli/providers/status.js +1 -1
- package/dist/git-cli/service.js +1 -0
- package/dist/git-cli/service.js.map +1 -1
- package/dist/ipc/ipcServer.js +1 -1
- package/dist/plus/agents/providers/gkAgentProvider.js +2 -2
- package/dist/plus/git-github/api/github.d.ts +1 -1
- package/dist/plus/git-github/api/github.js +1 -1
- package/dist/plus/git-github/providers/github/blame.js +1 -1
- package/dist/plus/integrations/authentication/integrationAuthenticationProvider.js +1 -1
- package/dist/plus/integrations/context.d.ts +1 -1
- package/dist/plus/integrations/integrationService.js +1 -1
- package/dist/plus/integrations/models/integration.js +1 -1
- package/dist/plus/integrations/providers/bitbucket-server.d.ts +1 -1
- package/dist/plus/integrations/reads/batchEtags.d.ts +5 -2
- package/dist/plus/integrations/reads/batchEtags.js +31 -10
- package/dist/plus/integrations/reads/batchEtags.js.map +1 -1
- package/dist/plus/integrations/reads/pullRequestBranches.js +10 -3
- package/dist/plus/integrations/reads/pullRequestBranches.js.map +1 -1
- package/dist/plus/integrations/results.d.ts +16 -1
- package/dist/plus/integrations/results.js +22 -3
- package/dist/plus/integrations/results.js.map +1 -1
- package/dist/utils/event.d.ts +1 -1
- package/docs/integrations.md +5 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,42 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.11.1] - 2026-10-16
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Adds tip commits to `WorktreeSummary`: `sha` is HEAD's commit (`undefined` before the first commit) and `base.sha` is the base ref's tip, so a host can key on commits rather than counts. A commit and a fast-forward of the base that leave every count the same now change the summary and fire. `getAheadOfBase` answers the tip as `base.sha`, resolved from the cached ref list in git's own order (a tag before a same-named branch), and its `dependsOn` now names that tag too, so the tag moving recomputes the base. Both come from reads the summary already does, except that a recompute of only the base re-reads the shared ref list when the ref move that triggered it cleared that list (git, git-cli)
|
|
14
|
+
- Adds `baseDependsOn` to `WorktreeSummary`: the full ref names whose movement can change the base answer, as `getAheadOfBase` reports them, taken from the summary's own base read and given with or without a base. A host can narrow a watch subscription's `relevantRefs` to it without reading the base again, and a change to the list alone fires (git)
|
|
15
|
+
- Adds `targetKeys` to `ProviderWarning`: a batch read's warning (`getPullRequestsBatch`, `getIssuesBatch`, `getPullRequestsForBranches`) names the keys of the targets it concerns — the target that was refused or failed, or every target of an integration call that failed as a whole — so a caller that merges several callers' targets into one call can hand each failure only to its own targets. A warning without it refused the whole call before any target was read. Equal warnings merge their keys rather than one being dropped (plus/integrations)
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- Fixes `getAheadOfBase` answering a stale count against a tag-named base after the tag moved: a tag change now clears the cached commit counts and merge bases, which are keyed by ref name, as a branch move already did (git)
|
|
20
|
+
|
|
21
|
+
## [0.11.0] - 2026-10-15
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- Adds `maxWaitMs` to `RepositoryWatchSession.subscribe` and `subscribeToWorkingTree`, and `defaultRepoMaxWaitMs` / `defaultWorkingTreeMaxWaitMs` to `RepositoryWatchService`'s options: a flush happens no later than that long after the first pending change, however long activity continues. Across subscribers the shortest delay and the shortest max-wait win; `Infinity` opts a subscriber out of the cap (git)
|
|
26
|
+
- Adds which refs moved to `WatcherRepoChangeEvent`: `refs` holds the full ref names (or ref directories, or `HEAD`/`ORIG_HEAD`) whose files changed, and `mayHaveChangedRef(ref)` answers conservatively, treating a change with no name (a `packed-refs` rewrite, a `config` change, an injected change) as moving every ref of its kind. `RepositoryWatchSession.subscribe` takes `relevantRefs`, a list read at delivery, which narrows that subscription's events to changes that may move a listed ref, so a linked worktree's subscriber can skip sibling branches' commits; other subscribers and cache invalidation still see every change (git)
|
|
27
|
+
- Adds `branches.getAheadOfBase(branch)`: how far HEAD has moved past the base its branch was cut from, and which ref it was measured against. Bases are tried in trust order (the user's merge target, the detected one, the recorded `gk-merge-base`, then the local default branch), only recorded values count (never a reflog guess), and a target that no longer resolves falls through. Each is measured as itself or its tracking ref, whichever forked nearer HEAD, so a stale local `main` doesn't count commits `origin/main` already has. A base that is the branch itself, by name or as its copy on one of the repo's remotes, at HEAD's own commit answers no base rather than 0 ahead. It answers `{ base, dependsOn }`: `base` is the ref and count, `undefined` when there is no base (also on a detached HEAD or one with no commit yet), and `dependsOn` lists the refs whose movement can change the answer, given even without a base so a watcher learns when one appears. A count that can't be read rejects with git's error rather than answering no base (git, git-cli)
|
|
28
|
+
- Adds an exclude set to the file-watcher seam, so a native watcher can prune ignored directories before making any OS watch: `FileWatchingProvider.createWatcher` takes `options.excludes` (directories relative to the base path, each pruned with its subtree; globs or literal paths), and a provider that prunes natively sets `supportsExcludes`. Core always passes `**/node_modules` and `**/.git` for the working tree and the `.git` subtrees nothing reads (`objects`, `logs`, `hooks`, …) for `.git` watchers; for a `supportsExcludes` provider it adds the directories an ignore rule matches, read from git (new `GitProvider.getIgnoredDirectories`), and re-creates the working-tree watcher, new before old, when ignore rules change or an ignored directory appears after it started (a first build's `dist/`) (git, git-cli)
|
|
29
|
+
- Adds an `overflow` reason to `FileWatchEvent`, so a watcher that dropped events can make core resync: on the working tree it becomes an incomplete change (consumers refresh everything) and reloads the ignore rules, since a lost `.gitignore` edit would leave them stale; on a `.git` watcher every kind a watcher can report, which clears every cache type and refreshes every subscriber without unregistering the repository; and on `RepositoryInitWatcher` an `onDidCreate` for the overflowed path so the host rescans it for repositories. A reported directory now stands for everything beneath it, and `RepositoryWorkingTreeChangeEvent.changed(uri)` matches a file under a changed directory, since a native watcher can miss the files of a just-created directory (git)
|
|
30
|
+
- Adds `WorktreeSummaryService` (`GitService.summaries`, present when a `watchingProvider` is): a cached summary of each subscribed worktree (branch, detached, upstream, ahead/behind, dirty, and ahead-of-base from `getAheadOfBase`), kept current by the watch layer. An event re-reads only the fields it can affect (an edit runs only the dirty probe; an unrelated branch moving reads nothing), one read runs per worktree at a time, `onDidChange` / `onDidChangeSummary` fire only when a value changes, and a failed read keeps the last values marked `stale`; when only the base can't be read, the other fields still update. It watches only while subscribed (git)
|
|
31
|
+
- Adds `onDidChangeMergeTargets` (`GitService`, `GitProvider`, `Cache`): fires when an external `.git/gk/config` write changed a branch's merge-relevant keys (`gk-merge-base`, `gk-merge-target`, `gk-merge-target-user`, `gk-target-base`), naming those branches, once per repository (`repoPath` is its common path) and after the derived caches were cleared. It never fires for a rewrite that only touches activity timestamps, nor for core's own writes, including a branch delete's or rename's section rewrite; `refs` is `undefined` (any branch may have changed) for the coarse fallback (no reconciler, or a failed reconcile) or when there was no earlier snapshot to diff against (git, git-cli)
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
|
|
35
|
+
- Changes the watch debounce to flush during continuous activity: repository changes flush at least every 2 s and working-tree changes at least every 10 s by default, where a steady stream of events (a long rebase, a build writing into the working tree) used to defer every flush until it stopped. Recording an event no longer re-arms a timer or allocates an event object (git)
|
|
36
|
+
|
|
37
|
+
- Changes the `worktrees` repository change to mean only that the worktree list, or what `git worktree list` reports per worktree (its HEAD, lock or location), changed. A linked worktree's own index, paused-operation and HEAD writes reach only that worktree's session, through its own gitdir watcher, instead of waking every worktree sharing the repository as `worktrees`; a sibling's HEAD change still reaches the others as `worktrees`. A main checkout no longer receives each shared `.git` change twice once a linked worktree is watched (git)
|
|
38
|
+
|
|
39
|
+
### Fixed
|
|
40
|
+
|
|
41
|
+
- Fixes the watch layer's gitignore filter answering differently from git, which let ignored output reach subscribers as working-tree changes or, worse, dropped real changes: it now honours nested `.gitignore` files (deeper ones overriding, nothing re-included beneath an ignored directory), reads `info/exclude` from the common git dir for a linked worktree, applies `core.excludesFile` < `info/exclude` < `.gitignore` in that order rather than in whichever order the reads finished, resolves `core.excludesFile` as git does (a `~/` path expanded, and `$XDG_CONFIG_HOME/git/ignore` or `~/.config/git/ignore` when unset), and matches case the way git does (`core.ignorecase`, else the platform default). An edited nested `.gitignore` reloads it, and a burst of edits costs one trailing reload rather than one per file. Where its matcher can't tell, it answers "not ignored", which costs a refresh rather than a missed change (git, git-cli)
|
|
42
|
+
- Fixes a standalone `createCliGitService` with a `watchingProvider` never re-reading the last-fetched time after a fetch: FETCH_HEAD reached only the per-watch `onFetchHeadChanged` hook. `RepositoryWatchService` now has a global `onDidChangeFetchHead` event, and the standalone service bridges it to the cache's `lastFetched` (git, git-cli)
|
|
43
|
+
- Fixes working-tree and repository change events advancing the wrong status clock when a host passed a path spelled differently from the cache's key (a Windows drive-letter case, backslashes or a trailing separator): `RepositoryWatchService.watch` and `getSession` key sessions by `getRepositoryKey`, so every session, event and hook carries the same key status reads fence on, and two spellings of one repository share a session (git)
|
|
44
|
+
|
|
9
45
|
## [0.10.7] - 2026-10-15
|
|
10
46
|
|
|
11
47
|
### Changed
|
|
@@ -613,7 +649,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
|
|
|
613
649
|
|
|
614
650
|
- 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.
|
|
615
651
|
|
|
616
|
-
[unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.
|
|
652
|
+
[unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.11.1...HEAD
|
|
653
|
+
[0.11.1]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.11.0...gitkraken:releases/core/v0.11.1
|
|
654
|
+
[0.11.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.10.7...gitkraken:releases/core/v0.11.0
|
|
617
655
|
[0.10.7]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.10.6...gitkraken:releases/core/v0.10.7
|
|
618
656
|
[0.10.6]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.10.5...gitkraken:releases/core/v0.10.6
|
|
619
657
|
[0.10.5]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.10.4...gitkraken:releases/core/v0.10.5
|
package/dist/git/cache.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { PagedResult } from "../utils/paging.js";
|
|
2
1
|
import { PromiseOrValue } from "../utils/promise.js";
|
|
2
|
+
import { Event } from "../utils/event.js";
|
|
3
|
+
import { PagedResult } from "../utils/paging.js";
|
|
3
4
|
import { CacheController, PromiseCache, PromiseMap, RepoPromiseCacheMap } from "../utils/promiseCache.js";
|
|
4
5
|
import { ResourceUsage } from "../utils/resourceUsage.js";
|
|
5
6
|
import { Uri } from "../utils/uri.js";
|
|
@@ -39,6 +40,20 @@ export type CachedGitTypes = UriScopedCachedGitTypes | 'branch' | 'branches' | '
|
|
|
39
40
|
* the churn the key-aware reconcile replaced.
|
|
40
41
|
*/
|
|
41
42
|
export type GkReconcileOutcome = 'reconciled' | 'deferred' | 'failed';
|
|
43
|
+
/** Fired by {@link Cache.onDidChangeMergeTargets} */
|
|
44
|
+
export interface MergeTargetsChangeEvent {
|
|
45
|
+
/**
|
|
46
|
+
* The repository's common path (the main worktree's, once registered). Merge keys live in the shared
|
|
47
|
+
* `.git/gk/config`, so this fires once per change for the whole repository, not once per worktree.
|
|
48
|
+
*/
|
|
49
|
+
readonly repoPath: string;
|
|
50
|
+
/**
|
|
51
|
+
* Branches whose merge-relevant keys (`gk-merge-base`, `gk-merge-target`, `gk-merge-target-user`,
|
|
52
|
+
* `gk-target-base`) changed. `undefined` when it can't be told, so any branch's may have: the coarse fallback
|
|
53
|
+
* (no reconciler, or a failed reconcile), or a change with no earlier snapshot to diff against.
|
|
54
|
+
*/
|
|
55
|
+
readonly refs: ReadonlySet<string> | undefined;
|
|
56
|
+
}
|
|
42
57
|
export type ConflictDetectionCacheKey = `apply:${string}:${string}:${string}` | `merge:${string}:${string}` | `reapply:${string}:${string}`;
|
|
43
58
|
export declare function shouldEvictBlameCacheEntry(progressive: ProgressiveGitBlame | undefined): Promise<boolean>;
|
|
44
59
|
/**
|
|
@@ -64,6 +79,14 @@ export declare class Cache implements Disposable {
|
|
|
64
79
|
* `baseBranchName`/`branchOverviews` on every gk write. Absent means "never observed".
|
|
65
80
|
*/
|
|
66
81
|
private _gkConfigMergeSnapshots;
|
|
82
|
+
private readonly _onDidChangeMergeTargets;
|
|
83
|
+
/**
|
|
84
|
+
* Fires when an external `.git/gk/config` write changed a branch's merge-relevant keys — never for a write that
|
|
85
|
+
* only touched other keys (activity timestamps), and never for core's own writes, which
|
|
86
|
+
* {@link recordGkConfigWrite} folds into the snapshot before the watcher reports them. Fires after the derived
|
|
87
|
+
* caches were cleared, so a listener's re-read sees the new values.
|
|
88
|
+
*/
|
|
89
|
+
get onDidChangeMergeTargets(): Event<MergeTargetsChangeEvent>;
|
|
67
90
|
/**
|
|
68
91
|
* Reconciler registered by the CLI config sub-provider (see {@link setGkConfigReconciler}),
|
|
69
92
|
* invoked on a watcher-observed `'gkConfig'` change instead of the coarse `clearCaches(repoPath,
|
|
@@ -234,6 +257,8 @@ export declare class Cache implements Disposable {
|
|
|
234
257
|
* clear when no reconciler is registered (e.g. the GitHub provider) so nothing can go stale.
|
|
235
258
|
*/
|
|
236
259
|
private handleGkConfigChanged;
|
|
260
|
+
/** The coarse fallback: every derived merge cache is cleared, so any branch's merge targets may have changed */
|
|
261
|
+
private clearGkConfigCoarsely;
|
|
237
262
|
/** Hard-evicts the cached bulk `.git/gk/config` map so the next read hits disk. */
|
|
238
263
|
deleteGkConfigMap(repoPath: string): void;
|
|
239
264
|
/** The merge-relevant gk config snapshot currently serving as the reconcile baseline. */
|
|
@@ -276,6 +301,12 @@ export declare class Cache implements Disposable {
|
|
|
276
301
|
* the next real read (`getGkConfigMap`) populates one from scratch.
|
|
277
302
|
*/
|
|
278
303
|
recordGkConfigWrite(repoPath: string, key: string, value: string | undefined): void;
|
|
304
|
+
/**
|
|
305
|
+
* {@link recordGkConfigWrite} for a whole `branch.<ref>` section: our own `--remove-section` (a branch delete) or
|
|
306
|
+
* `--rename-section` (a branch rename, to `renamedTo`), so the reconcile that follows doesn't report it as an
|
|
307
|
+
* external merge-target change.
|
|
308
|
+
*/
|
|
309
|
+
recordGkConfigSectionWrite(repoPath: string, ref: string, renamedTo?: string): void;
|
|
279
310
|
/**
|
|
280
311
|
* Registers the reconciler invoked by {@link handleGkConfigChanged} on a watcher-observed
|
|
281
312
|
* `'gkConfig'` change. Only one reconciler is kept — later registrations replace earlier ones,
|
|
@@ -287,7 +318,8 @@ export declare class Cache implements Disposable {
|
|
|
287
318
|
* Diffs a freshly-read gk config map's merge-relevant subset against `priorSnapshot` (captured by
|
|
288
319
|
* `handleGkConfigChanged` before the reconcile started, so it reflects the pre-change state even
|
|
289
320
|
* though this call's own re-read already raced ahead and refreshed the live snapshot), cascading
|
|
290
|
-
* `baseBranchName`/`branchOverviews` for every ref whose merge-relevant key actually changed
|
|
321
|
+
* `baseBranchName`/`branchOverviews` for every ref whose merge-relevant key actually changed, then firing
|
|
322
|
+
* {@link onDidChangeMergeTargets} naming those refs.
|
|
291
323
|
* `priorSnapshot` of `undefined` (never observed before this reconcile) is treated as "everything
|
|
292
324
|
* may have changed" — a full coarse clear, same as the pre-existing watcher behavior. Returns
|
|
293
325
|
* whether anything changed (i.e. whether a follow-up repository-changed event is warranted).
|
package/dist/git/cache.js
CHANGED
|
@@ -2,6 +2,7 @@ import { exhaustiveArray } from "../utils/array.js";
|
|
|
2
2
|
import { raceWithSignal } from "../utils/cancellation.js";
|
|
3
3
|
import { debug } from "../utils/decorators/log.js";
|
|
4
4
|
import { invalidateMemoized } from "../utils/decorators/memoize.js";
|
|
5
|
+
import { Emitter } from "../utils/event.js";
|
|
5
6
|
import { getBranchId } from "../utils/gitRefs.js";
|
|
6
7
|
import { normalizePath } from "../utils/path.js";
|
|
7
8
|
import { PromiseCache, PromiseMap, RepoPromiseCacheMap } from "../utils/promiseCache.js";
|
|
@@ -133,6 +134,16 @@ var Cache = class Cache {
|
|
|
133
134
|
* `baseBranchName`/`branchOverviews` on every gk write. Absent means "never observed".
|
|
134
135
|
*/
|
|
135
136
|
_gkConfigMergeSnapshots = /* @__PURE__ */ new Map();
|
|
137
|
+
_onDidChangeMergeTargets = new Emitter();
|
|
138
|
+
/**
|
|
139
|
+
* Fires when an external `.git/gk/config` write changed a branch's merge-relevant keys — never for a write that
|
|
140
|
+
* only touched other keys (activity timestamps), and never for core's own writes, which
|
|
141
|
+
* {@link recordGkConfigWrite} folds into the snapshot before the watcher reports them. Fires after the derived
|
|
142
|
+
* caches were cleared, so a listener's re-read sees the new values.
|
|
143
|
+
*/
|
|
144
|
+
get onDidChangeMergeTargets() {
|
|
145
|
+
return this._onDidChangeMergeTargets.event;
|
|
146
|
+
}
|
|
136
147
|
/**
|
|
137
148
|
* Reconciler registered by the CLI config sub-provider (see {@link setGkConfigReconciler}),
|
|
138
149
|
* invoked on a watcher-observed `'gkConfig'` change instead of the coarse `clearCaches(repoPath,
|
|
@@ -145,6 +156,7 @@ var Cache = class Cache {
|
|
|
145
156
|
}
|
|
146
157
|
dispose() {
|
|
147
158
|
this.reset();
|
|
159
|
+
this._onDidChangeMergeTargets.dispose();
|
|
148
160
|
}
|
|
149
161
|
/** Resource usage retained by instantiated sub-caches and their bookkeeping maps. */
|
|
150
162
|
getResourceUsage() {
|
|
@@ -441,6 +453,8 @@ var Cache = class Cache {
|
|
|
441
453
|
keysToClear.add("commitCount");
|
|
442
454
|
keysToClear.add("logShas");
|
|
443
455
|
keysToClear.add("resolvedRevisions");
|
|
456
|
+
keysToClear.add("leftRightCommitCount");
|
|
457
|
+
keysToClear.add("mergeBase");
|
|
444
458
|
}
|
|
445
459
|
if (types.includes("tracking")) {
|
|
446
460
|
keysToClear.add("fileExistence");
|
|
@@ -684,13 +698,21 @@ var Cache = class Cache {
|
|
|
684
698
|
const commonPath = this.getCommonPath(repoPath);
|
|
685
699
|
this._caches.gkConfigMap?.delete(commonPath);
|
|
686
700
|
if (this._gkConfigReconciler == null) {
|
|
687
|
-
this.
|
|
701
|
+
this.clearGkConfigCoarsely(repoPath);
|
|
688
702
|
return;
|
|
689
703
|
}
|
|
690
704
|
const priorSnapshot = this._gkConfigMergeSnapshots.get(commonPath);
|
|
691
705
|
Promise.resolve(this._gkConfigReconciler(repoPath, priorSnapshot)).then((outcome) => {
|
|
692
|
-
if (outcome === "failed") this.
|
|
693
|
-
}, () => this.
|
|
706
|
+
if (outcome === "failed") this.clearGkConfigCoarsely(repoPath);
|
|
707
|
+
}, () => this.clearGkConfigCoarsely(repoPath));
|
|
708
|
+
}
|
|
709
|
+
/** The coarse fallback: every derived merge cache is cleared, so any branch's merge targets may have changed */
|
|
710
|
+
clearGkConfigCoarsely(repoPath) {
|
|
711
|
+
this.clearCaches(repoPath, "gkConfig");
|
|
712
|
+
this._onDidChangeMergeTargets.fire({
|
|
713
|
+
repoPath: this.getCommonPath(repoPath),
|
|
714
|
+
refs: void 0
|
|
715
|
+
});
|
|
694
716
|
}
|
|
695
717
|
/** Hard-evicts the cached bulk `.git/gk/config` map so the next read hits disk. */
|
|
696
718
|
deleteGkConfigMap(repoPath) {
|
|
@@ -795,6 +817,21 @@ var Cache = class Cache {
|
|
|
795
817
|
this._gkConfigMergeSnapshots.set(commonPath, next);
|
|
796
818
|
}
|
|
797
819
|
/**
|
|
820
|
+
* {@link recordGkConfigWrite} for a whole `branch.<ref>` section: our own `--remove-section` (a branch delete) or
|
|
821
|
+
* `--rename-section` (a branch rename, to `renamedTo`), so the reconcile that follows doesn't report it as an
|
|
822
|
+
* external merge-target change.
|
|
823
|
+
*/
|
|
824
|
+
recordGkConfigSectionWrite(repoPath, ref, renamedTo) {
|
|
825
|
+
const commonPath = this.getCommonPath(repoPath);
|
|
826
|
+
const snapshot = this._gkConfigMergeSnapshots.get(commonPath);
|
|
827
|
+
if (snapshot == null) return;
|
|
828
|
+
const prefixLength = `branch.${ref}.`.length;
|
|
829
|
+
const next = /* @__PURE__ */ new Map();
|
|
830
|
+
for (const [key, value] of snapshot) if (branchOverviewGkConfigKeysRegex.exec(key)?.[1] !== ref) next.set(key, value);
|
|
831
|
+
else if (renamedTo != null) next.set(`branch.${renamedTo}.${key.substring(prefixLength)}`, value);
|
|
832
|
+
this._gkConfigMergeSnapshots.set(commonPath, next);
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
798
835
|
* Registers the reconciler invoked by {@link handleGkConfigChanged} on a watcher-observed
|
|
799
836
|
* `'gkConfig'` change. Only one reconciler is kept — later registrations replace earlier ones,
|
|
800
837
|
* which is harmless since every CLI config sub-provider sharing this `Cache` reconciles the same
|
|
@@ -807,7 +844,8 @@ var Cache = class Cache {
|
|
|
807
844
|
* Diffs a freshly-read gk config map's merge-relevant subset against `priorSnapshot` (captured by
|
|
808
845
|
* `handleGkConfigChanged` before the reconcile started, so it reflects the pre-change state even
|
|
809
846
|
* though this call's own re-read already raced ahead and refreshed the live snapshot), cascading
|
|
810
|
-
* `baseBranchName`/`branchOverviews` for every ref whose merge-relevant key actually changed
|
|
847
|
+
* `baseBranchName`/`branchOverviews` for every ref whose merge-relevant key actually changed, then firing
|
|
848
|
+
* {@link onDidChangeMergeTargets} naming those refs.
|
|
811
849
|
* `priorSnapshot` of `undefined` (never observed before this reconcile) is treated as "everything
|
|
812
850
|
* may have changed" — a full coarse clear, same as the pre-existing watcher behavior. Returns
|
|
813
851
|
* whether anything changed (i.e. whether a follow-up repository-changed event is warranted).
|
|
@@ -819,14 +857,24 @@ var Cache = class Cache {
|
|
|
819
857
|
if (priorSnapshot == null) {
|
|
820
858
|
this.evictShared("baseBranchName", repoPath);
|
|
821
859
|
this.evictShared("branchOverviews", repoPath);
|
|
860
|
+
this._onDidChangeMergeTargets.fire({
|
|
861
|
+
repoPath: commonPath,
|
|
862
|
+
refs: void 0
|
|
863
|
+
});
|
|
822
864
|
return true;
|
|
823
865
|
}
|
|
824
|
-
let
|
|
866
|
+
let refs;
|
|
825
867
|
for (const key of /* @__PURE__ */ new Set([...priorSnapshot.keys(), ...newSubset.keys()])) if (priorSnapshot.get(key) !== newSubset.get(key)) {
|
|
826
|
-
changed = true;
|
|
827
868
|
this.cascadeGkConfigKeyChange(commonPath, key);
|
|
869
|
+
const ref = branchOverviewGkConfigKeysRegex.exec(key)?.[1];
|
|
870
|
+
if (ref != null) (refs ??= /* @__PURE__ */ new Set()).add(ref);
|
|
828
871
|
}
|
|
829
|
-
return
|
|
872
|
+
if (refs == null) return false;
|
|
873
|
+
this._onDidChangeMergeTargets.fire({
|
|
874
|
+
repoPath: commonPath,
|
|
875
|
+
refs
|
|
876
|
+
});
|
|
877
|
+
return true;
|
|
830
878
|
}
|
|
831
879
|
/**
|
|
832
880
|
* Shared per-ref cascade for a changed `branch.<ref>.gk-...` key: invalidates `baseBranchName` (for
|