@gitkraken/core-gitlens 0.32.0 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/CHANGELOG.md +42 -1
  2. package/dist/git/cache.d.ts +121 -15
  3. package/dist/git/cache.js +316 -74
  4. package/dist/git/cache.js.map +1 -1
  5. package/dist/git/context.d.ts +3 -1
  6. package/dist/git/context.js.map +1 -1
  7. package/dist/git/errors.d.ts +3 -1
  8. package/dist/git/errors.js +4 -1
  9. package/dist/git/errors.js.map +1 -1
  10. package/dist/git/models/pullRequest.d.ts +90 -1
  11. package/dist/git/models/pullRequest.js +18 -2
  12. package/dist/git/models/pullRequest.js.map +1 -1
  13. package/dist/git/models/repositoryIdentities.d.ts +0 -1
  14. package/dist/git/models/repositoryIdentities.js +1 -4
  15. package/dist/git/models/repositoryIdentities.js.map +1 -1
  16. package/dist/git/providers/provider.d.ts +7 -0
  17. package/dist/git/providers/shared/remotes.js +2 -0
  18. package/dist/git/providers/shared/remotes.js.map +1 -1
  19. package/dist/git/remotes/gitlab.js +15 -9
  20. package/dist/git/remotes/gitlab.js.map +1 -1
  21. package/dist/git/service.js +4 -1
  22. package/dist/git/service.js.map +1 -1
  23. package/dist/git/utils/pullRequest.utils.d.ts +72 -1
  24. package/dist/git/utils/pullRequest.utils.js +99 -1
  25. package/dist/git/utils/pullRequest.utils.js.map +1 -1
  26. package/dist/git/utils/repository.utils.d.ts +16 -0
  27. package/dist/git/utils/repository.utils.js +37 -2
  28. package/dist/git/utils/repository.utils.js.map +1 -1
  29. package/dist/git/watching/changeEvent.d.ts +13 -3
  30. package/dist/git/watching/changeEvent.js +19 -4
  31. package/dist/git/watching/changeEvent.js.map +1 -1
  32. package/dist/git/watching/gitDirPoller.d.ts +10 -1
  33. package/dist/git/watching/gitDirPoller.js +9 -3
  34. package/dist/git/watching/gitDirPoller.js.map +1 -1
  35. package/dist/git/watching/unwatchedCacheValidator.d.ts +144 -0
  36. package/dist/git/watching/unwatchedCacheValidator.js +884 -0
  37. package/dist/git/watching/unwatchedCacheValidator.js.map +1 -0
  38. package/dist/git/watching/watchGroup.d.ts +6 -2
  39. package/dist/git/watching/watchGroup.js +35 -24
  40. package/dist/git/watching/watchGroup.js.map +1 -1
  41. package/dist/git/watching/watchService.d.ts +27 -1
  42. package/dist/git/watching/watchService.js +60 -17
  43. package/dist/git/watching/watchService.js.map +1 -1
  44. package/dist/git/watching/watchSession.d.ts +29 -12
  45. package/dist/git/watching/watchSession.js +52 -21
  46. package/dist/git/watching/watchSession.js.map +1 -1
  47. package/dist/git/watching/worktreeSummary.js +7 -7
  48. package/dist/git/watching/worktreeSummary.js.map +1 -1
  49. package/dist/git-cli/cliGitProvider.d.ts +28 -2
  50. package/dist/git-cli/cliGitProvider.js +63 -20
  51. package/dist/git-cli/cliGitProvider.js.map +1 -1
  52. package/dist/git-cli/exec/commandClassifier.d.ts +31 -1
  53. package/dist/git-cli/exec/commandClassifier.js +67 -16
  54. package/dist/git-cli/exec/commandClassifier.js.map +1 -1
  55. package/dist/git-cli/exec/git.d.ts +46 -2
  56. package/dist/git-cli/exec/git.js +87 -9
  57. package/dist/git-cli/exec/git.js.map +1 -1
  58. package/dist/git-cli/exec/gitDirResolver.d.ts +11 -0
  59. package/dist/git-cli/exec/gitDirResolver.js +34 -1
  60. package/dist/git-cli/exec/gitDirResolver.js.map +1 -1
  61. package/dist/git-cli/exec/gitQueue.js +2 -28
  62. package/dist/git-cli/exec/gitQueue.js.map +1 -1
  63. package/dist/git-cli/providers/branches.d.ts +1 -0
  64. package/dist/git-cli/providers/branches.js +21 -10
  65. package/dist/git-cli/providers/branches.js.map +1 -1
  66. package/dist/git-cli/providers/config.d.ts +15 -1
  67. package/dist/git-cli/providers/config.js +67 -22
  68. package/dist/git-cli/providers/config.js.map +1 -1
  69. package/dist/git-cli/providers/pausedOperations.d.ts +1 -0
  70. package/dist/git-cli/providers/pausedOperations.js +4 -0
  71. package/dist/git-cli/providers/pausedOperations.js.map +1 -1
  72. package/dist/git-cli/providers/revision.js +2 -0
  73. package/dist/git-cli/providers/revision.js.map +1 -1
  74. package/dist/git-cli/providers/worktrees.js +36 -10
  75. package/dist/git-cli/providers/worktrees.js.map +1 -1
  76. package/dist/git-cli/service.d.ts +25 -1
  77. package/dist/git-cli/service.js +46 -1
  78. package/dist/git-cli/service.js.map +1 -1
  79. package/dist/plus/ai/errors.d.ts +8 -2
  80. package/dist/plus/ai/errors.js +15 -3
  81. package/dist/plus/ai/errors.js.map +1 -1
  82. package/dist/plus/git-github/api/github.d.ts +51 -1
  83. package/dist/plus/git-github/api/github.js +276 -3
  84. package/dist/plus/git-github/api/github.js.map +1 -1
  85. package/dist/plus/git-github/models.d.ts +54 -1
  86. package/dist/plus/git-github/models.js +48 -3
  87. package/dist/plus/git-github/models.js.map +1 -1
  88. package/dist/plus/integrations/fieldPresence.d.ts +6 -1
  89. package/dist/plus/integrations/fieldPresence.js +19 -9
  90. package/dist/plus/integrations/fieldPresence.js.map +1 -1
  91. package/dist/plus/integrations/models/gitHostIntegration.d.ts +26 -1
  92. package/dist/plus/integrations/models/gitHostIntegration.js +51 -0
  93. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  94. package/dist/plus/integrations/models/integration.d.ts +15 -2
  95. package/dist/plus/integrations/models/integration.js +1 -1
  96. package/dist/plus/integrations/models/integration.js.map +1 -1
  97. package/dist/plus/integrations/providers/github.d.ts +16 -1
  98. package/dist/plus/integrations/providers/github.js +53 -1
  99. package/dist/plus/integrations/providers/github.js.map +1 -1
  100. package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +10 -0
  101. package/dist/plus/integrations/providers/gitlab/gitlab.js +62 -15
  102. package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
  103. package/dist/plus/integrations/providers/gitlab/gitlab.utils.d.ts +8 -0
  104. package/dist/plus/integrations/providers/gitlab/gitlab.utils.js +32 -16
  105. package/dist/plus/integrations/providers/gitlab/gitlab.utils.js.map +1 -1
  106. package/dist/plus/integrations/reads/etag.js +11 -0
  107. package/dist/plus/integrations/reads/etag.js.map +1 -1
  108. package/docs/integrations.md +39 -6
  109. package/package.json +1 -1
