From 824c719313fe9e87cc0101dfbc6bf70eb82077db Mon Sep 17 00:00:00 2001 From: xphoniex Date: Thu, 25 May 2023 11:04:31 +0000 Subject: [PATCH] Use the new `Merge` scheme for `Patch` `merges` field has moved one level up, from `revisions` to `patch` itself Signed-off-by: xphoniex --- httpd-client/lib/project/patch.ts | 30 ++++++++++++++++++++++-------- src/views/projects/Patch.svelte | 12 +++++++----- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/httpd-client/lib/project/patch.ts b/httpd-client/lib/project/patch.ts index 2d1553004..4b59736b3 100644 --- a/httpd-client/lib/project/patch.ts +++ b/httpd-client/lib/project/patch.ts @@ -10,30 +10,44 @@ import { optional, strictObject, string, + tuple, union, } from "zod"; export type PatchState = | { status: "draft" } - | { status: "open" } + | { status: "open"; conflicts?: [string, string][] } | { status: "archived" } - | { status: "merged" }; + | { status: "merged"; revision: string; commit: string }; const patchStateSchema = union([ - strictObject({ status: literal("draft") }), - strictObject({ status: literal("open") }), - strictObject({ status: literal("archived") }), - strictObject({ status: literal("merged") }), + strictObject({ + status: literal("draft"), + }), + strictObject({ + status: literal("open"), + conflicts: array(tuple([string(), string()])).optional(), + }), + strictObject({ + status: literal("archived"), + }), + strictObject({ + status: literal("merged"), + revision: string(), + commit: string(), + }), ]) satisfies ZodSchema; export interface Merge { author: { id: string; alias?: string }; + revision: string; commit: string; timestamp: number; } const mergeSchema = strictObject({ author: strictObject({ id: string(), alias: string().optional() }), + revision: string(), commit: string(), timestamp: number(), }) satisfies ZodSchema; @@ -94,7 +108,6 @@ export interface Revision { refs: string[]; discussions: Comment[]; reviews: Review[]; - merges: Merge[]; timestamp: number; } @@ -106,7 +119,6 @@ const revisionSchema = strictObject({ refs: array(string()), discussions: array(commentSchema), reviews: array(reviewSchema), - merges: array(mergeSchema), timestamp: number(), }) satisfies ZodSchema; @@ -118,6 +130,7 @@ export interface Patch { state: PatchState; target: string; tags: string[]; + merges: Merge[]; revisions: Revision[]; } @@ -129,6 +142,7 @@ export const patchSchema = strictObject({ state: patchStateSchema, target: string(), tags: array(string()), + merges: array(mergeSchema), revisions: array(revisionSchema), }) satisfies ZodSchema; diff --git a/src/views/projects/Patch.svelte b/src/views/projects/Patch.svelte index f2cd8d1d7..bc972469f 100644 --- a/src/views/projects/Patch.svelte +++ b/src/views/projects/Patch.svelte @@ -158,11 +158,13 @@ type: "review", inner: [rev.id, review.author.id, review], })), - ...rev.merges.map(inner => ({ - timestamp: inner.timestamp, - type: "merge", - inner, - })), + ...patch.merges + .filter(merge => merge.revision === rev.id) + .map(inner => ({ + timestamp: inner.timestamp, + type: "merge", + inner, + })), ...rev.discussions .filter(comment => !comment.replyTo) .map(thread => ({