@gitkraken/core-gitlens 0.15.0 → 0.15.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +25 -1
  2. package/dist/git/models/branch.d.ts +7 -0
  3. package/dist/git/models/branch.js +1 -0
  4. package/dist/git/models/branch.js.map +1 -1
  5. package/dist/git/models/graph.d.ts +2 -0
  6. package/dist/git/models/graph.js.map +1 -1
  7. package/dist/git/models/reference.d.ts +4 -0
  8. package/dist/git/providers/provider.d.ts +3 -1
  9. package/dist/git/providers/revision.d.ts +2 -1
  10. package/dist/git/run.types.d.ts +3 -2
  11. package/dist/git/utils/branch.utils.d.ts +15 -3
  12. package/dist/git/utils/branch.utils.js +34 -8
  13. package/dist/git/utils/branch.utils.js.map +1 -1
  14. package/dist/git/utils/reference.utils.d.ts +2 -0
  15. package/dist/git/utils/reference.utils.js.map +1 -1
  16. package/dist/git/watching/worktreeSummary.d.ts +7 -4
  17. package/dist/git/watching/worktreeSummary.js +22 -3
  18. package/dist/git/watching/worktreeSummary.js.map +1 -1
  19. package/dist/git-cli/cliGitProvider.d.ts +6 -0
  20. package/dist/git-cli/cliGitProvider.js +48 -2
  21. package/dist/git-cli/cliGitProvider.js.map +1 -1
  22. package/dist/git-cli/exec/git.d.ts +1 -0
  23. package/dist/git-cli/exec/git.js +8 -10
  24. package/dist/git-cli/exec/git.js.map +1 -1
  25. package/dist/git-cli/exec/indexLock.d.ts +9 -1
  26. package/dist/git-cli/exec/indexLock.js +19 -5
  27. package/dist/git-cli/exec/indexLock.js.map +1 -1
  28. package/dist/git-cli/parsers/logParser.d.ts +4 -0
  29. package/dist/git-cli/parsers/logParser.js +12 -2
  30. package/dist/git-cli/parsers/logParser.js.map +1 -1
  31. package/dist/git-cli/parsers/refParser.js +4 -2
  32. package/dist/git-cli/parsers/refParser.js.map +1 -1
  33. package/dist/git-cli/providers/branchRemote.d.ts +13 -1
  34. package/dist/git-cli/providers/branchRemote.js +41 -12
  35. package/dist/git-cli/providers/branchRemote.js.map +1 -1
  36. package/dist/git-cli/providers/branches.js +55 -21
  37. package/dist/git-cli/providers/branches.js.map +1 -1
  38. package/dist/git-cli/providers/graph.js +53 -32
  39. package/dist/git-cli/providers/graph.js.map +1 -1
  40. package/dist/git-cli/providers/operations.js +22 -4
  41. package/dist/git-cli/providers/operations.js.map +1 -1
  42. package/dist/git-cli/providers/revision.d.ts +8 -1
  43. package/dist/git-cli/providers/revision.js +22 -8
  44. package/dist/git-cli/providers/revision.js.map +1 -1
  45. package/dist/git-cli/providers/stash.js +3 -3
  46. package/dist/git-cli/providers/stash.js.map +1 -1
  47. package/dist/git-cli/providers/worktrees.js +3 -3
  48. package/dist/git-cli/providers/worktrees.js.map +1 -1
  49. package/package.json +1 -1
@@ -4,7 +4,7 @@ import { getScopedLogger } from "../../utils/logger.scoped.js";
4
4
  import { getSettledValue } from "../../utils/promise.js";
5
5
  import { debug } from "../../utils/decorators/log.js";
6
6
  import { createDisposable } from "../../utils/disposable.js";
7
- import { getBranchId, getBranchNameWithoutRemote, getRemoteNameFromBranchName } from "../../utils/gitRefs.js";
7
+ import { getBranchId, getBranchNameWithoutRemote } from "../../utils/gitRefs.js";
8
8
  import { isUncommitted } from "../../git/utils/revision.utils.js";
9
9
  import { splitRemoteBranchName } from "../../git/utils/branch.utils.js";
10
10
  import __decorate from "../../_virtual/@oxc-project+runtime/helpers/esm/decorate.js";
@@ -44,15 +44,15 @@ function isMoveableGraphRef(refname) {
44
44
  * CREATES stay fast) — keeping the high-frequency events (commits, branch/tag creates, fetches,
45
45
  * checkouts) on the fast path. Sorted so map/list iteration order can't produce spurious mismatches.
46
46
  */
