@fern-api/replay 0.10.0 → 0.10.2
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 +22 -5
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +22 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1261,9 +1261,10 @@ var ReplayApplicator = class {
|
|
|
1261
1261
|
const resolvedPath = await this.resolveFilePath(filePath, baseGen.tree_hash, currentTreeHash);
|
|
1262
1262
|
const base = await this.git.showFile(baseGen.tree_hash, filePath);
|
|
1263
1263
|
const theirs = await this.applyPatchToContent(base, patch.patch_content, filePath, tempGit, tempDir);
|
|
1264
|
-
|
|
1264
|
+
const effectiveTheirs = theirs ?? await (0, import_promises.readFile)((0, import_node_path2.join)(this.outputDir, resolvedPath), "utf-8").catch(() => null);
|
|
1265
|
+
if (effectiveTheirs) {
|
|
1265
1266
|
this.fileTheirsAccumulator.set(resolvedPath, {
|
|
1266
|
-
content:
|
|
1267
|
+
content: effectiveTheirs,
|
|
1267
1268
|
baseGeneration: patch.base_generation
|
|
1268
1269
|
});
|
|
1269
1270
|
}
|
|
@@ -1307,8 +1308,12 @@ var ReplayApplicator = class {
|
|
|
1307
1308
|
};
|
|
1308
1309
|
} catch {
|
|
1309
1310
|
for (const [resolvedPath, content] of snapshots) {
|
|
1311
|
+
const fullPath = (0, import_node_path2.join)(this.outputDir, resolvedPath);
|
|
1310
1312
|
if (content != null) {
|
|
1311
|
-
await (0, import_promises.writeFile)(
|
|
1313
|
+
await (0, import_promises.writeFile)(fullPath, content);
|
|
1314
|
+
} else {
|
|
1315
|
+
await (0, import_promises.unlink)(fullPath).catch(() => {
|
|
1316
|
+
});
|
|
1312
1317
|
}
|
|
1313
1318
|
}
|
|
1314
1319
|
}
|
|
@@ -1423,7 +1428,7 @@ var ReplayApplicator = class {
|
|
|
1423
1428
|
}
|
|
1424
1429
|
let useAccumulatorAsMergeBase = false;
|
|
1425
1430
|
const accumulatorEntry = this.fileTheirsAccumulator.get(resolvedPath);
|
|
1426
|
-
if (!theirs
|
|
1431
|
+
if (accumulatorEntry && (!theirs || base == null)) {
|
|
1427
1432
|
theirs = await this.applyPatchToContent(
|
|
1428
1433
|
accumulatorEntry.content,
|
|
1429
1434
|
patch.patch_content,
|
|
@@ -1465,12 +1470,16 @@ var ReplayApplicator = class {
|
|
|
1465
1470
|
}
|
|
1466
1471
|
}
|
|
1467
1472
|
if (base == null && !ours && effective_theirs) {
|
|
1473
|
+
this.fileTheirsAccumulator.set(resolvedPath, {
|
|
1474
|
+
content: effective_theirs,
|
|
1475
|
+
baseGeneration: patch.base_generation
|
|
1476
|
+
});
|
|
1468
1477
|
const outDir2 = (0, import_node_path2.dirname)(oursPath);
|
|
1469
1478
|
await (0, import_promises.mkdir)(outDir2, { recursive: true });
|
|
1470
1479
|
await (0, import_promises.writeFile)(oursPath, effective_theirs);
|
|
1471
1480
|
return { file: resolvedPath, status: "merged", reason: "new-file" };
|
|
1472
1481
|
}
|
|
1473
|
-
if (base == null && ours && effective_theirs) {
|
|
1482
|
+
if (base == null && ours && effective_theirs && !useAccumulatorAsMergeBase) {
|
|
1474
1483
|
const merged2 = threeWayMerge("", ours, effective_theirs);
|
|
1475
1484
|
const outDir2 = (0, import_node_path2.dirname)(oursPath);
|
|
1476
1485
|
await (0, import_promises.mkdir)(outDir2, { recursive: true });
|
|
@@ -1653,16 +1662,24 @@ var ReplayApplicator = class {
|
|
|
1653
1662
|
const addedLines = [];
|
|
1654
1663
|
let inTargetFile = false;
|
|
1655
1664
|
let inHunk = false;
|
|
1665
|
+
let isNewFile = false;
|
|
1656
1666
|
let noTrailingNewline = false;
|
|
1657
1667
|
for (const line of lines) {
|
|
1658
1668
|
if (line.startsWith("diff --git")) {
|
|
1659
1669
|
if (inTargetFile) break;
|
|
1660
1670
|
inTargetFile = isDiffLineForFile(line, filePath);
|
|
1661
1671
|
inHunk = false;
|
|
1672
|
+
isNewFile = false;
|
|
1662
1673
|
continue;
|
|
1663
1674
|
}
|
|
1664
1675
|
if (!inTargetFile) continue;
|
|
1676
|
+
if (!inHunk) {
|
|
1677
|
+
if (line === "--- /dev/null" || line.startsWith("new file mode")) {
|
|
1678
|
+
isNewFile = true;
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1665
1681
|
if (line.startsWith("@@")) {
|
|
1682
|
+
if (!isNewFile) return null;
|
|
1666
1683
|
inHunk = true;
|
|
1667
1684
|
continue;
|
|
1668
1685
|
}
|