@gitkraken/core-gitlens 0.47.0 → 0.49.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 (42) hide show
  1. package/CHANGELOG.md +30 -1
  2. package/dist/git/cache.d.ts +4 -0
  3. package/dist/git/cache.js +12 -0
  4. package/dist/git/cache.js.map +1 -1
  5. package/dist/git/providers/config.d.ts +3 -2
  6. package/dist/git-cli/cliGitProvider.d.ts +2 -0
  7. package/dist/git-cli/cliGitProvider.js +6 -0
  8. package/dist/git-cli/cliGitProvider.js.map +1 -1
  9. package/dist/git-cli/providers/branches.js +8 -4
  10. package/dist/git-cli/providers/branches.js.map +1 -1
  11. package/dist/git-cli/providers/config.d.ts +10 -6
  12. package/dist/git-cli/providers/config.js +48 -13
  13. package/dist/git-cli/providers/config.js.map +1 -1
  14. package/dist/git-cli/providers/pausedOperations.js +2 -2
  15. package/dist/git-cli/providers/pausedOperations.js.map +1 -1
  16. package/dist/git-cli/providers/staging.js +1 -1
  17. package/dist/ipc/discovery.js +1 -1
  18. package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
  19. package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
  20. package/dist/plus/ai/providers/anthropicProvider.js +0 -20
  21. package/dist/plus/ai/providers/anthropicProvider.js.map +1 -1
  22. package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
  23. package/dist/plus/integrations/models/publicIntegration.d.ts +0 -1
  24. package/dist/plus/integrations/providers/azure/azure.js +1 -1
  25. package/dist/plus/integrations/providers/issueSorts.d.ts +0 -1
  26. package/dist/plus/integrations/reads/drains.d.ts +0 -1
  27. package/dist/utils/date.d.ts +1 -0
  28. package/dist/utils/date.js +10 -1
  29. package/dist/utils/date.js.map +1 -1
  30. package/dist/utils/env/node/exec.js +2 -2
  31. package/dist/utils/keys/keymapDispatcher.d.ts +12 -0
  32. package/dist/utils/keys/keymapDispatcher.js +41 -1
  33. package/dist/utils/keys/keymapDispatcher.js.map +1 -1
  34. package/dist/utils/pausedOperation.js +48 -16
  35. package/dist/utils/pausedOperation.js.map +1 -1
  36. package/dist/utils/plural.d.ts +1 -0
  37. package/dist/utils/plural.js +7 -2
  38. package/dist/utils/plural.js.map +1 -1
  39. package/dist/utils/wheel.d.ts +8 -0
  40. package/dist/utils/wheel.js +12 -0
  41. package/dist/utils/wheel.js.map +1 -0
  42. package/package.json +1 -1