@@ -120,9 +120,23 @@ export declare class ConfigGitSubProvider implements GitConfigSubProvider {
120
120
  }): Promise<void>;
121
121
  private setConfigCore;
122
122
  getCurrentUser(repoPath: string): Promise<GitUser | undefined>;
123
+ private readCurrentUser;
123
124
  getDefaultWorktreePath(repoPath: string): Promise<string | undefined>;
124
125
  getGitDir(repoPath: string): Promise<GitDir>;
125
- /** The git dirs {@link getRepositoryInfo} would report for `repoPath`, when they can be read without running git */
126
+ private readGitDir;
127
+ /**
128
+ * Caches `repoPath`'s git dir when its files show it (see {@link readGitDirsWithoutGit}), never running git; whether
129
+ * one is cached. `false` for a layout only git can answer for (a bare repository, a submodule, a
130
+ * `--separate-git-dir` checkout, a `core.worktree`), which {@link getGitDir} resolves. Rejects when the answer may
131
+ * differ if asked again soon: a file failed to read in a way that may pass, or the repository closed mid-read
132
+ */
133
+ resolveGitDirWithoutGit(repoPath: string): Promise<boolean>;
134
+ /** Whether git may be run in `repoPath`: the context's workspace flag, then the host's per-path predicate */
135
+ private isTrusted;
136
+ /**
137
+ * The git dirs {@link getRepositoryInfo} would report for `repoPath`, when they can be read without running git;
138
+ * `rejectIfTransient` rejects for a read that failed in a way that may pass (see `readGitDirsOrReject`)
139
+ */
126
140
  private readGitDirsWithoutGit;
