Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Updates for http-api verified commits change
Alexis Sellier committed 4 years ago
commit efb91c7e7383aeddf4b81afefd83f8ac3889f995
parent 101d6d329fcf9040bcd0f7617e7b8e72ae672139
5 files changed +31 -9
modified cypress/integration/project.spec.ts
@@ -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" });
  });
modified src/api.ts
@@ -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;
modified src/base/projects/History.svelte
@@ -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>
modified src/base/projects/Widget.svelte
@@ -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>
modified src/project.ts
@@ -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);
  }