mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 02:00:31 +08:00
Move repo facts outside the project payload
Repos need not carry a `xyz.radicle.project` payload; the default branch can come from `xyz.radicle.crefs` alone. Such repos got no counts and no default branch, and failed schema validation in explorer, which broke the parse of a whole listing. httpd: - Add top-level `cobs` with issue, patch and bucketed release counts - Add top-level `defaultBranch`, qualified like the crefs payload - Omit a count the node cannot determine instead of reporting zero - Drop `head`: the tip is `refs[defaultBranch]` - Keep counts in the project payload for older clients until a major release - Keep the project payload when a COB read fails - Keep `meta.releases` a single count: delegate + other - Log and skip canonical ref rules and refs that fail to read, so one bad ref doesn't drop the default branch tip explorer: - Model `cobs` and `defaultBranch`, adapting older nodes to one shape - Resolve the default branch from the crefs HEAD on older nodes - Collect the shims for older httpd in http-client/lib/compat.ts, each naming the httpd release that the client can drop it with - Add `defaultBranchTip`, replacing `head`, with a fallback to the legacy `meta.head` - Make the project payload and its legacy meta optional - Fall back to the RID for the repo name, and show a placeholder for a missing name in repo cards and the header - Hide a counter instead of reading a missing count as zero - Fall back to a full-page check for "More" without counts - Add a `repo.sourceUnavailable` route for repos without a default branch or tip - Browse explicit revisions and offer the branch selector without a default branch - List these repos in repo grids and on the landing page - Say the node is older or built without releases - Scope release pages in the client, so views never call the shims - Read OG worker repos through the same compat shims - Share the repo name and default branch helpers with the OG worker CI: - Add check:open-graph, a wrangler deploy dry run - Run it in GitHub CI, Buildkite and check:ci - Install explorer's dependencies first: the worker resolves compat.ts imports, such as zod, from there Tests: - Test that a build without releases omits the count - Test that one failing rule keeps the others - Test the repo shape across httpd versions and the release shims - Test `hasMorePages` and `repoName` - Test repos without a project payload end to end
This commit is contained in:
@@ -46,8 +46,9 @@ export function artifactView(
|
||||
trusted: visible(byScope.trusted).length,
|
||||
untrusted: visible(byScope.untrusted).length,
|
||||
},
|
||||
// Others is one click away whenever it holds something.
|
||||
showFilters: byScope.untrusted.length > 0,
|
||||
// Others is one click away whenever it holds something, and Delegates is
|
||||
// one click back from it.
|
||||
showFilters: scope === "untrusted" || byScope.untrusted.length > 0,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -299,7 +299,8 @@ function setTitle(loadedRoute: LoadedRoute) {
|
||||
loadedRoute.resource === "repo.patches" ||
|
||||
loadedRoute.resource === "repo.patch" ||
|
||||
loadedRoute.resource === "repo.releases" ||
|
||||
loadedRoute.resource === "repo.release"
|
||||
loadedRoute.resource === "repo.release" ||
|
||||
loadedRoute.resource === "repo.sourceUnavailable"
|
||||
) {
|
||||
title.push(...repoTitle(loadedRoute));
|
||||
} else if (loadedRoute.resource === "nodes") {
|
||||
|
||||
+26
-17
@@ -6,25 +6,14 @@ import twemojiModule from "twemoji";
|
||||
|
||||
export const REFS_HEADS = "refs/heads/";
|
||||
|
||||
// Reads the repository's default branch. Heartwood no longer requires the
|
||||
// project payload, so this is the single place to change once the API stops
|
||||
// carrying the default branch there.
|
||||
export function defaultBranch(repo: Repo): string {
|
||||
return repo.payloads["xyz.radicle.project"].data.defaultBranch;
|
||||
// The commit the default branch resolves to.
|
||||
export function defaultBranchTip(repo: Repo): string | undefined {
|
||||
return repo.defaultBranch ? repo.refs?.refs[repo.defaultBranch] : undefined;
|
||||
}
|
||||
|
||||
// Counts the releases a user can browse: the two unredacted buckets, or the
|
||||
// single count older nodes report in place of the buckets. Undefined means the
|
||||
// node doesn't report releases at all, which is how the release API is
|
||||
// detected.
|
||||
export function visibleReleaseCount(repo: Repo): number | undefined {
|
||||
const releases = repo.payloads["xyz.radicle.project"].meta.releases;
|
||||
if (releases === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return typeof releases === "number"
|
||||
? releases
|
||||
: releases.delegate + releases.other;
|
||||
// The default branch in the unqualified form that routes use.
|
||||
export function defaultBranchName(repo: Repo): string | undefined {
|
||||
return repo.defaultBranch ? unqualifyBranch(repo.defaultBranch) : undefined;
|
||||
}
|
||||
|
||||
export function unqualifyBranch(refname: string): string {
|
||||
@@ -105,6 +94,26 @@ export function truncateId(pubkey: string): string {
|
||||
return `${pubkey.substring(0, 6)}…${pubkey.slice(-6)}`;
|
||||
}
|
||||
|
||||
// Whether a paged list may have more items. With a total, compare against it;
|
||||
// without one, offer more while every loaded page came back full.
|
||||
export function hasMorePages(
|
||||
loaded: number,
|
||||
pages: number,
|
||||
perPage: number,
|
||||
total: number | undefined,
|
||||
): boolean {
|
||||
return total === undefined ? loaded === pages * perPage : loaded < total;
|
||||
}
|
||||
|
||||
// A repo only has a name if it carries a project payload. Fall back to the RID,
|
||||
// which every repo has.
|
||||
export function repoName(repo: Repo): string {
|
||||
return (
|
||||
repo.payloads["xyz.radicle.project"]?.data.name ??
|
||||
formatRepositoryId(repo.rid)
|
||||
);
|
||||
}
|
||||
|
||||
// The URL path segment to use for a repo: its configured alias when the node
|
||||
// advertises one, otherwise the canonical RID. Keeps alias-based URLs sticky
|
||||
// across in-app navigation, since the backend resolves either form.
|
||||
|
||||
Reference in New Issue
Block a user