Add copied diff with modifications

This commit is contained in:
Sebastian Martinez
2023-12-04 20:45:11 +01:00
parent 0a90ed0345
commit 5abd1bf635
2 changed files with 47 additions and 14 deletions
+23 -8
View File
@@ -148,13 +148,7 @@ const diffCopiedChangesetSchema = object({
oldPath: string(),
});
const diffMovedChangesetSchema = diffCopiedChangesetSchema.merge(
object({
current: diffFileSchema,
}),
);
const diffMovedWithModificationsChangesetSchema =
const diffCopiedWithModificationsChangesetSchema =
diffCopiedChangesetSchema.merge(
object({
old: diffFileSchema,
@@ -163,6 +157,22 @@ const diffMovedWithModificationsChangesetSchema =
}),
);
const diffMovedChangesetSchema = object({
newPath: string(),
oldPath: string(),
current: diffFileSchema,
});
const diffMovedWithModificationsChangesetSchema = diffMovedChangesetSchema
.omit({ current: true })
.merge(
object({
old: diffFileSchema,
new: diffFileSchema,
diff: diffContentSchema,
}),
);
type Diff = z.infer<typeof diffSchema>;
const diffSchema = object({
@@ -175,7 +185,12 @@ const diffSchema = object({
diffMovedWithModificationsChangesetSchema,
]),
),
copied: array(diffCopiedChangesetSchema),
copied: array(
union([
diffCopiedWithModificationsChangesetSchema,
diffCopiedChangesetSchema,
]),
),
stats: object({
filesChanged: number(),
insertions: number(),
+24 -6
View File
@@ -180,12 +180,30 @@
{/if}
{/each}
{#each diff.copied as file}
<FileLocationChange
{projectId}
{baseUrl}
newPath={file.newPath}
oldPath={file.oldPath}
mode="copied" />
{#if "diff" in file}
<div use:intersection={observer} id={"observer:" + file.newPath}>
<FileDiff
{projectId}
{baseUrl}
{revision}
{expanded}
content={files[file.new.oid]?.content}
oldContent={files[file.old.oid]?.content}
visible={filesVisibility.has(file.newPath)}
filePath={file.newPath}
oldFilePath={file.oldPath}
fileDiff={{ ...file.diff, type: getFileType(file.diff, file.new) }}
headerBadgeCaption="copied" />
</div>
{:else}
<FileLocationChange
{projectId}
{baseUrl}
{revision}
newPath={file.newPath}
oldPath={file.oldPath}
mode="copied" />
{/if}
{/each}
</Observer>
</div>