@gitkraken/core-gitlens 0.8.0 → 0.9.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 (72) hide show
  1. package/CHANGELOG.md +32 -1
  2. package/dist/git/cache.d.ts +11 -0
  3. package/dist/git/cache.js +26 -3
  4. package/dist/git/cache.js.map +1 -1
  5. package/dist/git/context.d.ts +3 -2
  6. package/dist/git/context.js.map +1 -1
  7. package/dist/git/features.d.ts +1 -1
  8. package/dist/git/features.js +1 -0
  9. package/dist/git/features.js.map +1 -1
  10. package/dist/git/models/reflog.d.ts +6 -0
  11. package/dist/git/models/reflog.js.map +1 -1
  12. package/dist/git/models/revision.d.ts +0 -1
  13. package/dist/git/models/revision.js +1 -2
  14. package/dist/git/models/revision.js.map +1 -1
  15. package/dist/git/providers/commits.d.ts +20 -1
  16. package/dist/git/providers/operations.d.ts +13 -0
  17. package/dist/git/providers/provider.d.ts +14 -4
  18. package/dist/git/providers/refs.d.ts +10 -0
  19. package/dist/git/providers/revision.d.ts +2 -0
  20. package/dist/git/providers/staging.d.ts +2 -1
  21. package/dist/git/providers/stash.d.ts +3 -2
  22. package/dist/git/providers/status.d.ts +4 -0
  23. package/dist/git/run.types.d.ts +16 -0
  24. package/dist/git-cli/cliGitProvider.d.ts +24 -3
  25. package/dist/git-cli/cliGitProvider.js +79 -17
  26. package/dist/git-cli/cliGitProvider.js.map +1 -1
  27. package/dist/git-cli/exec/commandClassifier.d.ts +31 -0
  28. package/dist/git-cli/exec/commandClassifier.js +391 -0
  29. package/dist/git-cli/exec/commandClassifier.js.map +1 -0
  30. package/dist/git-cli/exec/git.d.ts +24 -3
  31. package/dist/git-cli/exec/git.js +116 -12
  32. package/dist/git-cli/exec/git.js.map +1 -1
  33. package/dist/git-cli/parsers/reflogParser.d.ts +7 -0
  34. package/dist/git-cli/parsers/reflogParser.js +11 -1
  35. package/dist/git-cli/parsers/reflogParser.js.map +1 -1
  36. package/dist/git-cli/providers/branches.js +16 -14
  37. package/dist/git-cli/providers/branches.js.map +1 -1
  38. package/dist/git-cli/providers/commits.d.ts +4 -2
  39. package/dist/git-cli/providers/commits.js +55 -4
  40. package/dist/git-cli/providers/commits.js.map +1 -1
  41. package/dist/git-cli/providers/diff.js +4 -4
  42. package/dist/git-cli/providers/diff.js.map +1 -1
  43. package/dist/git-cli/providers/operations.d.ts +12 -0
  44. package/dist/git-cli/providers/operations.js +26 -3
  45. package/dist/git-cli/providers/operations.js.map +1 -1
  46. package/dist/git-cli/providers/patch.js +2 -5
  47. package/dist/git-cli/providers/patch.js.map +1 -1
  48. package/dist/git-cli/providers/refs.d.ts +5 -0
  49. package/dist/git-cli/providers/refs.js +26 -1
  50. package/dist/git-cli/providers/refs.js.map +1 -1
  51. package/dist/git-cli/providers/remotes.js +3 -2
  52. package/dist/git-cli/providers/remotes.js.map +1 -1
  53. package/dist/git-cli/providers/revision.d.ts +2 -0
  54. package/dist/git-cli/providers/revision.js +11 -0
  55. package/dist/git-cli/providers/revision.js.map +1 -1
  56. package/dist/git-cli/providers/staging.d.ts +2 -1
  57. package/dist/git-cli/providers/staging.js +12 -7
  58. package/dist/git-cli/providers/staging.js.map +1 -1
  59. package/dist/git-cli/providers/stash.d.ts +3 -2
  60. package/dist/git-cli/providers/stash.js +34 -22
  61. package/dist/git-cli/providers/stash.js.map +1 -1
  62. package/dist/git-cli/providers/status.d.ts +2 -0
  63. package/dist/git-cli/providers/status.js +27 -9
  64. package/dist/git-cli/providers/status.js.map +1 -1
  65. package/dist/plus/git-github/providers/github/commits.d.ts +4 -2
  66. package/dist/plus/git-github/providers/github/commits.js +3 -1
  67. package/dist/plus/git-github/providers/github/commits.js.map +1 -1
  68. package/dist/plus/git-github/providers/github/revision.d.ts +1 -0
  69. package/dist/plus/git-github/providers/github/revision.js +5 -0
  70. package/dist/plus/git-github/providers/github/revision.js.map +1 -1
  71. package/docs/kepler-git-write-api-parity.md +140 -14
  72. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -6,6 +6,36 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.9.0] - 2026-09-29
