@fern-api/replay 0.10.0 → 0.10.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.
package/dist/cli.cjs CHANGED
@@ -15682,7 +15682,7 @@ var ReplayApplicator = class {
15682
15682
  }
15683
15683
  let useAccumulatorAsMergeBase = false;
15684
15684
  const accumulatorEntry = this.fileTheirsAccumulator.get(resolvedPath);
15685
- if (!theirs && accumulatorEntry) {
15685
+ if (accumulatorEntry && (!theirs || base == null)) {
15686
15686
  theirs = await this.applyPatchToContent(
15687
15687
  accumulatorEntry.content,
15688
15688
  patch.patch_content,
@@ -15724,12 +15724,16 @@ var ReplayApplicator = class {
15724
15724
  }
15725
15725
  }
15726
15726
  if (base == null && !ours && effective_theirs) {
15727
+ this.fileTheirsAccumulator.set(resolvedPath, {
15728
+ content: effective_theirs,
15729
+ baseGeneration: patch.base_generation
15730
+ });
15727
15731
  const outDir2 = (0, import_node_path3.dirname)(oursPath);
15728
15732
  await (0, import_promises.mkdir)(outDir2, { recursive: true });
15729
15733
  await (0, import_promises.writeFile)(oursPath, effective_theirs);
15730
15734
  return { file: resolvedPath, status: "merged", reason: "new-file" };
15731
15735
  }
15732
- if (base == null && ours && effective_theirs) {
15736
+ if (base == null && ours && effective_theirs && !useAccumulatorAsMergeBase) {
15733
15737
  const merged2 = threeWayMerge("", ours, effective_theirs);
15734
15738
  const outDir2 = (0, import_node_path3.dirname)(oursPath);
15735
15739
  await (0, import_promises.mkdir)(outDir2, { recursive: true });
@@ -15912,16 +15916,24 @@ var ReplayApplicator = class {
15912
15916
  const addedLines = [];
15913
15917
  let inTargetFile = false;
15914
15918
  let inHunk = false;
15919
+ let isNewFile = false;
15915
15920
  let noTrailingNewline = false;
15916
15921
  for (const line of lines) {
15917
15922
  if (line.startsWith("diff --git")) {
15918
15923
  if (inTargetFile) break;
15919
15924
  inTargetFile = isDiffLineForFile(line, filePath);
15920
15925
  inHunk = false;
15926
+ isNewFile = false;
15921
15927
  continue;
15922
15928
  }
15923
15929
  if (!inTargetFile) continue;
15930
+ if (!inHunk) {
15931
+ if (line === "--- /dev/null" || line.startsWith("new file mode")) {
15932
+ isNewFile = true;
15933
+ }
15934
+ }
15924
15935
  if (line.startsWith("@@")) {
15936
+ if (!isNewFile) return null;
15925
15937
  inHunk = true;
15926
15938
  continue;
15927
15939
  }