mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-10-18 19:30:27 +08:00
Update JSON scheme for heartwood
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
This commit is contained in:
@@ -34,7 +34,7 @@ GIT_AUTHOR_EMAIL="alice@radicle.xyz"
|
||||
GIT_COMMITTER_NAME="Alice Liddell"
|
||||
GIT_COMMITTER_EMAIL="alice@radicle.xyz"
|
||||
|
||||
RAD_DEBUG=1 RAD_HOME=$ALICE_RAD_HOME RAD_PASSPHRASE=$PASSPHRASE rad auth
|
||||
RAD_SEED=ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff RAD_HOME=$ALICE_RAD_HOME RAD_PASSPHRASE=$PASSPHRASE rad auth
|
||||
|
||||
cd $ALICE_CHECKOUT
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
REV=1f55d7a32750b3e63c56aad00370411b90420a29
|
||||
REV=e01838a70a2e19d747a49085db6445b1b823901e
|
||||
|
||||
REPO_ROOT=$(git rev-parse --show-toplevel)
|
||||
FIXTURE=$REPO_ROOT/tests/fixtures/seeds/palm-heartwood.tar.bz2
|
||||
@@ -69,7 +69,7 @@ run_docker() {
|
||||
}
|
||||
|
||||
run_binary() {
|
||||
if [ $CI = true ]; then
|
||||
if [ "$CI" = true ]; then
|
||||
local binaries_dir="$REPO_ROOT/tests/tmp"
|
||||
gsutil cp "gs://heartwood-artifacts/${REV}/x86_64-unknown-linux-musl/radicle-httpd" "$binaries_dir"
|
||||
chmod a+x "${binaries_dir}/radicle-httpd"
|
||||
|
||||
+10
-10
@@ -4,18 +4,19 @@ import { ApiError } from "@app/lib/api";
|
||||
import { getDaysPassed } from "@app/lib/utils";
|
||||
|
||||
export interface CommitsHistory {
|
||||
headers: CommitMetadata[];
|
||||
commits: CommitMetadata[];
|
||||
stats: Stats;
|
||||
}
|
||||
|
||||
export interface CommitMetadata {
|
||||
header: CommitHeader;
|
||||
commit: CommitHeader;
|
||||
context: CommitContext;
|
||||
}
|
||||
|
||||
export interface Author {
|
||||
email: string;
|
||||
name: string;
|
||||
time: number;
|
||||
}
|
||||
|
||||
export interface CommitStats {
|
||||
@@ -25,7 +26,7 @@ export interface CommitStats {
|
||||
}
|
||||
|
||||
export interface GroupedCommitsHistory {
|
||||
headers: CommitGroup[];
|
||||
commits: CommitGroup[];
|
||||
stats: Stats;
|
||||
}
|
||||
|
||||
@@ -42,9 +43,8 @@ export interface CommitContext {
|
||||
export interface CommitHeader {
|
||||
author: Author;
|
||||
committer: Author;
|
||||
committerTime: number;
|
||||
description: string;
|
||||
sha1: string;
|
||||
id: string;
|
||||
summary: string;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ export interface WeeklyActivity {
|
||||
}
|
||||
|
||||
export interface Commit {
|
||||
header: CommitHeader;
|
||||
commit: CommitHeader;
|
||||
stats: DiffStats;
|
||||
diff: Diff;
|
||||
branches: string[];
|
||||
@@ -81,16 +81,16 @@ export function formatGroupTime(timestamp: number): string {
|
||||
}
|
||||
|
||||
export function groupCommits(
|
||||
commits: { header: CommitHeader; context: CommitContext }[],
|
||||
commits: { commit: CommitHeader; context: CommitContext }[],
|
||||
): CommitGroup[] {
|
||||
const groupedCommits: CommitGroup[] = [];
|
||||
let groupDate: Date | undefined = undefined;
|
||||
|
||||
try {
|
||||
commits = commits.sort((a, b) => {
|
||||
if (a.header.committerTime > b.header.committerTime) {
|
||||
if (a.commit.committer.time > b.commit.committer.time) {
|
||||
return -1;
|
||||
} else if (a.header.committerTime < b.header.committerTime) {
|
||||
} else if (a.commit.committer.time < b.commit.committer.time) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ export function groupCommits(
|
||||
});
|
||||
|
||||
for (const commit of commits) {
|
||||
const time = commit.header.committerTime * 1000;
|
||||
const time = commit.commit.committer.time * 1000;
|
||||
const date = new Date(time);
|
||||
const isNewDay =
|
||||
!groupedCommits.length ||
|
||||
|
||||
+52
-4
@@ -282,7 +282,24 @@ export class Project implements ProjectInfo {
|
||||
page: opts?.page,
|
||||
verified: opts?.verified,
|
||||
};
|
||||
return new Request(`projects/${id}/commits`, host).get(params);
|
||||
const result = await new Request(`projects/${id}/commits`, host).get(
|
||||
params,
|
||||
);
|
||||
if (!window.HEARTWOOD) {
|
||||
for (const commit of result.headers) {
|
||||
commit.commit = commit.header;
|
||||
delete commit.header;
|
||||
|
||||
commit.commit.committer.time = commit.commit.committerTime;
|
||||
delete commit.commit.committerTime;
|
||||
|
||||
commit.commit.id = commit.commit.sha1;
|
||||
delete commit.commit.sha1;
|
||||
}
|
||||
result.commits = result.headers;
|
||||
delete result.headers;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static async getActivity(
|
||||
@@ -299,6 +316,15 @@ export class Project implements ProjectInfo {
|
||||
).get();
|
||||
|
||||
if (!window.HEARTWOOD) {
|
||||
result.commit = result.header;
|
||||
delete result.header;
|
||||
|
||||
result.commit.committer.time = result.commit.committerTime;
|
||||
delete result.commit.committerTime;
|
||||
|
||||
result.commit.id = result.commit.sha1;
|
||||
delete result.commit.sha1;
|
||||
|
||||
result.stats["insertions"] = result.stats["additions"];
|
||||
delete result.stats["additions"];
|
||||
result.diff["added"] = result.diff["created"];
|
||||
@@ -333,24 +359,46 @@ export class Project implements ProjectInfo {
|
||||
|
||||
async getTree(commit: string, path: string): Promise<Tree> {
|
||||
if (path === "/") path = "";
|
||||
return new Request(
|
||||
const result = await new Request(
|
||||
`projects/${this.id}/tree/${commit}/${path}`,
|
||||
this.seed.addr,
|
||||
).get();
|
||||
if (!window.HEARTWOOD) {
|
||||
if (result.info.lastCommit) {
|
||||
result.info.lastCommit.id = result.info.lastCommit.sha1;
|
||||
delete result.info.lastCommit.sha1;
|
||||
}
|
||||
for (const entry of result.entries) {
|
||||
if (entry.info.lastCommit) {
|
||||
entry.info.lastCommit.id = entry.info.lastCommit.sha1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
async getBlob(commit: string, path: string): Promise<Blob> {
|
||||
return new Request(
|
||||
const result = await new Request(
|
||||
`projects/${this.id}/blob/${commit}/${path}`,
|
||||
this.seed.addr,
|
||||
).get();
|
||||
if (!window.HEARTWOOD) {
|
||||
result.info.lastCommit.id = result.info.lastCommit.sha1;
|
||||
delete result.info.lastCommit.sha1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
async getReadme(commit: string): Promise<Blob> {
|
||||
return new Request(
|
||||
const result = await new Request(
|
||||
`projects/${this.id}/readme/${commit}`,
|
||||
this.seed.addr,
|
||||
).get();
|
||||
if (!window.HEARTWOOD && result.info.lastCommit) {
|
||||
result.info.lastCommit.id = result.info.lastCommit.sha1;
|
||||
delete result.info.lastCommit.sha1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static async get(
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
const fileExtension = blob.path.split(".").pop() ?? "";
|
||||
const lastCommit = window.HEARTWOOD ? blob.lastCommit : blob.info.lastCommit;
|
||||
|
||||
const parentDir = blob.path
|
||||
.match(/^.*\/|/)
|
||||
?.values()
|
||||
@@ -227,7 +228,9 @@
|
||||
</div>
|
||||
{/if}
|
||||
<div class="last-commit" title={lastCommit.author.name} use:twemoji>
|
||||
<span class="hash">{lastCommit.sha1.slice(0, 7)}</span>
|
||||
<span class="hash">
|
||||
{lastCommit.id.slice(0, 7)}
|
||||
</span>
|
||||
{lastCommit.summary}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -57,15 +57,15 @@
|
||||
<div class="commit">
|
||||
<header>
|
||||
<div class="summary">
|
||||
<div class="txt-medium" use:twemoji>{commit.header.summary}</div>
|
||||
<div class="txt-medium" use:twemoji>{commit.commit.summary}</div>
|
||||
<div class="layout-desktop txt-monospace sha1">
|
||||
<span>{commit.header.sha1}</span>
|
||||
<span>{commit.commit.id}</span>
|
||||
</div>
|
||||
<div class="layout-mobile txt-monospace sha1 txt-small">
|
||||
{formatCommit(commit.header.sha1)}
|
||||
{formatCommit(commit.commit.id)}
|
||||
</div>
|
||||
</div>
|
||||
<pre class="description txt-small">{commit.header.description}</pre>
|
||||
<pre class="description txt-small">{commit.commit.description}</pre>
|
||||
<div class="authorship">
|
||||
<CommitAuthorship {commit} />
|
||||
{#if commit.context?.committer}
|
||||
|
||||
@@ -37,17 +37,17 @@
|
||||
</style>
|
||||
|
||||
<span class="authorship txt-tiny">
|
||||
{#if commit.header.author.email === commit.header.committer.email}
|
||||
{#if commit.commit.author.email === commit.commit.committer.email}
|
||||
<img
|
||||
class="avatar"
|
||||
alt="avatar"
|
||||
src={gravatarURL(commit.header.committer.email)} />
|
||||
src={gravatarURL(commit.commit.committer.email)} />
|
||||
{#if commit.context?.committer}
|
||||
<span
|
||||
class="committer"
|
||||
class:txt-bold={Boolean(commit.context.committer.peer.person?.name)}>
|
||||
{commit.context.committer.peer.person?.name ||
|
||||
commit.header.committer.name}
|
||||
commit.commit.committer.name}
|
||||
</span>
|
||||
{#if !noDelegate && commit.context?.committer.peer.delegate}
|
||||
<Badge variant="tertiary">delegate</Badge>
|
||||
@@ -55,7 +55,7 @@
|
||||
<span>committed</span>
|
||||
{:else}
|
||||
<span class="layout-desktop-inline committer">
|
||||
{commit.header.committer.name}
|
||||
{commit.commit.committer.name}
|
||||
</span>
|
||||
<span>committed</span>
|
||||
{/if}
|
||||
@@ -64,22 +64,22 @@
|
||||
<img
|
||||
class="avatar"
|
||||
alt="avatar"
|
||||
src={gravatarURL(commit.header.author.email)} />
|
||||
src={gravatarURL(commit.commit.author.email)} />
|
||||
<span class="layout-desktop-inline author">
|
||||
{commit.header.author.name}
|
||||
{commit.commit.author.name}
|
||||
</span>
|
||||
<span>authored</span>
|
||||
{/if}
|
||||
<img
|
||||
class="avatar"
|
||||
alt="avatar"
|
||||
src={gravatarURL(commit.header.committer.email)} />
|
||||
src={gravatarURL(commit.commit.committer.email)} />
|
||||
{#if commit.context?.committer}
|
||||
<span
|
||||
class="committer"
|
||||
class:txt-bold={Boolean(commit.context.committer.peer.person?.name)}>
|
||||
{commit.context.committer.peer.person?.name ||
|
||||
commit.header.committer.name}
|
||||
commit.commit.committer.name}
|
||||
</span>
|
||||
{#if !noDelegate && commit.context?.committer.peer.delegate}
|
||||
<Badge variant="tertiary">delegate</Badge>
|
||||
@@ -87,14 +87,14 @@
|
||||
<span>committed</span>
|
||||
{:else}
|
||||
<span class="layout-desktop-inline committer">
|
||||
{commit.header.committer.name}
|
||||
{commit.commit.committer.name}
|
||||
</span>
|
||||
<span>committed</span>
|
||||
{/if}
|
||||
{/if}
|
||||
{#if !noTime}
|
||||
<span class="layout-desktop-inline">
|
||||
{formatTimestamp(commit.header.committerTime)}
|
||||
{formatTimestamp(commit.commit.committer.time)}
|
||||
</span>
|
||||
{/if}
|
||||
</span>
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
<div class="column-left">
|
||||
<div class="header">
|
||||
<div class="summary" use:twemoji>
|
||||
{commit.header.summary}
|
||||
{commit.commit.summary}
|
||||
</div>
|
||||
</div>
|
||||
<CommitAuthorship {commit} noDelegate />
|
||||
@@ -99,12 +99,12 @@
|
||||
<CommitVerifiedBadge {commit} />
|
||||
</div>
|
||||
{/if}
|
||||
<span class="hash txt-highlight">{formatCommit(commit.header.sha1)}</span>
|
||||
<span class="hash txt-highlight">{formatCommit(commit.commit.id)}</span>
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div
|
||||
class="browse"
|
||||
title="Browse the repository at this point in the history"
|
||||
on:click|stopPropagation={() => browseCommit(commit.header.sha1)}>
|
||||
on:click|stopPropagation={() => browseCommit(commit.commit.id)}>
|
||||
<Icon name="browse" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
const fetchMoreCommits = async (): Promise<CommitMetadata[]> => {
|
||||
const response = await Project.getCommits(project.id, project.seed.addr, {
|
||||
// Fetching 31 elements since we remove the first one
|
||||
parent: history.headers[history.headers.length - 1].header.sha1,
|
||||
parent: history.commits[history.commits.length - 1].commit.id,
|
||||
perPage: 31,
|
||||
verified: true,
|
||||
});
|
||||
// Removing the first element of the array, since it's the same as the last of the current list
|
||||
return response.headers.slice(1);
|
||||
return response.commits.slice(1);
|
||||
};
|
||||
|
||||
const browseCommit = (event: { detail: string }) => {
|
||||
@@ -68,23 +68,23 @@
|
||||
</style>
|
||||
|
||||
<div class="history">
|
||||
<List bind:items={history.headers} query={fetchMoreCommits}>
|
||||
<List bind:items={history.commits} query={fetchMoreCommits}>
|
||||
<svelte:fragment slot="list" let:items>
|
||||
{@const headers = groupCommits(items)}
|
||||
{#each headers as group (group.time)}
|
||||
{@const commits = groupCommits(items)}
|
||||
{#each commits as group (group.time)}
|
||||
<div class="commit-group">
|
||||
<header class="commit-date">
|
||||
<p>{group.date}</p>
|
||||
</header>
|
||||
<div class="commit-group-headers">
|
||||
{#each group.commits as commit (commit.header.sha1)}
|
||||
{#each group.commits as commit (commit.commit.id)}
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div
|
||||
class="commit"
|
||||
on:click={() => {
|
||||
router.updateProjectRoute({
|
||||
view: { resource: "commits" },
|
||||
revision: commit.header.sha1,
|
||||
revision: commit.commit.id,
|
||||
});
|
||||
}}>
|
||||
<CommitTeaser {commit} on:browseCommit={browseCommit} />
|
||||
|
||||
BIN
Binary file not shown.
Reference in New Issue
Block a user