10
+
11
+ ### Added
12
+
13
+ - Adds `excluding` to `commits.getLogShas`, the same `GitRefExclusions` `getCommitCount` takes, for listing what `rev` has that other refs don't; GitHub returns no SHAs when it's set (git, git-cli, plus/git-github)
14
+ - Adds `revision.getEmptyTreeSha(repoPath)`, the empty tree's id in the repository's own object format, SHA-1 or SHA-256, cached per repository. GitHub repositories are always SHA-1 (git, git-cli, plus/git-github)
15
+ - Adds `excluding` to `commits.getCommitCount`, counting what `rev` has that other refs don't, such as what deleting a branch would orphan. `branches`, `remotes` and `tags` exclude a whole namespace, and `except` takes full ref names back out of it, which core converts to the short form git's `--exclude` actually matches (a raw `--exclude=refs/heads/x --branches` excludes nothing). GitHub returns `undefined` when `excluding` is set (git, git-cli, plus/git-github)
16
+ - Adds `refs.getReflogEntries(repoPath, ref, { grep })`, a ref's reflog entries (sha and message, newest first) optionally filtered by git's `--grep-reflog` pattern. A failed read rejects rather than resolving `[]`, so "no match" is distinguishable from "never read" (git, git-cli)
17
+ - Adds `untracked` (`'no'`, `'normal'` or `'all'`) and `branch: false` to `status.getStatus`, for a caller that only needs the file list: `branch: false` skips `--branch`, so no upstream ahead/behind is computed, and leaves the result's branch fields unset. Defaults are unchanged (git, git-cli)
18
+ - Adds `folderName` and a trailing `runOptions` to `clone`. `folderName` is used exactly, with no auto-numbering, so git's own refusal of a non-empty folder surfaces; without it the folder is still derived from the URL and numbered past a taken one. `runOptions` carries the clone's `env`, `cancellation` and `timeout` (git, git-cli)
19
+ - Adds `preserveFetchHead` to `ops.fetch` (`--no-write-fetch-head`), for a fetch that must not disturb `FETCH_HEAD` before a user's own `git pull` reads it. Ignored on git older than 2.29, leaving `FETCH_HEAD` written as before (git, git-cli)
20
+ - Adds `refspecs` to `ops.fetch`, passed verbatim after `remote` (`git fetch <remote> <refspec>...`), for fetching one ref into a chosen destination. It never adds `-u`, so git still refuses to write into a checked-out branch. A refspec that writes a local branch or tag also announces `heads` or `tags` (git, git-cli)
21
+ - Adds `notify` to `git.run`'s options, so a raw command announces its own change through `provider.notifyChanged` once it settles, whether it succeeded or failed. `'infer'` classifies the argv: read-only and object-store-only commands announce nothing; a write announces its verb's change kinds for the repository it ran in, the `-C` target when given, and run under `-C` it also announces the kinds every worktree sharing that `.git` sees, such as a branch, tag or stash it wrote, to the caller's own tree, dropping a repository's in-flight runs once however many of its worktrees are named. An explicit list announces exactly those kinds. Left unset, nothing is classified (git, git-cli)
22
+ - Adds a trailing `runOptions` (`env`, `cancellation`, `timeout`) to `stash.applyStash`, `stash.saveStash` and `staging.clean`, as the other long-running operations already take, so a caller can lift the default timeout for a large stash or clean, or cancel one. Defaults are unchanged (git, git-cli)
23
+
24
+ ### Changed
25
+
26
+ - **Breaking (git)** — `rootSha` is removed; use `revision.getEmptyTreeSha(repoPath)`
27
+ - **Breaking (git, git-cli, plus/git-github)** — `commits.getCommitCount` takes `options` before `cancellation`, `getCommitCount(repoPath, rev, options?, cancellation?)`. A caller passing a cancellation positionally must move it
28
+ - **Breaking (git)** — `GitRevisionSubProvider` requires `getEmptyTreeSha(repoPath)`, so a custom implementation must add it
29
+ - **Breaking (git, git-cli)** — `provider.notifyChanged` without `cache` now resets only what its `changes` can have made stale — the caches a file watcher's change of the same kinds clears, status clock included — instead of every cache, and fires `cache.onReset` with those types. An empty `changes`, or one naming `unknown`, still resets everything; a kind no cache depends on, such as `starred`, resets nothing and fires no `cache.onReset`. Pass `cache: 'all'` for the old behavior (git, git-cli)
30
+
31
+ ### Fixed
32
+
33
+ - Fixes `remotes.removeRemote`, and `remotes.addRemote` with `fetch`, leaving branch lists and history reads cached without the remote-tracking branches they deleted or created, so a count excluding remote branches kept its old answer (git-cli)
34
+ - Fixes every typed write and `provider.notifyChanged` dropping the in-flight git runs of every repository, so identical reads running at once in other repositories each spawned their own process. Only the written repository's runs, its worktrees' included, are dropped now; `git.clearPendingCommands(repoPaths)` takes the paths to drop, and with none still drops all (git-cli)
35
+ - Fixes diffs against a root commit's missing parent, and against a stash's untracked files, failing in a SHA-256 repository, which the hardcoded SHA-1 empty tree doesn't exist in (git-cli)
36
+ - Fixes detecting a branch's base from its reflog failing for a branch named like a tracked file, or named `delete`, `expire` or `exists` (git-cli)
37
+ - Fixes every git command core runs targeting the wrong repository when the host itself was launched by git — from a hook, a `rebase -x` step, or as `GIT_EDITOR` (a VS Code window opened by `git rebase -i`). The inherited `GIT_DIR`, `GIT_WORK_TREE`, `GIT_INDEX_FILE`, `GIT_COMMON_DIR`, `GIT_OBJECT_DIRECTORY`, `GIT_ALTERNATE_OBJECT_DIRECTORIES` and `GIT_NAMESPACE` overrode each command's working directory, and `GIT_CONFIG_PARAMETERS`, `GIT_EXEC_PATH`, `GIT_PREFIX` and `GIT_REFLOG_ACTION` carried the launching command's own state into all of them. They are now dropped from the inherited environment, and so are `GIT_AUTHOR_*` / `GIT_COMMITTER_*` when git launched the host (it always exports `GIT_EXEC_PATH`), since an editor opened for `commit --amend` inherits that commit's author and date; an identity set deliberately still applies. A host's `env` option or a call's own `env` can still set any of them (git-cli)
38
+
9
39
  ## [0.8.0] - 2026-09-27
