lody 0.103.0 → 0.104.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.
@@ -1,4 +1,4 @@
1
- import { o as object, s as string, l as literal, b as boolean, a as _enum, e as union, n as number, d as discriminatedUnion, c as array, r as record, P as tuple, u as unknown } from "./schemas-WuyisFi9.js";
1
+ import { o as object, s as string, l as literal, c as boolean, a as _enum, e as union, n as number, d as discriminatedUnion, b as array, r as record, P as tuple, u as unknown } from "./schemas-D_XLKCXC.js";
2
2
  import { execFile } from "node:child_process";
3
3
  import { readFile } from "node:fs/promises";
4
4
  import path__default from "node:path";
@@ -847,6 +847,17 @@ function bytesToHex(bytes) {
847
847
  function assertNever(value) {
848
848
  throw new Error(`Unhandled Code Collab value: ${String(value)}`);
849
849
  }
850
+ function gitDiffBaseRefCandidates(preferredBaseBranch) {
851
+ const preferred = preferredBaseBranch?.trim();
852
+ const refs = [];
853
+ if (preferred?.startsWith("refs/remotes/")) {
854
+ refs.push(preferred);
855
+ } else if (preferred) {
856
+ const branch = preferred.startsWith("refs/heads/") ? preferred.slice("refs/heads/".length) : preferred;
857
+ refs.push(`origin/${branch}`, preferred);
858
+ }
859
+ return [.../* @__PURE__ */ new Set([...refs, "origin/main", "main", "origin/master", "master", "origin/HEAD"])];
860
+ }
850
861
  const execFileAsync = promisify(execFile);
851
862
  const GIT_MAX_BUFFER_BYTES = 64 * 1024 * 1024;
852
863
  async function isInsideGitWorktree(workspaceRoot) {
@@ -899,7 +910,7 @@ async function runGitLsFiles(cwd) {
899
910
  }
900
911
  }
901
912
  async function computeAllChanges(workspaceRoot, options = {}) {
902
- const diffBase = await resolveAllChangesDiffBase(workspaceRoot, options.preferredBaseBranch);
913
+ const diffBase = options.diffBase ?? await resolveAllChangesDiffBase(workspaceRoot, options.preferredBaseBranch);
903
914
  const diffTarget = diffBase ?? "HEAD";
904
915
  const [numstat, nameStatus, untracked] = await Promise.all([
905
916
  // `--numstat` cannot use `-z`, so disable `core.quotePath` to keep non-ASCII paths
@@ -976,17 +987,10 @@ async function resolveAllChangesDiffBase(workspaceRoot, preferredBaseBranch) {
976
987
  }
977
988
  }
978
989
  const head = await runGit(workspaceRoot, ["rev-parse", "--verify", "HEAD^{commit}"]);
979
- return head.ok && head.stdout.trim() ? "HEAD" : null;
990
+ return head.ok && head.stdout.trim() ? head.stdout.trim() : null;
980
991
  }
981
992
  async function resolveAllChangesBaseRef(workspaceRoot, preferredBaseBranch) {
982
- const candidates = [
983
- ...preferredBaseBranch ? [`origin/${preferredBaseBranch}`, preferredBaseBranch] : [],
984
- "origin/main",
985
- "main",
986
- "origin/master",
987
- "master",
988
- "origin/HEAD"
989
- ];
993
+ const candidates = gitDiffBaseRefCandidates(preferredBaseBranch);
990
994
  for (const candidate of candidates) {
991
995
  const exists = await runGit(workspaceRoot, ["rev-parse", "--verify", `${candidate}^{commit}`]);
992
996
  if (exists.ok) {
@@ -1141,16 +1145,18 @@ async function closeDirectoryQuietly(directory) {
1141
1145
  }
1142
1146
  }
1143
1147
  export {
1144
- CODE_COLLAB_V2_TEXT_LIMITS as A,
1145
- CODE_COLLAB_V2_ALL_CHANGES_DIFF_LIMITS as B,
1148
+ buildCodeCollabFileIndexState as A,
1149
+ CODE_COLLAB_V2_TEXT_LIMITS as B,
1146
1150
  CodeCollabV2FileIndexRequestSchema as C,
1147
- computeAllChanges as D,
1148
- codeCollabFileIndexStatesEqual as E,
1149
- scanGitDirectoryEntries as F,
1150
- closeDirectoryQuietly as G,
1151
- joinWorkspacePath as H,
1152
- isInsideGitWorktree as I,
1153
- pathSegmentComparisonKey as J,
1151
+ CODE_COLLAB_V2_ALL_CHANGES_DIFF_LIMITS as D,
1152
+ resolveAllChangesDiffBase as E,
1153
+ computeAllChanges as F,
1154
+ codeCollabFileIndexStatesEqual as G,
1155
+ scanGitDirectoryEntries as H,
1156
+ closeDirectoryQuietly as I,
1157
+ joinWorkspacePath as J,
1158
+ isInsideGitWorktree as K,
1159
+ pathSegmentComparisonKey as L,
1154
1160
  CodeCollabV2OpenTextRequestSchema as a,
1155
1161
  CodeCollabV2RefreshTextRequestSchema as b,
1156
1162
  CodeCollabV2SaveTextRequestSchema as c,
@@ -1176,6 +1182,6 @@ export {
1176
1182
  readCodeCollabFileIndexSignalFromFlock as w,
1177
1183
  writeCodeCollabFileIndexSignalToFlock as x,
1178
1184
  writeCodeCollabFileIndexToFlock as y,
1179
- buildCodeCollabFileIndexState as z
1185
+ gitDiffBaseRefCandidates as z
1180
1186
  };
1181
- //# sourceMappingURL=directory-handle-CtdCjbNh.js.map
1187
+ //# sourceMappingURL=directory-handle-DgcESjFj.js.map