mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 22:30:41 +08:00
Add syntax highlighting to patch and commit changesets
- This commit doesn't change the way syntax highlighting is done. - But due to changes in `radicle-httpd` we can highlight the entire files of a changeset, and then replace the plain text lines with highlighted ones. - Also highlights only the files currently visible of a changeset. Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
@@ -1,17 +1,34 @@
|
||||
import type { z } from "zod";
|
||||
export type {
|
||||
Commit,
|
||||
CommitHeader,
|
||||
Commits,
|
||||
Diff,
|
||||
DiffContent,
|
||||
DiffFile,
|
||||
HunkLine,
|
||||
Hunks,
|
||||
Commit,
|
||||
Diff,
|
||||
CommitHeader,
|
||||
DiffFile,
|
||||
DiffContent,
|
||||
};
|
||||
|
||||
import { array, literal, number, object, optional, string, union } from "zod";
|
||||
export { commitHeaderSchema, diffSchema, commitSchema, commitsSchema };
|
||||
import {
|
||||
array,
|
||||
boolean,
|
||||
literal,
|
||||
number,
|
||||
object,
|
||||
optional,
|
||||
record,
|
||||
string,
|
||||
union,
|
||||
} from "zod";
|
||||
export {
|
||||
commitBlobSchema,
|
||||
commitHeaderSchema,
|
||||
commitSchema,
|
||||
commitsSchema,
|
||||
diffBlobSchema,
|
||||
diffSchema,
|
||||
};
|
||||
|
||||
const gitPersonSchema = object({
|
||||
name: string(),
|
||||
@@ -29,6 +46,22 @@ const commitHeaderSchema = object({
|
||||
committer: gitPersonSchema.merge(object({ time: number() })),
|
||||
});
|
||||
|
||||
const diffBlobSchema = object({
|
||||
binary: boolean(),
|
||||
content: string(),
|
||||
id: string(),
|
||||
lastCommit: commitHeaderSchema,
|
||||
});
|
||||
|
||||
export type DiffBlob = z.infer<typeof diffBlobSchema>;
|
||||
|
||||
const commitBlobSchema = object({
|
||||
binary: boolean(),
|
||||
content: string(),
|
||||
});
|
||||
|
||||
export type CommitBlob = z.infer<typeof commitBlobSchema>;
|
||||
|
||||
type AdditionHunkLine = z.infer<typeof additionHunkLineSchema>;
|
||||
|
||||
const additionHunkLineSchema = object({
|
||||
@@ -146,12 +179,13 @@ const commitSchema = object({
|
||||
commit: commitHeaderSchema,
|
||||
diff: diffSchema,
|
||||
branches: array(string()),
|
||||
files: record(string(), commitBlobSchema),
|
||||
});
|
||||
|
||||
type Commits = z.infer<typeof commitsSchema>;
|
||||
|
||||
const commitsSchema = object({
|
||||
commits: array(commitSchema),
|
||||
commits: array(commitSchema.omit({ files: true })),
|
||||
stats: object({
|
||||
commits: number(),
|
||||
branches: number(),
|
||||
|
||||
Reference in New Issue
Block a user