Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/source-control-core/src/server/diffFileRevisions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ describe("truncateLongDiffLines", () => {
});

describe("parseDiffFileRevisions", () => {
it("locates a pure copy when a path contains the header separator", () => {
const patch = patchOf(
"diff --git a/source.txt b/folder b/copy.txt",
"similarity index 100%",
"copy from source.txt",
"copy to folder b/copy.txt",
);

assert.deepStrictEqual(parseDiffFilePaths(patch), [
{ oldPath: "source.txt", newPath: "folder b/copy.txt" },
]);
assert.strictEqual(diffFileSection(patch, "folder b/copy.txt"), patch);
});

it("reads the head id of a changed file off its index line", () => {
const revisions = parseDiffFileRevisions(
patchOf(
Expand Down
4 changes: 4 additions & 0 deletions packages/source-control-core/src/server/diffFileRevisions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ function parseEntries(patch: string): ReadonlyArray<Omit<Entry, "inBody">> {
entry.revision = headRevision(line.slice("index ".length));
} else if (line.startsWith("deleted file mode")) {
entry.deleted = true;
} else if (line.startsWith("copy from ")) {
entry.oldPath = unquoteGitPatchPath(line.slice("copy from ".length));
} else if (line.startsWith("copy to ")) {
entry.newPath = unquoteGitPatchPath(line.slice("copy to ".length));
} else if (line.startsWith("rename from ")) {
entry.oldPath = unquoteGitPatchPath(line.slice("rename from ".length));
} else if (line.startsWith("rename to ")) {
Expand Down
Loading