@gitkraken/core-gitlens 0.29.0 → 0.31.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 (52) hide show
  1. package/CHANGELOG.md +33 -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/models/issue.d.ts +3 -2
  6. package/dist/git/models/issue.js +3 -1
  7. package/dist/git/models/issue.js.map +1 -1
  8. package/dist/git/models/issueOrPullRequest.d.ts +21 -0
  9. package/dist/git/models/pullRequest.d.ts +7 -3
  10. package/dist/git/models/pullRequest.js +3 -1
  11. package/dist/git/models/pullRequest.js.map +1 -1
  12. package/dist/git/utils/issue.utils.js +3 -1
  13. package/dist/git/utils/issue.utils.js.map +1 -1
  14. package/dist/git/utils/issueOrPullRequest.utils.d.ts +3 -1
  15. package/dist/git/utils/issueOrPullRequest.utils.js +12 -1
  16. package/dist/git/utils/issueOrPullRequest.utils.js.map +1 -1
  17. package/dist/git/utils/pullRequest.utils.js +2 -0
  18. package/dist/git/utils/pullRequest.utils.js.map +1 -1
  19. package/dist/git/watching/worktreeSummary.d.ts +16 -7
  20. package/dist/git/watching/worktreeSummary.js +44 -14
  21. package/dist/git/watching/worktreeSummary.js.map +1 -1
  22. package/dist/git-cli/exec/gitDirResolver.d.ts +6 -1
  23. package/dist/git-cli/exec/gitDirResolver.js +9 -4
  24. package/dist/git-cli/exec/gitDirResolver.js.map +1 -1
  25. package/dist/git-cli/providers/branches.d.ts +9 -0
  26. package/dist/git-cli/providers/branches.js +183 -105
  27. package/dist/git-cli/providers/branches.js.map +1 -1
  28. package/dist/git-cli/providers/config.js +1 -1
  29. package/dist/git-cli/providers/config.js.map +1 -1
  30. package/dist/plus/git-github/api/github.js +16 -0
  31. package/dist/plus/git-github/api/github.js.map +1 -1
  32. package/dist/plus/git-github/models.d.ts +12 -0
  33. package/dist/plus/git-github/models.js +14 -3
  34. package/dist/plus/git-github/models.js.map +1 -1
  35. package/dist/plus/integrations/fieldPresence.d.ts +6 -2
  36. package/dist/plus/integrations/fieldPresence.js +47 -16
  37. package/dist/plus/integrations/fieldPresence.js.map +1 -1
  38. package/dist/plus/integrations/providers/gitlab/gitlab.js +7 -5
  39. package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
  40. package/dist/plus/integrations/providers/gitlab/models.d.ts +1 -0
  41. package/dist/plus/integrations/providers/gitlab/models.js +8 -6
  42. package/dist/plus/integrations/providers/gitlab/models.js.map +1 -1
  43. package/dist/plus/integrations/providers/models.js +18 -3
  44. package/dist/plus/integrations/providers/models.js.map +1 -1
  45. package/dist/plus/integrations/reads/pullRequestBranches.d.ts +2 -1
  46. package/dist/plus/integrations/reads/pullRequestBranches.js.map +1 -1
  47. package/dist/plus/integrations/reads/resolveRepository.js +3 -2
  48. package/dist/plus/integrations/reads/resolveRepository.js.map +1 -1
  49. package/dist/plus/integrations/results.d.ts +8 -3
  50. package/dist/plus/integrations/results.js.map +1 -1
  51. package/docs/integrations.md +28 -7
  52. package/package.json +1 -1
@@ -238,14 +238,16 @@ var WorktreeSummaryService = class {
238
238
  this.unwatchedFlights.delete(key);
239
239
  target.running = this.start(target);
240
240
  }
