@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/index.cjs CHANGED
@@ -1423,7 +1423,7 @@ var ReplayApplicator = class {
1423
1423
  }
1424
1424
  let useAccumulatorAsMergeBase = false;
1425
1425
  const accumulatorEntry = this.fileTheirsAccumulator.get(resolvedPath);
1426
- if (!theirs && accumulatorEntry) {
1426
+ if (accumulatorEntry && (!theirs || base == null)) {
1427
1427
  theirs = await this.applyPatchToContent(
1428
1428
  accumulatorEntry.content,
1429
1429
  patch.patch_content,
@@ -1465,12 +1465,16 @@ var ReplayApplicator = class {
1465
1465
  }
1466
1466
  }
1467
1467
  if (base == null && !ours && effective_theirs) {
1468
+ this.fileTheirsAccumulator.set(resolvedPath, {
1469
+ content: effective_theirs,
1470
+ baseGeneration: patch.base_generation
1471
+ });
1468
1472
  const outDir2 = (0, import_node_path2.dirname)(oursPath);
1469
1473
  await (0, import_promises.mkdir)(outDir2, { recursive: true });
1470
1474
  await (0, import_promises.writeFile)(oursPath, effective_theirs);
1471
1475
  return { file: resolvedPath, status: "merged", reason: "new-file" };
1472
1476
  }
1473
- if (base == null && ours && effective_theirs) {
1477
+ if (base == null && ours && effective_theirs && !useAccumulatorAsMergeBase) {
1474
1478
  const merged2 = threeWayMerge("", ours, effective_theirs);
1475
1479
  const outDir2 = (0, import_node_path2.dirname)(oursPath);
1476
1480
  await (0, import_promises.mkdir)(outDir2, { recursive: true });
@@ -1653,16 +1657,24 @@ var ReplayApplicator = class {
1653
1657
  const addedLines = [];
1654
1658
  let inTargetFile = false;
1655
1659
  let inHunk = false;
1660
+ let isNewFile = false;
1656
1661
  let noTrailingNewline = false;
1657
1662
  for (const line of lines) {
1658
1663
  if (line.startsWith("diff --git")) {
1659
1664
  if (inTargetFile) break;
1660
1665
  inTargetFile = isDiffLineForFile(line, filePath);
1661
1666
  inHunk = false;
1667
+ isNewFile = false;
1662
1668
  continue;
1663
1669
  }
1664
1670
  if (!inTargetFile) continue;
1671
+ if (!inHunk) {
1672
+ if (line === "--- /dev/null" || line.startsWith("new file mode")) {
1673
+ isNewFile = true;
1674
+ }
1675
+ }
1665
1676
  if (line.startsWith("@@")) {
1677
+ if (!isNewFile) return null;
1666
1678
  inHunk = true;
1667
1679
  continue;
1668
1680
  }