Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Cleanup commit types
Sebastian Martinez committed 3 years ago
commit 12be0dceb30f91ac8f5cc7a6755e7b785c8cfd44
parent e2f7665dbdfc172436cec5b9b00e15564583424a
5 files changed +28 -168
modified src/lib/commit.ts
@@ -1,4 +1,4 @@
-
import type { Stats, Person } from "@app/lib/project";
+
import type { Stats } from "@app/lib/project";
import type { Diff, DiffStats } from "@app/lib/diff";
import { ApiError } from "@app/lib/api";
import { getDaysPassed } from "@app/lib/utils";
@@ -10,7 +10,6 @@ export interface CommitsHistory {

export interface CommitMetadata {
  commit: CommitHeader;
-
  context: CommitContext;
}

export interface Author {
@@ -30,16 +29,6 @@ export interface GroupedCommitsHistory {
  stats: Stats;
}

-
export interface CommitContext {
-
  committer?: {
-
    peer: {
-
      id: string;
-
      person: Person | null;
-
      delegate: boolean;
-
    };
-
  };
-
}
-

export interface CommitHeader {
  author: Author;
  committer: Author;
@@ -68,7 +57,6 @@ export interface Commit {
  stats: DiffStats;
  diff: Diff;
  branches: string[];
-
  context: CommitContext;
}

export function formatGroupTime(timestamp: number): string {
@@ -81,7 +69,7 @@ export function formatGroupTime(timestamp: number): string {
}

export function groupCommits(
-
  commits: { commit: CommitHeader; context: CommitContext }[],
+
  commits: { commit: CommitHeader }[],
): CommitGroup[] {
  const groupedCommits: CommitGroup[] = [];
  let groupDate: Date | undefined = undefined;
@@ -97,8 +85,8 @@ export function groupCommits(
      return 0;
    });

-
    for (const commit of commits) {
-
      const time = commit.commit.committer.time * 1000;
+
    for (const { commit } of commits) {
+
      const time = commit.committer.time * 1000;
      const date = new Date(time);
      const isNewDay =
        !groupedCommits.length ||
@@ -116,7 +104,7 @@ export function groupCommits(
        });
        groupDate = date;
      }
-
      groupedCommits[groupedCommits.length - 1].commits.push(commit);
+
      groupedCommits[groupedCommits.length - 1].commits.push({ commit });
    }
    return groupedCommits;
  } catch (err) {
modified src/views/projects/Commit.svelte
@@ -5,11 +5,11 @@

  import Changeset from "@app/views/projects/SourceBrowser/Changeset.svelte";
  import CommitAuthorship from "@app/views/projects/Commit/CommitAuthorship.svelte";
-
  import CommitVerifiedBadge from "@app/views/projects/Commit/CommitVerifiedBadge.svelte";
  import * as router from "@app/lib/router";

  export let commit: Commit;

+
  const { commit: header } = commit;
  const onBrowse = (event: { detail: string }) => {
    router.updateProjectRoute({
      view: { resource: "tree" },
@@ -41,11 +41,6 @@
    color: var(--color-foreground-5);
    font-size: var(--font-size-small);
  }
-
  .authorship {
-
    display: flex;
-
    align-items: center;
-
    justify-content: space-between;
-
  }

  @media (max-width: 960px) {
    .commit {
@@ -57,21 +52,16 @@
<div class="commit">
  <header>
    <div class="summary">
-
      <div class="txt-medium" use:twemoji>{commit.commit.summary}</div>
+
      <div class="txt-medium" use:twemoji>{header.summary}</div>
      <div class="layout-desktop txt-monospace sha1">
-
        <span>{commit.commit.id}</span>
+
        <span>{header.id}</span>
      </div>
      <div class="layout-mobile txt-monospace sha1 txt-small">
-
        {formatCommit(commit.commit.id)}
+
        {formatCommit(header.id)}
      </div>
    </div>
-
    <pre class="description txt-small">{commit.commit.description}</pre>
-
    <div class="authorship">
-
      <CommitAuthorship {commit} />
-
      {#if commit.context?.committer}
-
        <CommitVerifiedBadge {commit} />
-
      {/if}
-
    </div>
+
    <pre class="description txt-small">{header.description}</pre>
+
    <CommitAuthorship {header} />
  </header>
  <Changeset
    stats={commit.diff.stats}
modified src/views/projects/Commit/CommitAuthorship.svelte
@@ -1,13 +1,11 @@
<script lang="ts">
-
  import type { CommitMetadata } from "@app/lib/commit";
+
  import type { CommitHeader } from "@app/lib/commit";

-
  import Badge from "@app/components/Badge.svelte";
  import { formatTimestamp, gravatarURL } from "@app/lib/utils";

-
  export let commit: CommitMetadata;
+
  export let header: CommitHeader;
  export let noTime = false;
  export let noAuthor = false;
-
  export let noDelegate = false;
</script>

<style>
@@ -37,64 +35,35 @@
</style>

<span class="authorship txt-tiny">
-
  {#if commit.commit.author.email === commit.commit.committer.email}
+
  {#if header.author.email === header.committer.email}
    <img
      class="avatar"
      alt="avatar"
-
      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.commit.committer.name}
-
      </span>
-
      {#if !noDelegate && commit.context?.committer.peer.delegate}
-
        <Badge variant="tertiary">delegate</Badge>
-
      {/if}
-
      <span>committed</span>
-
    {:else}
-
      <span class="layout-desktop-inline committer">
-
        {commit.commit.committer.name}
-
      </span>
-
      <span>committed</span>
-
    {/if}
+
      src={gravatarURL(header.committer.email)} />
+
    <span class="layout-desktop-inline committer">
+
      {header.committer.name}
+
    </span>
+
    <span>committed</span>
  {:else}
    {#if !noAuthor}
-
      <img
-
        class="avatar"
-
        alt="avatar"
-
        src={gravatarURL(commit.commit.author.email)} />
+
      <img class="avatar" alt="avatar" src={gravatarURL(header.author.email)} />
      <span class="layout-desktop-inline author">
-
        {commit.commit.author.name}
+
        {header.author.name}
      </span>
      <span>authored</span>
    {/if}
    <img
      class="avatar"
      alt="avatar"
-
      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.commit.committer.name}
-
      </span>
-
      {#if !noDelegate && commit.context?.committer.peer.delegate}
-
        <Badge variant="tertiary">delegate</Badge>
-
      {/if}
-
      <span>committed</span>
-
    {:else}
-
      <span class="layout-desktop-inline committer">
-
        {commit.commit.committer.name}
-
      </span>
-
      <span>committed</span>
-
    {/if}
+
      src={gravatarURL(header.committer.email)} />
+
    <span class="layout-desktop-inline committer">
+
      {header.committer.name}
+
    </span>
+
    <span>committed</span>
  {/if}
  {#if !noTime}
    <span class="layout-desktop-inline">
-
      {formatTimestamp(commit.commit.committer.time)}
+
      {formatTimestamp(header.committer.time)}
    </span>
  {/if}
</span>
modified src/views/projects/Commit/CommitTeaser.svelte
@@ -95,7 +95,7 @@
        {commit.commit.summary}
      </div>
    </div>
-
    <CommitAuthorship {commit} noDelegate />
+
    <CommitAuthorship header={commit.commit} />
  </div>
  <div class="column-right">
    <span class="hash txt-highlight">{formatCommit(commit.commit.id)}</span>
deleted src/views/projects/Commit/CommitVerifiedBadge.svelte
@@ -1,87 +0,0 @@
-
<script lang="ts">
-
  import type { CommitMetadata } from "@app/lib/commit";
-

-
  import debounce from "lodash/debounce";
-

-
  import Badge from "@app/components/Badge.svelte";
-
  import CommitAuthorship from "./CommitAuthorship.svelte";
-

-
  export let commit: CommitMetadata;
-

-
  let visible = false;
-
  const showDelay = 50; // ms
-

-
  const setVisible = debounce((value: boolean) => {
-
    visible = value;
-
  }, showDelay);
-
</script>
-

-
<style>
-
  .container {
-
    cursor: default;
-
  }
-
  .wrapper {
-
    position: absolute;
-
  }
-
  .popup {
-
    background-color: var(--color-foreground-1);
-
    border-radius: var(--border-radius-small);
-
    box-shadow: var(--elevation-low);
-
    color: var(--color-foreground);
-
    font-size: var(--font-size-tiny);
-
    left: -10rem;
-
    margin-top: 0.5rem;
-
    padding: 0.5rem 0;
-
    position: absolute;
-
    min-width: 14rem;
-
    z-index: 99;
-
  }
-
  .header {
-
    display: flex;
-
    padding: 1rem 0.75rem;
-
    gap: 0.5rem;
-
  }
-
  .highlight {
-
    color: var(--color-tertiary);
-
  }
-
  .committer {
-
    border-top: 1px dashed var(--color-foreground-4);
-
    padding: 0.75rem;
-
  }
-
  .peer {
-
    padding-top: 0.5rem;
-
    word-break: break-all;
-
    color: var(--color-foreground-5);
-
  }
-
</style>
-

-
<!-- svelte-ignore a11y-click-events-have-key-events -->
-
<div
-
  class="container"
-
  on:click|stopPropagation
-
  on:mouseenter={() => setVisible(true)}
-
  on:mouseleave={() => setVisible(false)}>
-
  <Badge variant="tertiary">Verified</Badge>
-

-
  {#if visible}
-
    <div class="wrapper">
-
      <div class="popup">
-
        <div class="header">
-
          <div class="highlight">✔</div>
-
          <div>
-
            This commit was <span class="highlight">signed</span>
-
            with the committer's radicle key.
-
          </div>
-
        </div>
-
        <div class="committer">
-
          <CommitAuthorship {commit} noAuthor noTime />
-
          {#if commit.context.committer}
-
            <div class="peer">
-
              {commit.context.committer.peer.id}
-
            </div>
-
          {/if}
-
        </div>
-
      </div>
-
    </div>
-
  {/if}
-
</div>