Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Improves changeset schemas and fix moved diff syntax highlighting
Sebastian Martinez committed 2 years ago
commit 1167dcfab673af6e961328f7b79b50b098cb1fd2
parent aa7a1b70401e53caeface48d09aa90546a52bb6a
2 files changed +20 -8
modified httpd-client/lib/project/commit.ts
@@ -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(),
modified src/views/projects/Changeset.svelte
@@ -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}