mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-02 10:10:28 +08:00
Updates for http-api verified commits change
Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
@@ -13,7 +13,7 @@ describe("Project View", () => {
|
||||
cy.intercept("https://willow.radicle.garden:8777/v1/projects/rad:git:hnrk8mbpirp7ua7sy66o4t9soasbq4y8uwgoy/tree/cbf5df499ab4f4a908f1756fbe2c236a4530516a", { fixture: "projectTreecbf5df4.json" });
|
||||
cy.intercept("https://willow.radicle.garden:8777/v1/projects/rad:git:hnrk8mbpirp7ua7sy66o4t9soasbq4y8uwgoy/remotes/hyndc7nx9keq76p1bkw9831arcndeeu3trwsc7kxt3osmpi6j9oeke", { fixture: "projectBranches.json" });
|
||||
cy.intercept("https://willow.radicle.garden:8777/v1/projects/rad:git:hnrk8mbpirp7ua7sy66o4t9soasbq4y8uwgoy/readme/56e4e029c294b08546386e1fb706b772c7433c49", { fixture: "projectReadme.json" });
|
||||
cy.intercept("https://willow.radicle.garden:8777/v1/projects/rad:git:hnrk8mbpirp7ua7sy66o4t9soasbq4y8uwgoy/commits?parent=cbf5df499ab4f4a908f1756fbe2c236a4530516a", { fixture: "projectCommits.json" });
|
||||
cy.intercept("https://willow.radicle.garden:8777/v1/projects/rad:git:hnrk8mbpirp7ua7sy66o4t9soasbq4y8uwgoy/commits?parent=cbf5df499ab4f4a908f1756fbe2c236a4530516a?verified=true", { fixture: "projectCommits.json" });
|
||||
cy.intercept("https://willow.radicle.garden:8777/v1/projects/rad:git:hnrk8mbpirp7ua7sy66o4t9soasbq4y8uwgoy/readme/cbf5df499ab4f4a908f1756fbe2c236a4530516a", { fixture: "projectReadme.json" });
|
||||
cy.intercept("https://willow.radicle.garden:8777/v1/projects/rad:git:hnrk8mbpirp7ua7sy66o4t9soasbq4y8uwgoy/commits/cbf5df499ab4f4a908f1756fbe2c236a4530516a", { fixture: "projectCommit.json" });
|
||||
});
|
||||
|
||||
+3
-1
@@ -10,7 +10,9 @@ export async function get(
|
||||
): Promise<any> {
|
||||
const query: Record<string, string> = {};
|
||||
for (const [key, val] of Object.entries(params)) {
|
||||
query[key] = val.toString();
|
||||
if (val !== undefined && val !== null) {
|
||||
query[key] = val.toString();
|
||||
}
|
||||
}
|
||||
|
||||
const base = api.host;
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
export let commit: string;
|
||||
|
||||
const fetchCommits = async (parentCommit: string): Promise<GroupedCommitsHistory> => {
|
||||
const commitsQuery = await Project.getCommits(project.urn, project.seed.api, parentCommit);
|
||||
const commitsQuery = await Project.getCommits(project.urn, project.seed.api, {
|
||||
parent: parentCommit, verified: true
|
||||
});
|
||||
return groupCommitHistory(commitsQuery);
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -18,7 +18,10 @@
|
||||
};
|
||||
|
||||
const loadCommits = async () => {
|
||||
const commits = await Project.getCommits(project.urn, seed.api, project.head ?? undefined, getTimestampOneYearAgo(), undefined, "500", "0");
|
||||
const commits = await Project.getCommits(project.urn, seed.api, {
|
||||
parent: project.head ?? null,
|
||||
since: getTimestampOneYearAgo(),
|
||||
});
|
||||
return groupCommitsByWeek(commits.headers);
|
||||
};
|
||||
</script>
|
||||
|
||||
+20
-5
@@ -274,11 +274,26 @@ export class Project implements ProjectInfo {
|
||||
return api.get(`projects/${urn}/remotes`, {}, host);
|
||||
}
|
||||
|
||||
static async getCommits(urn: string, host: api.Host, parent?: string, since?: string, until?: string, perPage?: string, page?: string): Promise<CommitsHistory> {
|
||||
const params: Record<string, string | undefined> = { parent, since, until, "per-page": perPage, page };
|
||||
// Removes the undefined params.
|
||||
Object.keys(params).forEach(key => params[key] === undefined && delete params[key]);
|
||||
|
||||
static async getCommits(
|
||||
urn: string,
|
||||
host: api.Host,
|
||||
opts?: {
|
||||
parent?: string | null;
|
||||
since?: string;
|
||||
until?: string;
|
||||
perPage?: number;
|
||||
page?: number;
|
||||
verified?: boolean;
|
||||
}
|
||||
): Promise<CommitsHistory> {
|
||||
const params: Record<string, any> = {
|
||||
"parent": opts?.parent,
|
||||
"since": opts?.since,
|
||||
"until": opts?.until,
|
||||
"per-page": opts?.perPage,
|
||||
"page": opts?.page,
|
||||
"verified": opts?.verified
|
||||
};
|
||||
return api.get(`projects/${urn}/commits`, params, host);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user