mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-15 11:20:36 +08:00
Improves changeset schemas and fix moved diff syntax highlighting
This commit is contained in:
@@ -16,7 +16,6 @@ import {
|
||||
literal,
|
||||
number,
|
||||
object,
|
||||
optional,
|
||||
record,
|
||||
string,
|
||||
union,
|
||||
@@ -151,19 +150,31 @@ const diffCopiedChangesetSchema = object({
|
||||
|
||||
const diffMovedChangesetSchema = diffCopiedChangesetSchema.merge(
|
||||
object({
|
||||
old: optional(diffFileSchema),
|
||||
new: optional(diffFileSchema),
|
||||
diff: optional(diffContentSchema),
|
||||
current: diffFileSchema,
|
||||
}),
|
||||
);
|
||||
|
||||
const diffMovedWithModificationsChangesetSchema =
|
||||
diffCopiedChangesetSchema.merge(
|
||||
object({
|
||||
old: diffFileSchema,
|
||||
new: diffFileSchema,
|
||||
diff: diffContentSchema,
|
||||
}),
|
||||
);
|
||||
|
||||
type Diff = z.infer<typeof diffSchema>;
|
||||
|
||||
const diffSchema = object({
|
||||
added: array(diffAddedChangesetSchema),
|
||||
deleted: array(diffDeletedChangesetSchema),
|
||||
modified: array(diffModifiedChangesetSchema),
|
||||
moved: array(diffMovedChangesetSchema),
|
||||
moved: array(
|
||||
union([
|
||||
diffMovedChangesetSchema,
|
||||
diffMovedWithModificationsChangesetSchema,
|
||||
]),
|
||||
),
|
||||
copied: array(diffCopiedChangesetSchema),
|
||||
stats: object({
|
||||
filesChanged: number(),
|
||||
|
||||
@@ -154,18 +154,19 @@
|
||||
</div>
|
||||
{/each}
|
||||
{#each diff.moved as file}
|
||||
{#if file.diff}
|
||||
{#if "diff" in file}
|
||||
<div use:intersection={observer} id={"observer:" + file.newPath}>
|
||||
<FileDiff
|
||||
{projectId}
|
||||
{baseUrl}
|
||||
{revision}
|
||||
{expanded}
|
||||
content=""
|
||||
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}
|
||||
fileDiff={{ ...file.diff, type: getFileType(file.diff, file.new) }}
|
||||
headerBadgeCaption="moved" />
|
||||
</div>
|
||||
{:else}
|
||||
|
||||
Reference in New Issue
Block a user