diff --git a/http-client/index.ts b/http-client/index.ts index 272fb752a..3fb09696e 100644 --- a/http-client/index.ts +++ b/http-client/index.ts @@ -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, diff --git a/http-client/lib/repo.ts b/http-client/lib/repo.ts index ffe989f6e..6b720235b 100644 --- a/http-client/lib/repo.ts +++ b/http-client/lib/repo.ts @@ -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; +}; + +const tagInfoSchema = object({ + commit: string(), + tagger: object({ + name: string(), + email: string(), + timestamp: number(), + }).optional(), + message: string().optional(), +}); + +export type TagInfo = z.infer; + 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; - -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; +export type Remote = z.infer; + +const remotesSchema = array(remoteSchema); export type DiffResponse = z.infer; diff --git a/http-client/tests/repo.test.ts b/http-client/tests/repo.test.ts index 0e01feb9c..e676a34b9 100644 --- a/http-client/tests/repo.test.ts +++ b/http-client/tests/repo.test.ts @@ -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)); }); diff --git a/public/typography.css b/public/typography.css index 510e66b43..49d52d715 100644 --- a/public/typography.css +++ b/public/typography.css @@ -73,11 +73,13 @@ } [data-codefont="system"] { + --txt-code-small: 400 0.75rem/1rem monospace; --txt-code-regular: 400 0.875rem/1.25rem monospace; --txt-code-semibold: 600 0.875rem/1.25rem monospace; } [data-codefont="jetbrains"] { + --txt-code-small: 400 0.75rem/1rem "JetBrains Mono"; --txt-code-regular: 400 0.875rem/1.25rem "JetBrains Mono"; --txt-code-semibold: 600 0.875rem/1.25rem "JetBrains Mono"; } @@ -158,6 +160,10 @@ html { font: var(--txt-body-l-semibold); } +.txt-code-small { + font: var(--txt-code-small); +} + .txt-code-regular { font: var(--txt-code-regular); } diff --git a/src/components/TextInput.svelte b/src/components/TextInput.svelte index 7fb7eb096..77d226cf9 100644 --- a/src/components/TextInput.svelte +++ b/src/components/TextInput.svelte @@ -11,6 +11,8 @@ export let placeholder: string | undefined = undefined; export let value: string | undefined = undefined; + export let size: "small" | "regular" = "regular"; + export let autofocus: boolean = false; export let autoselect: boolean = false; export let disabled: boolean = false; @@ -76,9 +78,14 @@ position: relative; flex: 1; align-items: center; - height: var(--button-regular-height); background: var(--color-surface-base); } + .wrapper.small { + height: var(--button-small-height); + } + .wrapper.regular { + height: var(--button-regular-height); + } input { background: var(--color-surface-base); font-family: inherit; @@ -139,7 +146,7 @@ } -
+
, +): Record { + const branches: Record = {}; + for (const [name, oid] of Object.entries(refs)) { + if (name.startsWith("refs/heads/")) { + branches[name.slice("refs/heads/".length)] = oid; + } + } + return branches; +} + +export function getTagsFromRefs( + refs: Record, +): Record { + const tags: Record = {}; + for (const [name, oid] of Object.entries(refs)) { + if (name.startsWith("refs/tags/")) { + tags[name.slice("refs/tags/".length)] = oid; + } + } + return tags; +} diff --git a/src/views/repos/History.svelte b/src/views/repos/History.svelte index 04ddf16df..76fb37657 100644 --- a/src/views/repos/History.svelte +++ b/src/views/repos/History.svelte @@ -2,8 +2,8 @@ import type { BaseUrl, CommitHeader, + PeerRefs, Repo, - Remote, SeedingPolicy, Tree, } from "@http-client"; @@ -31,7 +31,7 @@ export let commit: string; export let commitHeaders: CommitHeader[]; export let peer: string | undefined; - export let peers: Remote[]; + export let peers: PeerRefs[]; export let repo: Repo; export let revision: string | undefined; export let tree: Tree; diff --git a/src/views/repos/Source.svelte b/src/views/repos/Source.svelte index 4e8102031..2c5307e46 100644 --- a/src/views/repos/Source.svelte +++ b/src/views/repos/Source.svelte @@ -1,8 +1,8 @@