mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 10:10:30 +08:00
Show canonical branches and tags in peer selector
This commit is contained in:
@@ -3,9 +3,11 @@ import type {
|
||||
Blob,
|
||||
DiffResponse,
|
||||
Job,
|
||||
PeerRefs,
|
||||
Remote,
|
||||
Repo,
|
||||
RepoListQuery,
|
||||
TagInfo,
|
||||
Tree,
|
||||
TreeStats,
|
||||
} from "./lib/repo.js";
|
||||
@@ -77,6 +79,7 @@ export type {
|
||||
Merge,
|
||||
Patch,
|
||||
PatchState,
|
||||
PeerRefs,
|
||||
Reaction,
|
||||
Remote,
|
||||
Repo,
|
||||
@@ -84,6 +87,7 @@ export type {
|
||||
Review,
|
||||
Revision,
|
||||
SeedingPolicy,
|
||||
TagInfo,
|
||||
Tree,
|
||||
TreeStats,
|
||||
Verdict,
|
||||
|
||||
+30
-6
@@ -1,4 +1,3 @@
|
||||
import type { ZodSchema } from "zod";
|
||||
import type { Fetcher, RequestOptions } from "./fetcher.js";
|
||||
import type { Commit, Commits } from "./repo/commit.js";
|
||||
import type { Issue } from "./repo/issue.js";
|
||||
@@ -15,6 +14,7 @@ import {
|
||||
string,
|
||||
union,
|
||||
z,
|
||||
ZodSchema,
|
||||
} from "zod";
|
||||
|
||||
import {
|
||||
@@ -28,6 +28,25 @@ import { issueSchema, issuesSchema } from "./repo/issue.js";
|
||||
import { patchSchema, patchesSchema } from "./repo/patch.js";
|
||||
import { authorSchema } from "./shared.js";
|
||||
|
||||
export type PeerRefs = {
|
||||
id: string;
|
||||
alias?: string;
|
||||
delegate: boolean;
|
||||
refs: Record<string, string>;
|
||||
};
|
||||
|
||||
const tagInfoSchema = object({
|
||||
commit: string(),
|
||||
tagger: object({
|
||||
name: string(),
|
||||
email: string(),
|
||||
timestamp: number(),
|
||||
}).optional(),
|
||||
message: string().optional(),
|
||||
});
|
||||
|
||||
export type TagInfo = z.infer<typeof tagInfoSchema>;
|
||||
|
||||
const repoSchema = object({
|
||||
rid: string(),
|
||||
payloads: object({
|
||||
@@ -59,6 +78,10 @@ const repoSchema = object({
|
||||
object({ type: literal("private"), allow: optional(array(string())) }),
|
||||
]),
|
||||
seeding: number(),
|
||||
refs: object({
|
||||
tags: record(string(), tagInfoSchema),
|
||||
refs: record(string(), string()),
|
||||
}).optional(),
|
||||
});
|
||||
const reposSchema = array(repoSchema);
|
||||
|
||||
@@ -106,16 +129,17 @@ const treeSchema = object({
|
||||
path: string(),
|
||||
});
|
||||
|
||||
export type Remote = z.infer<typeof remoteSchema>;
|
||||
|
||||
export const remoteSchema = object({
|
||||
const remoteSchema = object({
|
||||
id: string(),
|
||||
alias: string().optional(),
|
||||
heads: record(string(), string()),
|
||||
delegate: boolean(),
|
||||
heads: record(string(), string()),
|
||||
refs: record(string(), string()).optional(),
|
||||
});
|
||||
|
||||
const remotesSchema = array(remoteSchema) satisfies ZodSchema<Remote[]>;
|
||||
export type Remote = z.infer<typeof remoteSchema>;
|
||||
|
||||
const remotesSchema = array(remoteSchema);
|
||||
|
||||
export type DiffResponse = z.infer<typeof diffResponseSchema>;
|
||||
|
||||
|
||||
@@ -52,10 +52,6 @@ describe("repo", () => {
|
||||
await api.repo.getTree(sourceBrowsingRid, aliceMainHead, "src");
|
||||
});
|
||||
|
||||
test("#getAllRemotes(rid)", async () => {
|
||||
await api.repo.getAllRemotes(sourceBrowsingRid);
|
||||
});
|
||||
|
||||
test("#getRemoteByPeer(rid, peer)", async () => {
|
||||
await api.repo.getRemoteByPeer(sourceBrowsingRid, aliceRemote.substring(8));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user