@@ -7,6 +7,12 @@ import { DeprecatedGkConfigKeys, GitConfigKeys, GitConfigSubProvider, GitConfigT
7
7
  import { Git } from "../exec/git.js";
8
8
  import { CliGitProviderInternal } from "../cliGitProvider.js";
9
9
  //#region ../git-cli/src/providers/config.d.ts
10
+ type RepositoryInfo = {
11
+ repoPath: string;
12
+ gitDir: string;
13
+ commonGitDir: string | undefined;
14
+ superprojectPath: string | undefined;
15
+ } | [safe: true, repoPath: string] | [safe: false] | [];
10
16
  /** The clock a failed current-user read's wait is measured on, exported for testing */
11
17
  export declare const currentUserReadClock: {
12
18
  now: () => number;
@@ -134,6 +140,7 @@ export declare class ConfigGitSubProvider implements GitConfigSubProvider {
134
140
  getDefaultWorktreePath(repoPath: string): Promise<string | undefined>;
135
141
  getGitDir(repoPath: string): Promise<GitDir>;
136
142
  private readGitDir;
143
+ private throwIfClosedSince;
137
144
  /**
138
145
  * Caches `repoPath`'s git dir when its files show it (see {@link readGitDirsWithoutGit}), never running git; whether
139
146
  * one is cached. `false` for a layout only git can answer for (a bare repository, a submodule, a
@@ -230,12 +237,9 @@ export declare class ConfigGitSubProvider implements GitConfigSubProvider {
230
237
  * `[]` when git says `cwd` isn't a repository it can use, or `cwd` isn't a folder. Rejects when git gives no answer
231
238
  * (it ran past its time limit, was killed or couldn't start), which says nothing about `cwd`.
232
239
  */
233
- getRepositoryInfo(cwd: string): Promise<{
234
- repoPath: string;
235
- gitDir: string;
236
- commonGitDir: string | undefined;
237
- superprojectPath: string | undefined;
238
- } | [safe: true, repoPath: string] | [safe: false] | []>;
240
+ getRepositoryInfo(cwd: string): Promise<RepositoryInfo>;
241
+ private getCloseGeneration;
242
+ private readRepositoryInfo;
239
243
  /**
240
244
  * Ensures the `.git/gk/` folder exists, but only if the parent `.git` directory already exists.
241
245
  * This prevents creating stray `.git` directories if the computed path is wrong.
@@ -15,9 +15,9 @@ import { KeyedSequencer } from "../exec/indexLock.js";
15
15
  import { isFolder, isGitAnswer, isGitUnanswered, throwIfUnanswered } from "../exec/git.js";
16
16
  import { HoldOffMap } from "../../utils/holdOffMap.js";
17
17
  import { gate } from "../../utils/decorators/gate.js";
18
- import { hostname, userInfo } from "os";
19
- import { env } from "process";
20
18
  import { promises, statSync } from "fs";
19
+ import { env } from "process";
20
+ import { hostname, userInfo } from "os";
21
21
  //#region ../git-cli/src/providers/config.ts
22
22
  const mappedAuthorRegex = /(.+)\s<(.+)>/;
23
23
  const emptyArray = Object.freeze([]);
@@ -395,26 +395,33 @@ var ConfigGitSubProvider = class {
395
395
  let gitDir;
396
396
  const fsGitDirs = await this.readGitDirsWithoutGit(repoPath);
397
397
  if (fsGitDirs != null) {
398
+ this.throwIfClosedSince(repoPath, closeGeneration);
398
399
  gitDir = toGitDir(fsGitDirs);
399
- if (this.cache.getCloseGeneration(repoPath) === closeGeneration) this.cache.gitDir.set(repoPath, gitDir);
400
+ this.cache.gitDir.set(repoPath, gitDir);
400
401
  return gitDir;
401
402
  }
402
403
  const repoInfo = await this.getRepositoryInfo(repoPath);
403
- if (!Array.isArray(repoInfo) && repoInfo != null) gitDir = {
404
- uri: fileUri(repoInfo.gitDir),
405
- commonUri: repoInfo.commonGitDir ? fileUri(repoInfo.commonGitDir) : void 0,
406
- parentUri: repoInfo.superprojectPath ? fileUri(repoInfo.superprojectPath) : void 0
407
- };
408
- else {
404
+ if (!Array.isArray(repoInfo) && repoInfo != null) {
405
+ this.throwIfClosedSince(repoPath, closeGeneration);
406
+ gitDir = {
407
+ uri: fileUri(repoInfo.gitDir),
408
+ commonUri: repoInfo.commonGitDir ? fileUri(repoInfo.commonGitDir) : void 0,
409
+ parentUri: repoInfo.superprojectPath ? fileUri(repoInfo.superprojectPath) : void 0
410
+ };
411
+ } else {
409
412
  gitDir = { uri: this.provider.getAbsoluteUri(joinPaths(repoPath, ".git"), repoPath) };
410
413
  if (!this.isTrusted(repoPath)) return gitDir;
414
+ this.throwIfClosedSince(repoPath, closeGeneration);
411
415
  const gitDirPath = gitDir.uri.toString(true);
412
416
  scope?.warn(`rev-parse failed for '${repoPath}'; falling back to '${gitDirPath}'`);
413
417
  this.context.hooks?.operations?.onGitDirResolveFailed?.(repoPath, gitDirPath, `rev_parse returned ${JSON.stringify(repoInfo)}`);
414
418
  }
415
- if (this.cache.getCloseGeneration(repoPath) === closeGeneration) this.cache.gitDir.set(repoPath, gitDir);
419
+ this.cache.gitDir.set(repoPath, gitDir);
416
420
  return gitDir;
417
421
  }
422
+ throwIfClosedSince(repoPath, closeGeneration) {
423
+ if (this.cache.getCloseGeneration(repoPath) !== closeGeneration) throw new Error(`'${repoPath}' was closed while its git dir was read`);
424
+ }
418
425
  /**
419
426
  * Caches `repoPath`'s git dir when its files show it (see {@link readGitDirsWithoutGit}), never running git; whether
420
427
  * one is cached. `false` for a layout only git can answer for (a bare repository, a submodule, a
@@ -425,7 +432,7 @@ var ConfigGitSubProvider = class {
425
432
  if (this.cache.gitDir.get(repoPath) != null) return true;
426
433
  const closeGeneration = this.cache.getCloseGeneration(repoPath);
427
434
  const fsGitDirs = await this.readGitDirsWithoutGit(repoPath, true);
428
- if (this.cache.getCloseGeneration(repoPath) !== closeGeneration) throw new Error(`'${repoPath}' was closed while its git dir was read`);
435
+ this.throwIfClosedSince(repoPath, closeGeneration);
429
436
  if (fsGitDirs == null) return false;
430
437
  if (this.cache.gitDir.get(repoPath) == null) this.cache.gitDir.set(repoPath, toGitDir(fsGitDirs));
431
438
  return true;
@@ -789,6 +796,25 @@ var ConfigGitSubProvider = class {
789
796
  * (it ran past its time limit, was killed or couldn't start), which says nothing about `cwd`.
790
797
  */
791
798
  async getRepositoryInfo(cwd) {
799
+ const stampedPaths = getPathAndAncestors(cwd);
800
+ const closeGeneration = this.getCloseGeneration(stampedPaths);
801
+ const info = await this.readRepositoryInfo(cwd);
802
+ if (Array.isArray(info)) return info;
803
+ if (!stampedPaths.includes(info.repoPath)) return info;
804
+ if (this.getCloseGeneration(stampedPaths) !== closeGeneration) return info;
805
+ this.cache.gitDir.set(info.repoPath, {
806
+ uri: fileUri(info.gitDir),
807
+ commonUri: info.commonGitDir ? fileUri(info.commonGitDir) : void 0,
808
+ parentUri: info.superprojectPath ? fileUri(info.superprojectPath) : void 0
809
+ });
810
+ return info;
811
+ }
812
+ getCloseGeneration(paths) {
813
+ let generation = 0;
814
+ for (const path of paths) generation += this.cache.getCloseGeneration(path);
815
+ return generation;
816
+ }
817
+ async readRepositoryInfo(cwd) {
792
818
  let result;
793
819
  if (!this.isTrusted(cwd)) try {
794
820
  await promises.stat(joinPaths(cwd, "HEAD"));
@@ -852,7 +878,7 @@ var ConfigGitSubProvider = class {
852
878
  const repoPath = result?.commonPath ?? result?.path;
853
879
  if (repoPath?.length) {
854
880
  const workTree = await this.git.rev_parse__work_tree_of_git_dir(repoPath);
855
- return workTree ? this.getRepositoryInfo(workTree) : [true, repoPath];
881
+ return workTree ? this.readRepositoryInfo(workTree) : [true, repoPath];
856
882
  }
857
883
  }
858
884
  }
@@ -864,7 +890,7 @@ var ConfigGitSubProvider = class {
864
890
  cwd = parent;
865
891
  exists = await fsExists(cwd);
866
892
  } while (!exists);
867
- return this.getRepositoryInfo(cwd);
893
+ return this.readRepositoryInfo(cwd);
868
894
  }
869
895
  return emptyArray;
870
896
  }
@@ -996,6 +1022,15 @@ function toGitDir(fsGitDirs) {
996
1022
  parentUri: void 0
997
1023
  };
998
1024
  }
1025
+ function getPathAndAncestors(path) {
1026
+ const paths = [];
1027
+ while (true) {
1028
+ paths.push(normalizePath(path));
1029
+ const parent = dirname(path);
1030
+ if (parent === path) return paths;
1031
+ path = parent;
1032
+ }
1033
+ }
999
1034
  //#endregion
1000
1035
  export { ConfigGitSubProvider, canonicalizeGitConfigKey, currentUserReadClock, gkConfigFingerprintClock, isGitBooleanFalse, isGkConfigStatRacy, mayConfigDifferByCheckout, parseConfigListing, parseConfigRegexNullOutput, parseConfigRegexOutput, parseGitBoolean };
1001
1036