@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/cli.cjs
CHANGED
|
@@ -15520,9 +15520,10 @@ var ReplayApplicator = class {
|
|
|
15520
15520
|
const resolvedPath = await this.resolveFilePath(filePath, baseGen.tree_hash, currentTreeHash);
|
|
15521
15521
|
const base = await this.git.showFile(baseGen.tree_hash, filePath);
|
|
15522
15522
|
const theirs = await this.applyPatchToContent(base, patch.patch_content, filePath, tempGit, tempDir);
|
|
15523
|
-
|
|
15523
|
+
const effectiveTheirs = theirs ?? await (0, import_promises.readFile)((0, import_node_path3.join)(this.outputDir, resolvedPath), "utf-8").catch(() => null);
|
|
15524
|
+
if (effectiveTheirs) {
|
|
15524
15525
|
this.fileTheirsAccumulator.set(resolvedPath, {
|
|
15525
|
-
content:
|
|
15526
|
+
content: effectiveTheirs,
|
|
15526
15527
|
baseGeneration: patch.base_generation
|
|
15527
15528
|
});
|
|
15528
15529
|
}
|
|
@@ -15566,8 +15567,12 @@ var ReplayApplicator = class {
|
|
|
15566
15567
|
};
|
|
15567
15568
|
} catch {
|
|
15568
15569
|
for (const [resolvedPath, content] of snapshots) {
|
|
15570
|
+
const fullPath = (0, import_node_path3.join)(this.outputDir, resolvedPath);
|
|
15569
15571
|
if (content != null) {
|
|
15570
|
-
await (0, import_promises.writeFile)(
|
|
15572
|
+
await (0, import_promises.writeFile)(fullPath, content);
|
|
15573
|
+
} else {
|
|
15574
|
+
await (0, import_promises.unlink)(fullPath).catch(() => {
|
|
15575
|
+
});
|
|
15571
15576
|
}
|
|
15572
15577
|
}
|
|
15573
15578
|
}
|
|
@@ -15682,7 +15687,7 @@ var ReplayApplicator = class {
|
|
|
15682
15687
|
}
|
|
15683
15688
|
let useAccumulatorAsMergeBase = false;
|
|
15684
15689
|
const accumulatorEntry = this.fileTheirsAccumulator.get(resolvedPath);
|
|
15685
|
-
if (!theirs
|
|
15690
|
+
if (accumulatorEntry && (!theirs || base == null)) {
|
|
15686
15691
|
theirs = await this.applyPatchToContent(
|
|
15687
15692
|
accumulatorEntry.content,
|
|
15688
15693
|
patch.patch_content,
|
|
@@ -15724,12 +15729,16 @@ var ReplayApplicator = class {
|
|
|
15724
15729
|
}
|
|
15725
15730
|
}
|
|
15726
15731
|
if (base == null && !ours && effective_theirs) {
|
|
15732
|
+
this.fileTheirsAccumulator.set(resolvedPath, {
|
|
15733
|
+
content: effective_theirs,
|
|
15734
|
+
baseGeneration: patch.base_generation
|
|
15735
|
+
});
|
|
15727
15736
|
const outDir2 = (0, import_node_path3.dirname)(oursPath);
|
|
15728
15737
|
await (0, import_promises.mkdir)(outDir2, { recursive: true });
|
|
15729
15738
|
await (0, import_promises.writeFile)(oursPath, effective_theirs);
|
|
15730
15739
|
return { file: resolvedPath, status: "merged", reason: "new-file" };
|
|
15731
15740
|
}
|
|
15732
|
-
if (base == null && ours && effective_theirs) {
|
|
15741
|
+
if (base == null && ours && effective_theirs && !useAccumulatorAsMergeBase) {
|
|
15733
15742
|
const merged2 = threeWayMerge("", ours, effective_theirs);
|
|
15734
15743
|
const outDir2 = (0, import_node_path3.dirname)(oursPath);
|
|
15735
15744
|
await (0, import_promises.mkdir)(outDir2, { recursive: true });
|
|
@@ -15912,16 +15921,24 @@ var ReplayApplicator = class {
|
|
|
15912
15921
|
const addedLines = [];
|
|
15913
15922
|
let inTargetFile = false;
|
|
15914
15923
|
let inHunk = false;
|
|
15924
|
+
let isNewFile = false;
|
|
15915
15925
|
let noTrailingNewline = false;
|
|
15916
15926
|
for (const line of lines) {
|
|
15917
15927
|
if (line.startsWith("diff --git")) {
|
|
15918
15928
|
if (inTargetFile) break;
|
|
15919
15929
|
inTargetFile = isDiffLineForFile(line, filePath);
|
|
15920
15930
|
inHunk = false;
|
|
15931
|
+
isNewFile = false;
|
|
15921
15932
|
continue;
|
|
15922
15933
|
}
|
|
15923
15934
|
if (!inTargetFile) continue;
|
|
15935
|
+
if (!inHunk) {
|
|
15936
|
+
if (line === "--- /dev/null" || line.startsWith("new file mode")) {
|
|
15937
|
+
isNewFile = true;
|
|
15938
|
+
}
|
|
15939
|
+
}
|
|
15924
15940
|
if (line.startsWith("@@")) {
|
|
15941
|
+
if (!isNewFile) return null;
|
|
15925
15942
|
inHunk = true;
|
|
15926
15943
|
continue;
|
|
15927
15944
|
}
|