mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 18:20:30 +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,7 +1,6 @@
|
||||
import type { BaseUrl } from "./lib/fetcher.js";
|
||||
import type {
|
||||
Blob,
|
||||
CommitBlob,
|
||||
Project,
|
||||
Remote,
|
||||
Tree,
|
||||
@@ -10,8 +9,10 @@ import type {
|
||||
import type { Comment } from "./lib/project/comment.js";
|
||||
import type {
|
||||
Commit,
|
||||
CommitBlob,
|
||||
CommitHeader,
|
||||
Diff,
|
||||
DiffBlob,
|
||||
DiffContent,
|
||||
DiffFile,
|
||||
HunkLine,
|
||||
@@ -46,6 +47,7 @@ export type {
|
||||
CommitBlob,
|
||||
CommitHeader,
|
||||
Diff,
|
||||
DiffBlob,
|
||||
DiffContent,
|
||||
DiffFile,
|
||||
DiffResponse,
|
||||
|
||||
@@ -29,6 +29,7 @@ import {
|
||||
} from "zod";
|
||||
|
||||
import {
|
||||
diffBlobSchema,
|
||||
commitHeaderSchema,
|
||||
commitSchema,
|
||||
commitsSchema,
|
||||
@@ -86,14 +87,6 @@ const blobSchema = object({
|
||||
|
||||
export type Blob = z.infer<typeof blobSchema>;
|
||||
|
||||
const commitBlobSchema = object({
|
||||
binary: boolean(),
|
||||
content: optional(string()),
|
||||
lastCommit: commitHeaderSchema,
|
||||
});
|
||||
|
||||
export type CommitBlob = z.infer<typeof commitBlobSchema>;
|
||||
|
||||
const treeEntrySchema = object({
|
||||
path: string(),
|
||||
name: string(),
|
||||
@@ -138,7 +131,7 @@ export type DiffResponse = z.infer<typeof diffResponseSchema>;
|
||||
const diffResponseSchema = object({
|
||||
commits: array(commitHeaderSchema),
|
||||
diff: diffSchema,
|
||||
files: record(string(), commitBlobSchema),
|
||||
files: record(string(), diffBlobSchema),
|
||||
});
|
||||
|
||||
export class Client {
|
||||
|
||||
@@ -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