mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-15 19:30:38 +08:00
Add copied diff with modifications
This commit is contained in:
@@ -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(),
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user