127
141
  /**
128
142
  * Gets the path to the .git/gk/config file for storing GitKraken-specific metadata.
@@ -10,7 +10,7 @@ import { parseBranchMetadataGkConfigKey } from "../../git/utils/branch.utils.js"
10
10
  import __decorate from "../../_virtual/@oxc-project+runtime/helpers/esm/decorate.js";
11
11
  import { WorkspaceUntrustedError } from "../../git/errors.js";
12
12
  import { fsExists } from "../../utils/env/node/exec.js";
13
- import { isGitDirMovedByEnv, readGitDirs } from "../exec/gitDirResolver.js";
13
+ import { isGitDirMovedByEnv, readGitDirs, readGitDirsOrReject } from "../exec/gitDirResolver.js";
14
14
  import { KeyedSequencer } from "../exec/indexLock.js";
15
15
  import { isFolder, isGitAnswer, isGitUnanswered, throwIfUnanswered } from "../exec/git.js";
16
16
  import { gate } from "../../utils/decorators/gate.js";
@@ -314,9 +314,17 @@ var ConfigGitSubProvider = class {
314
314
  async getCurrentUser(repoPath) {
315
315
  if (!repoPath) return void 0;
316
316
  const scope = getScopedLogger();
317
+ const validation = this.cache.validateBeforeRead(repoPath);
318
+ if (validation != null) await validation;
317
319
  const cached = this.cache.currentUser.get(repoPath);
318
320
  if (cached != null) return cached;
319
321
  if (cached === null) return void 0;
322
+ return this.readCurrentUser(repoPath, this.cache.getDropStamp("currentUser", repoPath), scope);
323
+ }
324
+ async readCurrentUser(repoPath, dropStamp, scope) {
325
+ const setCachedUser = (value) => {
326
+ if (!this.cache.isDroppedSince("currentUser", repoPath, dropStamp)) this.cache.currentUser.set(repoPath, value);
327
+ };
320
328
  const user = {
321
329
  name: void 0,
322
330
  email: void 0
@@ -329,7 +337,7 @@ var ConfigGitSubProvider = class {
329
337
  } else {
330
338
  user.name = env.GIT_AUTHOR_NAME || env.GIT_COMMITTER_NAME || userInfo()?.username || void 0;
331
339
  if (!user.name) {
332
- this.cache.currentUser.set(repoPath, null);
340
+ setCachedUser(null);
333
341
  return;
334
342
  }
335
343
  user.email = env.GIT_AUTHOR_EMAIL || env.GIT_COMMITTER_EMAIL || env.EMAIL || `${user.name}@${hostname()}`;
@@ -343,11 +351,12 @@ var ConfigGitSubProvider = class {
343
351
  const match = mappedAuthorRegex.exec(result.stdout);
344
352
  if (match != null) [, user.name, user.email] = match;
345
353
  }
346
- this.cache.currentUser.set(repoPath, user);
354
+ setCachedUser(user);
347
355
  return user;
348
356
  } catch (ex) {
357
+ if (ex instanceof WorkspaceUntrustedError) return void 0;
349
358
  scope?.error(ex);
350
- this.cache.currentUser.set(repoPath, null);
359
+ setCachedUser(null);
351
360
  return;
352
361
  }
353
362
  }
@@ -361,17 +370,14 @@ var ConfigGitSubProvider = class {
361
370
  const cached = this.cache.gitDir.get(repoPath);
362
371
  if (cached != null) return cached;
363
372
  const scope = getScopedLogger();
373
+ return this.readGitDir(repoPath, this.cache.getCloseGeneration(repoPath), scope);
374
+ }
375
+ async readGitDir(repoPath, closeGeneration, scope) {
364
376
  let gitDir;
365
377
  const fsGitDirs = await this.readGitDirsWithoutGit(repoPath);
366
378
  if (fsGitDirs != null) {
367
- const path = normalizePath(fsGitDirs.gitDir);
368
- const commonPath = normalizePath(fsGitDirs.commonGitDir);
369
- gitDir = {
370
- uri: fileUri(path),
371
- commonUri: commonPath !== path ? fileUri(commonPath) : void 0,
372
- parentUri: void 0
373
- };
374
- this.cache.gitDir.set(repoPath, gitDir);
379
+ gitDir = toGitDir(fsGitDirs);
380
+ if (this.cache.getCloseGeneration(repoPath) === closeGeneration) this.cache.gitDir.set(repoPath, gitDir);
375
381
  return gitDir;
376
382
  }
377
383
  const repoInfo = await this.getRepositoryInfo(repoPath);
@@ -382,18 +388,41 @@ var ConfigGitSubProvider = class {
382
388
  };
383
389
  else {
384
390
  gitDir = { uri: this.provider.getAbsoluteUri(joinPaths(repoPath, ".git"), repoPath) };
391
+ if (!this.isTrusted(repoPath)) return gitDir;
385
392
  const gitDirPath = gitDir.uri.toString(true);
386
393
  scope?.warn(`rev-parse failed for '${repoPath}'; falling back to '${gitDirPath}'`);
387
394
  this.context.hooks?.operations?.onGitDirResolveFailed?.(repoPath, gitDirPath, `rev_parse returned ${JSON.stringify(repoInfo)}`);
388
395
  }
389
- this.cache.gitDir.set(repoPath, gitDir);
396
+ if (this.cache.getCloseGeneration(repoPath) === closeGeneration) this.cache.gitDir.set(repoPath, gitDir);
390
397
  return gitDir;
391
398
  }
392
- /** The git dirs {@link getRepositoryInfo} would report for `repoPath`, when they can be read without running git */
393
- async readGitDirsWithoutGit(repoPath) {
394
- if (this.context.workspace?.isTrusted === false || this.git.options.isTrusted?.() === false) return void 0;
399
+ /**
400
+ * Caches `repoPath`'s git dir when its files show it (see {@link readGitDirsWithoutGit}), never running git; whether
401
+ * one is cached. `false` for a layout only git can answer for (a bare repository, a submodule, a
402
+ * `--separate-git-dir` checkout, a `core.worktree`), which {@link getGitDir} resolves. Rejects when the answer may
403
+ * differ if asked again soon: a file failed to read in a way that may pass, or the repository closed mid-read
404
+ */
405
+ async resolveGitDirWithoutGit(repoPath) {
406
+ if (this.cache.gitDir.get(repoPath) != null) return true;
407
+ const closeGeneration = this.cache.getCloseGeneration(repoPath);
408
+ const fsGitDirs = await this.readGitDirsWithoutGit(repoPath, true);
409
+ if (this.cache.getCloseGeneration(repoPath) !== closeGeneration) throw new Error(`'${repoPath}' was closed while its git dir was read`);
410
+ if (fsGitDirs == null) return false;
411
+ if (this.cache.gitDir.get(repoPath) == null) this.cache.gitDir.set(repoPath, toGitDir(fsGitDirs));
412
+ return true;
413
+ }
414
+ /** Whether git may be run in `repoPath`: the context's workspace flag, then the host's per-path predicate */
415
+ isTrusted(repoPath) {
416
+ return this.context.workspace?.isTrusted !== false && this.git.isPathTrusted(repoPath);
417
+ }
418
+ /**
419
+ * The git dirs {@link getRepositoryInfo} would report for `repoPath`, when they can be read without running git;
420
+ * `rejectIfTransient` rejects for a read that failed in a way that may pass (see `readGitDirsOrReject`)
421
+ */
422
+ async readGitDirsWithoutGit(repoPath, rejectIfTransient) {
423
+ if (!this.isTrusted(repoPath)) return void 0;
395
424
  if (isGitDirMovedByEnv(this.git.getRunEnvironment())) return void 0;
396
- return readGitDirs(repoPath, this.cache.superprojects);
425
+ return rejectIfTransient ? readGitDirsOrReject(repoPath, this.cache.superprojects) : readGitDirs(repoPath, this.cache.superprojects);
397
426
  }
398
427
  /**
399
428
  * Gets the path to the .git/gk/config file for storing GitKraken-specific metadata.
@@ -734,7 +763,7 @@ var ConfigGitSubProvider = class {
734
763
  */
735
764
  async getRepositoryInfo(cwd) {
736
765
  let result;
737
- if (this.context.workspace?.isTrusted === false) try {
766
+ if (!this.isTrusted(cwd)) try {
738
767
  await promises.stat(joinPaths(cwd, "HEAD"));
739
768
  result = await this.git.run({
740
769
  cwd,
@@ -782,7 +811,7 @@ var ConfigGitSubProvider = class {
782
811
  return [false];
783
812
  }
784
813
  const inDotGit = /this operation must be run in a work tree/.test(ex.stderr);
785
- if (inDotGit && this.context.workspace?.isTrusted !== false) {
814
+ if (inDotGit && this.isTrusted(cwd)) {
786
815
  result = await this.git.run({
787
816
  cwd,
788
817
  errors: "ignore"
@@ -895,15 +924,21 @@ __decorate([trace({ quiet: true })], ConfigGitSubProvider.prototype, "getIgnoreC
895
924
  __decorate([trace({ quiet: true })], ConfigGitSubProvider.prototype, "getConfigRegex", null);
896
925
  __decorate([trace({ quiet: true })], ConfigGitSubProvider.prototype, "getConfigRegexAll", null);
897
926
  __decorate([debug()], ConfigGitSubProvider.prototype, "setConfig", null);
898
- __decorate([gate(), debug({ quiet: true })], ConfigGitSubProvider.prototype, "getCurrentUser", null);
899
- __decorate([gate(), trace({
927
+ __decorate([debug({ quiet: true })], ConfigGitSubProvider.prototype, "getCurrentUser", null);
928
+ __decorate([gate((repoPath, dropStamp) => `${repoPath}|${dropStamp}`)], ConfigGitSubProvider.prototype, "readCurrentUser", null);
929
+ __decorate([trace({
900
930
  quiet: true,
901
931
  exit: (r) => `returned ${r}`
902
932
  })], ConfigGitSubProvider.prototype, "getDefaultWorktreePath", null);
903
- __decorate([gate(), trace({
933
+ __decorate([trace({
904
934
  quiet: true,
905
935
  exit: (r) => `returned ${r.uri.toString(true)}, commonUri=${r.commonUri?.toString(true)}, parentUri=${r.parentUri?.toString(true)}`
906
936
  })], ConfigGitSubProvider.prototype, "getGitDir", null);
937
+ __decorate([gate((repoPath, closeGeneration) => `${repoPath}|${closeGeneration}`)], ConfigGitSubProvider.prototype, "readGitDir", null);
938
+ __decorate([trace({
939
+ quiet: true,
940
+ exit: (r) => `returned ${r}`
941
+ })], ConfigGitSubProvider.prototype, "resolveGitDirWithoutGit", null);
907
942
  __decorate([trace({ quiet: true })], ConfigGitSubProvider.prototype, "getGkConfig", null);
908
943
  __decorate([trace({ quiet: true })], ConfigGitSubProvider.prototype, "getGkConfigRegex", null);
909
944
  __decorate([debug()], ConfigGitSubProvider.prototype, "setGkConfig", null);
@@ -913,6 +948,16 @@ __decorate([debug({ quiet: true })], ConfigGitSubProvider.prototype, "getSigning
913
948
  __decorate([debug({ quiet: true })], ConfigGitSubProvider.prototype, "validateSigningSetup", null);
914
949
  __decorate([debug()], ConfigGitSubProvider.prototype, "setSigningConfig", null);
915
950
  __decorate([gate(), debug()], ConfigGitSubProvider.prototype, "migrateGkConfigFromGitConfig", null);
951
+ /** The git dir {@link ConfigGitSubProvider.getGitDir} answers from the git dirs read without git */
952
+ function toGitDir(fsGitDirs) {
953
+ const path = normalizePath(fsGitDirs.gitDir);
954
+ const commonPath = normalizePath(fsGitDirs.commonGitDir);
955
+ return {
956
+ uri: fileUri(path),
957
+ commonUri: commonPath !== path ? fileUri(commonPath) : void 0,
958
+ parentUri: void 0
959
+ };
960
+ }
916
961
  //#endregion
917
962
  export { ConfigGitSubProvider, canonicalizeGitConfigKey, gkConfigFingerprintClock, isGitBooleanFalse, isGkConfigStatRacy, mayConfigDifferByCheckout, parseConfigListing, parseConfigRegexNullOutput, parseConfigRegexOutput, parseGitBoolean };
918
963