Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Add copied diff with modifications
Sebastian Martinez committed 2 years ago
commit 5abd1bf63501a3656e1b96aaf59a4ac08c4faa32
parent 0a90ed0345a023b0f83b38a839bb1af2364e8bf3
2 files changed +47 -14
modified httpd-client/lib/project/commit.ts
@@ -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(),
modified src/views/projects/Changeset.svelte
@@ -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>