241
- } else if (target.handle != null) subscription.attach(target.handle.session);
242
- else if (target.running == null && !target.disposed) target.running = this.start(target);
241
+ } else if (target.handle != null) {
242
+ subscription.attach(target.handle.session);
243
+ if (target.running == null && target.value == null && isCancellationError(target.error)) this.queue(target, allFields);
244
+ } else if (target.running == null && !target.disposed) target.running = this.start(target);
243
245
  return subscription;
244
246
  }
245
247
  /**
246
248
  * Returns a worktree's summary. For a subscribed worktree, the cached value — after waiting for any run in flight
247
- * or pending; it rejects with the read's error when there is still no value. Otherwise the last read of it,
248
- * re-reading what moved since (see {@link getSummarySnapshot}).
249
+ * or pending; it rejects with the read's error when there is still no value, after one more read when git ran out
250
+ * of time. Otherwise the last read of it, re-reading what moved since (see {@link getSummarySnapshot}).
249
251
  */
250
252
  async getSummary(repoPath, cancellation) {
251
253
  const key = getRepositoryKey(repoPath);
@@ -259,8 +261,9 @@ var WorktreeSummaryService = class {
259
261
  * the saved read's (see {@link WorktreeSummarySubscription.dirtyReadAt}), which `probeDirty` reads again. Any other
260
262
  * answers from its last read, re-reading only the groups whose inputs moved since (no git when none did), and in
261
263
  * full the first time, or after a failed or stale read. Its working tree is unwatched, so the dirty flag is re-read
262
- * only when the index file moved, or with `probeDirty`; a rejection drops the last read. Its inputs are core's
263
- * cached answers, which only a `.git` watch of the worktree (or core's own writes) keeps current.
264
+ * only when the index file moved, or with `probeDirty`; a rejection drops the last read, unless the read was cut
265
+ * short, which says nothing against it. Its inputs are core's cached answers, which only a `.git` watch of the
266
+ * worktree (or core's own writes) keeps current.
264
267
  */
265
268
  async getSummarySnapshot(repoPath, options) {
266
269
  const key = getRepositoryKey(repoPath);
@@ -279,11 +282,31 @@ var WorktreeSummaryService = class {
279
282
  dirtyReadAt: entry.dirtyReadAt
280
283
  };
281
284
  }
285
+ /**
286
+ * A first read cut short (git ran past its time limit, or was killed) says nothing about the worktree, and no git
287
+ * event may come to read it again, so each reader reads once more, joining a read in flight, before getting its
288
+ * error, and so does each new subscriber. Only they cause this: reads of a worktree run one at a time, each bounded
289
+ * by the time limit and holding a read slot.
290
+ */
282
291
  async getSubscribedSummary(entry, cancellation) {
292
+ let summary = await this.waitForValue(entry, cancellation);
293
+ if (summary != null) return summary;
294
+ if (isCancellationError(entry.error)) {
295
+ if (cancellation?.aborted) throw new CancellationError();
296
+ if (entry.running == null) {
297
+ if (entry.handle == null) entry.running = this.start(entry);
298
+ else this.queue(entry, allFields);
299
+ }
300
+ summary = await this.waitForValue(entry, cancellation);
301
+ if (summary != null) return summary;
302
+ }
303
+ throw entry.error ?? /* @__PURE__ */ new Error(`No summary available for '${entry.key}'`);
304
+ }
305
+ /** The value once any run in flight or pending is done, `undefined` when it has none */
306
+ async waitForValue(entry, cancellation) {
283
307
  if (entry.running != null) await (cancellation != null ? raceWithSignal(entry.running, cancellation) : entry.running);
284
308
  if (entry.disposed) throw new CancellationError();
285
- if (entry.value != null) return entry.value;
286
- throw entry.error ?? /* @__PURE__ */ new Error(`No summary available for '${entry.key}'`);
309
+ return entry.value;
287
310
  }
288
311
  /** Joins the read in flight for `key`, or starts one; the read is aborted only once no caller waits for it */
289
312
  async getUnwatchedSnapshot(key, probeDirty, cancellation) {
@@ -461,7 +484,7 @@ var WorktreeSummaryService = class {
461
484
  } catch (ex) {
462
485
  if (entry.disposed) return;
463
486
  entry.running = void 0;
464
- if (!isCancellationError(ex)) this.fail(entry, ex);
487
+ this.fail(entry, ex);
465
488
  return;
466
489
  }
467
490
  if (entry.disposed) return;
@@ -685,7 +708,7 @@ var WorktreeSummaryService = class {
685
708
  const signal = entry.abort.signal;
686
709
  result = await readSummary(repo, entry.key, fields, previous, entry.baseKeys, entry.baseConfigKey, entry.baseDefaultBranch, baseMoves, signal, this.verifyBaseRemeasure, (due, moves) => this.probeRead(repo, previous, tips, due, moves, probed, signal));
687
710
  } catch (ex) {
688
- if (entry.disposed || isCancellationError(ex)) return;
711
+ if (entry.disposed) return;
689
712
  this.fail(entry, ex);
690
713
  return;
691
714
  }
@@ -898,7 +921,7 @@ async function readSummary(repo, key, fields, previous, previousBaseKeys, previo
898
921
  try {
899
922
  full = await repo.branches.getAheadOfBase?.(branch, void 0, signal);
900
923
  } catch (ex) {
901
- if (isCancellationError(ex)) throw ex;
924
+ if (isReadAborted(ex, signal)) throw ex;
902
925
  }
903
926
  verifyBaseRemeasure(aheadOfBase, full);
904
927
  }
@@ -908,7 +931,7 @@ async function readSummary(repo, key, fields, previous, previousBaseKeys, previo
908
931
  dependsOn = aheadOfBase?.dependsOn ?? emptyRefs;
909
932
  baseDefaultBranch = aheadOfBase?.defaultBranch;
910
933
  } catch (ex) {
911
- if (isCancellationError(ex)) throw ex;
934
+ if (isReadAborted(ex, signal)) throw ex;
912
935
  baseFailed = true;
913
936
  baseError = ex;
914
937
  const sameBranch = previous != null && branch === previous.branch && detached === previous.detached;
@@ -946,6 +969,13 @@ async function readSummary(repo, key, fields, previous, previousBaseKeys, previo
946
969
  fields
947
970
  };
948
971
  }
972
+ /**
973
+ * Whether `ex` is the read giving up on `signal`, rather than failing: one cut short (git ran past its time limit, or
974
+ * was killed) rejects as a cancellation too, with `signal` not aborted
975
+ */
976
+ function isReadAborted(ex, signal) {
977
+ return isCancellationError(ex) && (signal?.aborted ?? true);
978
+ }
949
979
  async function getGitDir(repo) {
950
980
  try {
951
981
  return await repo.config.getGitDir?.();
@@ -1079,7 +1109,7 @@ async function readRemoteHeads(repo, heads, remotes, signal) {
1079
1109
  try {
1080
1110
  target = await repo.branches.getDefaultBranchName(name, { local: true }, signal);
1081
1111
  } catch (ex) {
1082
- if (isCancellationError(ex)) throw ex;
1112
+ if (isReadAborted(ex, signal)) throw ex;
1083
1113
  target = null;
1084
1114
  }
1085
1115
  heads.set(name, target);
@@ -1133,7 +1163,7 @@ async function readBaseConfig(repo, signal) {
1133
1163
  if (repo.branches.getAheadOfBaseConfigEntries != null) return await repo.branches.getAheadOfBaseConfigEntries(signal);
1134
1164
  return await repo.branches.getAheadOfBaseConfigKey?.(signal);
1135
1165
  } catch (ex) {
1136
- if (isCancellationError(ex)) throw ex;
1166
+ if (isReadAborted(ex, signal)) throw ex;
1137
1167
  return;
1138
1168
  }
1139
1169
  }