47
- function computeDecorationFingerprint(repoPath, defaultBranchName, defaultLocalName, headRefUpstreamName, branches, remotes, worktrees, currentUser) {
48
- const localShadowsDefault = defaultLocalName != null && (branches?.some((b) => b.name === defaultLocalName) ?? false);
47
+ function computeDecorationFingerprint(repoPath, defaultBranchName, defaultLocalName, headRefUpstreamName, headRefUpstreamLocal, branches, remotes, worktrees, currentUser) {
48
+ const localShadowsDefault = defaultLocalName != null && (branches?.some((b) => !b.remote && b.name === defaultLocalName) ?? false);
49
49
  const parts = [
50
50
  `d:${defaultBranchName ?? ""}|${localShadowsDefault ? "s" : ""}`,
51
- `h:${headRefUpstreamName ?? ""}`,
51
+ `h:${headRefUpstreamLocal ? "l:" : ""}${headRefUpstreamName ?? ""}`,
52
52
  `u:${currentUser?.name ?? ""}|${currentUser?.email ?? ""}`
53
53
  ];
54
54
  if (branches != null) {
55
- for (const b of branches) if (b.starred) parts.push(`s:${b.name}`);
55
+ for (const b of branches) if (b.starred) parts.push(`s:${b.remote ? "r:" : ""}${b.name}`);
56
56
  }
57
57
  if (remotes != null) for (const r of remotes) parts.push(`r:${r.name}|${r.url}|${r.provider?.gkProviderId ?? ""}`);
58
58
  let defaultWorktreeBranch;
@@ -236,9 +236,20 @@ var GraphGitSubProvider = class {
236
236
  shallowBoundaryPromise
237
237
  ]);
238
238
  const branches = getSettledValue(branchesResult)?.values;
239
- const branchMap = branches != null ? new Map(branches.map((r) => [r.name, r])) : /* @__PURE__ */ new Map();
239
+ const branchMap = /* @__PURE__ */ new Map();
240
+ const localBranchMap = /* @__PURE__ */ new Map();
241
+ const remoteBranchMap = /* @__PURE__ */ new Map();
242
+ if (branches != null) for (const b of branches) if (b.remote) {
243
+ remoteBranchMap.set(b.name, b);
244
+ if (!localBranchMap.has(b.name)) branchMap.set(b.name, b);
245
+ } else {
246
+ localBranchMap.set(b.name, b);
247
+ branchMap.set(b.name, b);
248
+ }
240
249
  const headBranch = branches?.find((b) => b.current);
241
250
  const headRefUpstreamName = headBranch?.upstream?.name;
251
+ const headRefUpstreamLocal = headBranch?.upstream?.local === true;
252
+ const headRemoteUpstreamName = headRefUpstreamLocal ? void 0 : headRefUpstreamName;
242
253
  const [worktrees, worktreesByBranch] = getSettledValue(worktreesResult) ?? [[], /* @__PURE__ */ new Map()];
243
254
  const remotes = getSettledValue(remotesResult);
244
255
  const remoteMap = remotes != null ? new Map(remotes.map((r) => [r.name, r])) : /* @__PURE__ */ new Map();
@@ -255,7 +266,7 @@ var GraphGitSubProvider = class {
255
266
  }
256
267
  }
257
268
  const currentUser = getSettledValue(currentUserResult);
258
- const decorationFingerprint = computeDecorationFingerprint(repoPath, defaultBranchName, defaultLocalName, headRefUpstreamName, branches, remotes, worktrees, currentUser);
269
+ const decorationFingerprint = computeDecorationFingerprint(repoPath, defaultBranchName, defaultLocalName, headRefUpstreamName, headRefUpstreamLocal, branches, remotes, worktrees, currentUser);
259
270
  const shas = getSettledValue(shaResult)?.stdout;
260
271
  const selectSha = shas != null ? first(shaParser.parse(shas)) : void 0;
261
272
  let refTips;
@@ -282,7 +293,7 @@ var GraphGitSubProvider = class {
282
293
  if (!downstreams.includes(localName)) downstreams.push(localName);
283
294
  };
284
295
  const seedDownstreamMapFromBranches = () => {
285
- for (const branch of branchMap.values()) if (!branch.remote && branch.upstream?.name != null) addDownstream(branch.upstream.name, branch.name);
296
+ for (const branch of localBranchMap.values()) if (branch.upstream?.name != null && !branch.upstream.local) addDownstream(branch.upstream.name, branch.name);
286
297
  };
287
298
  seedDownstreamMapFromBranches();
288
299
  const gitStash = getSettledValue(stashResult);