10
40
 
11
41
  ### Added
@@ -417,7 +447,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
417
447
 
418
448
  - 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.
419
449
 
420
- [unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.8.0...HEAD
450
+ [unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.9.0...HEAD
451
+ [0.9.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.8.0...gitkraken:releases/core/v0.9.0
421
452
  [0.8.0]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.7.2...gitkraken:releases/core/v0.8.0
422
453
  [0.7.2]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.7.1...gitkraken:releases/core/v0.7.2
423
454
  [0.7.1]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.7.0...gitkraken:releases/core/v0.7.1
@@ -101,6 +101,7 @@ export declare class Cache implements Disposable {
101
101
  get contributorsStats(): RepoPromiseCacheMap<string, GitContributorsStats | undefined>;
102
102
  get currentUser(): Map<RepoPath, GitUser | null>;
103
103
  get defaultBranchName(): RepoPromiseCacheMap<string, string | undefined>;
104
+ get emptyTreeSha(): PromiseMap<RepoPath, string>;
104
105
  get gitDir(): Map<RepoPath, GitDir>;
105
106
  get gitIgnore(): Map<RepoPath, GitIgnoreFilter>;
106
107
  get gitResults(): RepoPromiseCacheMap<RepoPath, GitResult>;
@@ -207,7 +208,15 @@ export declare class Cache implements Disposable {
207
208
  */
208
209
  unregisterRepoPath(repoPath: string): void;
209
210
  reset(): void;
211
+ /** Applies a watcher-observed change, sharing reads still in flight (see {@link applyRepositoryChanges}). */
210
212
  onRepositoryChanged(repoPath: string, changes: Iterable<RepositoryChange>): void;
213
+ /**
214
+ * Clears what `changes` can have made stale for `repoPath`, advances its status clock, and reconciles a
215
+ * `'gkConfig'` change, returning the cache types it cleared. `inFlight` is as {@link clearCaches}
216
+ * (`'share'`) vs {@link evictCaches} (`'evict'`). `'unknown'` and `'closed'` map to nothing here: the
217
+ * watcher unregisters the path on them, and an announced write resets everything instead.
218
+ */
219
+ applyRepositoryChanges(repoPath: string, changes: Iterable<RepositoryChange>, inFlight: 'share' | 'evict'): CachedGitTypes[];
211
220
  /**
212
221
  * Handles a watcher-observed `'gkConfig'` change. Always evicts the cached bulk map (forcing the
213
222
  * next read to hit disk). If a reconciler is registered (see {@link setGkConfigReconciler}),
@@ -316,6 +325,8 @@ export declare class Cache implements Disposable {
316
325
  /** Clears the cached default branch for one `remote` key (the networked lookup or its `:local` variant). */
317
326
  deleteDefaultBranchName(repoPath: string, remote: string): void;
318
327
  getInitialCommitSha(repoPath: string, factory: (commonPath: string) => PromiseOrValue<string | undefined>): Promise<string | undefined>;
328
+ /** A rejected factory is never cached (`PromiseMap` evicts on rejection) — a failed read retries next time. */
329
+ getEmptyTreeSha(repoPath: string, factory: (commonPath: string) => PromiseOrValue<string>): Promise<string>;
319
330
  getLastFetchedTimestamp(repoPath: string, factory: (commonPath: string) => PromiseOrValue<number | undefined>): Promise<number | undefined>;
320
331
  getRefs(repoPath: string, factory: (commonPath: string, cacheable: CacheController, cancellation?: AbortSignal) => PromiseOrValue<RefRecord[]>, cancellation?: AbortSignal): Promise<RefRecord[]>;
321
332
  getRefTips(repoPath: string, factory: (commonPath: string, cacheable: CacheController, cancellation?: AbortSignal) => PromiseOrValue<GitRefTip[]>, cancellation?: AbortSignal): Promise<GitRefTip[]>;
package/dist/git/cache.js CHANGED
@@ -54,6 +54,7 @@ const sharedCacheKeys = new Set(exhaustiveArray()([
54
54
  "contributorsLite",
55
55
  "contributorsStats",
56
56
  "defaultBranchName",
57
+ "emptyTreeSha",
57
58
  "gitResults",
58
59
  "gkConfigMap",
59
60
  "initialCommitSha",
@@ -94,6 +95,7 @@ function createEmptyCaches() {
94
95
  currentBranchReference: void 0,
95
96
  currentUser: void 0,
96
97
  defaultBranchName: void 0,
98
+ emptyTreeSha: void 0,
97
99
  gitDir: void 0,
98
100
  gitIgnore: void 0,
99
101
  gitResults: void 0,
@@ -237,6 +239,9 @@ var Cache = class Cache {
237
239
  get defaultBranchName() {
238
240
  return this._caches.defaultBranchName ??= new RepoPromiseCacheMap();
239
241
  }
242
+ get emptyTreeSha() {
243
+ return this._caches.emptyTreeSha ??= new PromiseMap();
244
+ }
240
245
  get gitDir() {
241
246
  return this._caches.gitDir ??= /* @__PURE__ */ new Map();
242
247
  }
@@ -420,6 +425,7 @@ var Cache = class Cache {
420
425
  keysToClear.add("refTips");
421
426
  keysToClear.add("commit");
422
427
  keysToClear.add("commitCount");
428
+ keysToClear.add("logShas");
423
429
  keysToClear.add("resolvedRevisions");
424
430
  }
425
431
  if (types.includes("tracking")) {
@@ -599,13 +605,24 @@ var Cache = class Cache {
599
605
  this._gkConfigReconciler = void 0;
600
606
  this._caches = createEmptyCaches();
601
607
  }
608
+ /** Applies a watcher-observed change, sharing reads still in flight (see {@link applyRepositoryChanges}). */
602
609
  onRepositoryChanged(repoPath, changes) {
603
610
  const changesSet = new Set(changes);
604
- const hasAny = (...c) => c.some((ch) => changesSet.has(ch));
605
- if (hasAny("unknown", "closed")) {
611
+ if (changesSet.has("unknown") || changesSet.has("closed")) {
606
612
  this.unregisterRepoPath(repoPath);
607
613
  return;
608
614
  }
615
+ this.applyRepositoryChanges(repoPath, changesSet, "share");
616
+ }
617
+ /**
618
+ * Clears what `changes` can have made stale for `repoPath`, advances its status clock, and reconciles a
619
+ * `'gkConfig'` change, returning the cache types it cleared. `inFlight` is as {@link clearCaches}
620
+ * (`'share'`) vs {@link evictCaches} (`'evict'`). `'unknown'` and `'closed'` map to nothing here: the
621
+ * watcher unregisters the path on them, and an announced write resets everything instead.
622
+ */
623
+ applyRepositoryChanges(repoPath, changes, inFlight) {
624
+ const changesSet = new Set(changes);
625
+ const hasAny = (...c) => c.some((ch) => changesSet.has(ch));
609
626
  if (hasAny("index", "head", "heads", "remotes", "ignores", "config")) this.incrementStatusGeneration(repoPath);
610
627
  const types = /* @__PURE__ */ new Set();
611
628
  if (hasAny("head")) types.add("branch");
@@ -638,7 +655,8 @@ var Cache = class Cache {
638
655
  if (hasAny("stash")) types.add("stashes");
639
656
  if (hasAny("tags")) types.add("tags");
640
657
  if (hasAny("worktrees")) types.add("worktrees");
641
- if (types.size) this.clearCaches(repoPath, ...types);
658
+ if (types.size) this.clearCachesCore(inFlight, repoPath, ...types);
659
+ return [...types];
642
660
  }
643
661
  /**
644
662
  * Handles a watcher-observed `'gkConfig'` change. Always evicts the cached bulk map (forcing the
@@ -882,6 +900,10 @@ var Cache = class Cache {
882
900
  getInitialCommitSha(repoPath, factory) {
883
901
  return this.getSharedSimple(this.initialCommitSha, repoPath, factory);
884
902
  }
903
+ /** A rejected factory is never cached (`PromiseMap` evicts on rejection) — a failed read retries next time. */
904
+ getEmptyTreeSha(repoPath, factory) {
905
+ return this.getSharedSimple(this.emptyTreeSha, repoPath, factory);
906
+ }
885
907
  getLastFetchedTimestamp(repoPath, factory) {
886
908
  return this.getSharedSimple(this.lastFetched, repoPath, factory);
887
909
  }
@@ -972,6 +994,7 @@ __decorate([debug({ onlyExit: true })], Cache.prototype, "clearCaches", null);
972
994
  __decorate([debug({ onlyExit: true })], Cache.prototype, "unregisterRepoPath", null);
973
995
  __decorate([debug({ onlyExit: true })], Cache.prototype, "reset", null);
974
996
  __decorate([debug({ onlyExit: true })], Cache.prototype, "onRepositoryChanged", null);
997
+ __decorate([debug({ onlyExit: true })], Cache.prototype, "applyRepositoryChanges", null);
975
998
  //#endregion
976
999
  export { Cache, areUriScopedCachedGitTypes, shouldEvictBlameCacheEntry };
977
1000