@@ -332,7 +343,7 @@ var GraphGitSubProvider = class {
332
343
  reachableFromHEAD,
333
344
  rewriteableFromHEAD,
334
345
  tipShasWithChildren,
335
- reachableFromHeadUpstream: headRefUpstreamName != null ? reachableFromHeadUpstream : void 0,
346
+ reachableFromHeadUpstream: headRemoteUpstreamName != null ? reachableFromHeadUpstream : void 0,
336
347
  avatars
337
348
  } : void 0;
338
349
  function buildRowFromCommit(commit) {
@@ -348,9 +359,8 @@ var GraphGitSubProvider = class {
348
359
  let sawHead = false;
349
360
  if (commit.tips) for (let tip of commit.tips.split(", ")) {
350
361
  head = false;
351
- if (tip === "refs/stash") continue;
352
362
  if (tip.startsWith("tag: ")) {
353
- const tagName = tip.substring(5);
363
+ const tagName = tip.substring(15);
354
364
  refTags.push({
355
365
  id: getTagId(repoPath, tagName),
356
366
  name: tagName,
@@ -363,28 +373,36 @@ var GraphGitSubProvider = class {
363
373
  sawHead = true;
364
374
  if (tip !== "HEAD") tip = tip.substring(8);
365
375
  }
366
- const slashRemote = slashRemoteNames.length ? splitRemoteBranchName(tip, slashRemoteNames) : void 0;
367
- const remoteName = slashRemote?.[0] ?? getRemoteNameFromBranchName(tip);
368
- if (remoteName) {
369
- const remote = remoteMap.get(remoteName);
376
+ let name;
377
+ let branch;
378
+ if (tip.startsWith("refs/heads/")) {
379
+ name = tip.substring(11);
380
+ branch = localBranchMap.get(name);
381
+ } else if (tip.startsWith("refs/remotes/")) {
382
+ name = tip.substring(13);
383
+ branch = remoteBranchMap.get(name);
384
+ const slashRemote = slashRemoteNames.length ? splitRemoteBranchName(name, slashRemoteNames) : void 0;
385
+ const slash = name.indexOf("/");
386
+ const remoteName = slashRemote?.[0] ?? (slash > 0 ? name.substring(0, slash) : void 0);
387
+ const remote = remoteName ? remoteMap.get(remoteName) : void 0;
370
388
  if (remote != null) {
371
- const branchName = slashRemote?.[1] ?? getBranchNameWithoutRemote(tip);
389
+ const branchName = slashRemote?.[1] ?? name.substring(slash + 1);
372
390
  if (branchName === "HEAD") continue;
373
391
  refRemoteHeads.push({
374
- id: getBranchId(repoPath, true, tip),
392
+ id: getBranchId(repoPath, true, name),
375
393
  name: branchName,
376
394
  owner: remote.name,
377
395
  url: remote.url,
378
- current: tip === headRefUpstreamName,
379
- isDefault: tip === defaultBranchName && !branchMap.has(defaultLocalName),
396
+ current: name === headRemoteUpstreamName,
397
+ isDefault: name === defaultBranchName && !localBranchMap.has(defaultLocalName),
380
398
  hostingServiceType: remote.provider?.gkProviderId,
381
- starred: branchMap.get(tip)?.starred || void 0
399
+ starred: branch?.starred || void 0
382
400
  });
383
401
  continue;
384
402
  }
385
- }
386
- const branch = branchMap.get(tip);
387
- const branchId = branch?.id ?? getBranchId(repoPath, false, tip);
403
+ } else if (tip === "HEAD") name = tip;
404
+ else continue;
405
+ const branchId = branch?.id ?? getBranchId(repoPath, false, name);
388
406
  const worktree = worktreesByBranch?.get(branchId) ?? (branchId === branchIdOfMainWorktree ? mainWorktree : void 0);
389
407
  const worktreeRef = worktree != null ? {
390
408
  id: getWorktreeId(repoPath, worktree.name),
@@ -393,11 +411,11 @@ var GraphGitSubProvider = class {
393
411
  } : void 0;
394
412
  refHeads.push({
395
413
  id: branchId,
396
- name: tip,
414
+ name,
397
415
  isCurrentHead: head,
398
416
  upstream: branch?.upstream != null ? {
399
417
  name: branch.upstream.name,
400
- id: getBranchId(repoPath, true, branch.upstream.name),
418
+ id: getBranchId(repoPath, !branch.upstream.local, branch.upstream.name),
401
419
  missing: branch.upstream.missing,
402
420
  state: {
403
421
  ahead: branch.upstream.state.ahead,
@@ -405,7 +423,7 @@ var GraphGitSubProvider = class {
405
423
  }
406
424
  } : void 0,
407
425
  worktree: worktreeRef,
408
- isDefault: defaultLocalName != null && tip === defaultLocalName,
426
+ isDefault: defaultLocalName != null && name === defaultLocalName,
409
427
  starred: branch?.starred || void 0
410
428
  });
411
429
  }
@@ -512,7 +530,7 @@ var GraphGitSubProvider = class {
512
530
  if (!isStash) {
513
531
  for (const parent of parents) if (undoableTipShas.has(parent)) tipShasWithChildren.add(parent);
514
532
  }
515
- for (const h of refHeads) if (h.upstream?.name != null) addDownstream(h.upstream.name, h.name);
533
+ for (const h of refHeads) if (h.upstream?.name != null && localBranchMap.get(h.name)?.upstream?.local !== true) addDownstream(h.upstream.name, h.name);
516
534
  return reachableRefs.get(sha);
517
535
  }
518
536
  const buildRowsStatsDeferred = (rows) => {
@@ -745,7 +763,7 @@ var GraphGitSubProvider = class {
745
763
  fallback("stash-changed");
746
764
  return;
747
765
  }
748
- const seedComparableFingerprint = rebindFromRepoPath != null ? computeDecorationFingerprint(rebindFromRepoPath, defaultBranchName, defaultLocalName, seed.headRefUpstreamName, branches, remotes, worktrees, currentUser) : decorationFingerprint;
766
+ const seedComparableFingerprint = rebindFromRepoPath != null ? computeDecorationFingerprint(rebindFromRepoPath, defaultBranchName, defaultLocalName, seed.headRefUpstreamName, seed.headRefUpstreamLocal === true, branches, remotes, worktrees, currentUser) : decorationFingerprint;
749
767
  if (seed.decorationFingerprint !== seedComparableFingerprint) {
750
768
  fallback("metadata-changed");
751
769
  return;
@@ -762,9 +780,10 @@ var GraphGitSubProvider = class {
762
780
  for (const r of seed.rows) {
763
781
  if (r.heads == null) continue;
764
782
  for (const h of r.heads) {
765
- const currentBranch = branchMap.get(h.name);
783
+ const currentBranch = localBranchMap.get(h.name);
766
784
  if (currentBranch == null) continue;
767
- if (h.upstream?.name !== currentBranch.upstream?.name) {
785
+ const currentUpstream = currentBranch.upstream;
786
+ if (h.upstream?.id !== (currentUpstream != null ? getBranchId(rebindFromRepoPath ?? repoPath, !currentUpstream.local, currentUpstream.name) : void 0)) {
768
787
  fallback("metadata-changed");
769
788
  return;
770
789
  }
@@ -831,7 +850,7 @@ var GraphGitSubProvider = class {
831
850
  total++;
832
851
  const fresh = freshShas.has(row.sha);
833
852
  if (!fresh) options?.onMutationStart?.();
834
- if (rebindFromRepoPath != null && !fresh && row.remotes != null) for (const remoteHead of row.remotes) remoteHead.current = `${remoteHead.owner}/${remoteHead.name}` === headRefUpstreamName;
853
+ if (rebindFromRepoPath != null && !fresh && row.remotes != null) for (const remoteHead of row.remotes) remoteHead.current = `${remoteHead.owner}/${remoteHead.name}` === headRemoteUpstreamName;
835
854
  const refs = accumulateRowState(row.sha, row.parents, row.heads ?? [], row.remotes ?? [], row.tags ?? [], row.sha === currentHeadSha, row.kind === "stash");
836
855
  if (fresh) {
837
856
  row.reachability = refs?.size ? {
@@ -1303,6 +1322,7 @@ var GraphSession = class {
1303
1322
  const shape = this.getWalkShape();
1304
1323
  const buildShape = buildShapeKey(shape);
1305
1324
  const prior = this._current;
1325
+ const priorHead = find(prior.branches.values(), (b) => b.current);
1306
1326
  const incrementalSeed = options?.rebuild !== true && prior.refTips != null && this._buildShape === buildShape ? {
1307
1327
  rows: this._window,
1308
1328
  tips: prior.refTips,
@@ -1313,7 +1333,8 @@ var GraphSession = class {
1313
1333
  onlyFollowFirstParent: shape.onlyFollowFirstParent,
1314
1334
  shallowBoundary: prior.shallowBoundary,
1315
1335
  decorationFingerprint: prior.decorationFingerprint,
1316
- headRefUpstreamName: find(prior.branches.values(), (b) => b.current)?.upstream?.name
1336
+ headRefUpstreamName: priorHead?.upstream?.name,
1337
+ headRefUpstreamLocal: priorHead?.upstream?.local === true
1317
1338
  } : void 0;
1318
1339
  let outcome;
1319
1340
  const graph = await this.provider.getGraph(this.repoPath, options?.rev, {