From f479f867d18bc6d497bfa4345b606dfff30edf50 Mon Sep 17 00:00:00 2001 From: Scott Chacon Date: Fri, 21 Jul 2023 10:59:20 +0200 Subject: [PATCH] show upstream commits --- src-tauri/src/virtual_branches/mod.rs | 10 +- src/lib/vbranches/types.ts | 3 +- src/routes/repo/[projectId]/+page.svelte | 4 +- .../repo/[projectId]/BottomPanel.svelte | 91 ++++++++++++++++--- src/routes/repo/[projectId]/CommitCard.svelte | 2 +- src/routes/repo/[projectId]/Tray.svelte | 59 +----------- 6 files changed, 85 insertions(+), 84 deletions(-) diff --git a/src-tauri/src/virtual_branches/mod.rs b/src-tauri/src/virtual_branches/mod.rs index 6f843c25a..a23d25fe8 100644 --- a/src-tauri/src/virtual_branches/mod.rs +++ b/src-tauri/src/virtual_branches/mod.rs @@ -63,8 +63,7 @@ pub struct VirtualBranchCommit { pub id: String, pub description: String, pub created_at: u128, - pub author_name: String, - pub author_email: String, + pub author: Author, pub is_remote: bool, } @@ -144,7 +143,7 @@ pub struct BaseBranch { pub upstream_commits: Vec, } -#[derive(Debug, Serialize, Hash, PartialEq, Eq)] +#[derive(Debug, Serialize, Hash, Clone, PartialEq, Eq)] #[serde(rename_all = "camelCase")] pub struct Author { pub name: String, @@ -900,8 +899,6 @@ pub fn commit_to_vbranch_commit( ) -> Result { let timestamp = commit.time().seconds() as u128; let signature = commit.author(); - let name = signature.name().unwrap().to_string(); - let email = signature.email().unwrap().to_string(); let message = commit.message().unwrap().to_string(); let sha = commit.id().to_string(); @@ -913,8 +910,7 @@ pub fn commit_to_vbranch_commit( let commit = VirtualBranchCommit { id: sha, created_at: timestamp * 1000, - author_name: name, - author_email: email, + author: Author::from(signature), description: message, is_remote, }; diff --git a/src/lib/vbranches/types.ts b/src/lib/vbranches/types.ts index 4d2b187ea..fcfb741b2 100644 --- a/src/lib/vbranches/types.ts +++ b/src/lib/vbranches/types.ts @@ -42,8 +42,7 @@ export class Branch { export class Commit { id!: string; - authorEmail!: string; - authorName!: string; + author!: Author; description!: string; @Transform((obj) => new Date(obj.value)) createdAt!: Date; diff --git a/src/routes/repo/[projectId]/+page.svelte b/src/routes/repo/[projectId]/+page.svelte index 35f36e60d..e53af0c13 100644 --- a/src/routes/repo/[projectId]/+page.svelte +++ b/src/routes/repo/[projectId]/+page.svelte @@ -46,7 +46,7 @@ {#if target}
- +
- +
{:else} diff --git a/src/routes/repo/[projectId]/BottomPanel.svelte b/src/routes/repo/[projectId]/BottomPanel.svelte index 4b5ed6bfa..93ed44c3d 100644 --- a/src/routes/repo/[projectId]/BottomPanel.svelte +++ b/src/routes/repo/[projectId]/BottomPanel.svelte @@ -1,10 +1,25 @@ -
+
{/if} - Common base +
+
Common base
+
{target.branchName}
+
{target.behind > 0 ? `behind ${target.behind}` : 'up-to-date'}
+
+ {#if target.behind == 0} + + {:else} + + {/if} +
+
{#if shown}
-
-
We're no strangers to love You know the rules and so do I
-
- A full commitment's what I'm thinking of You wouldn't get this from any other guy -
-
I just wanna tell you how I'm feeling Gotta make you understand
-
Never gonna give you up
-
Never gonna let you down
-
Never gonna run around and desert you
-
Never gonna make you cry
-
Never gonna say goodbye
-
Never gonna tell a lie and hurt you
+
Upstream Commits:
+
+ {#each target.upstreamCommits as commit} +
+ Gravatar for {commit.author.email} +
{commit.description.substring(0, 50)}
+
+ {/each}
{/if}
+ + + + + Update target +

You are about to update the base branch.

+ + + + +
diff --git a/src/routes/repo/[projectId]/CommitCard.svelte b/src/routes/repo/[projectId]/CommitCard.svelte index af18daa84..1816e66f4 100644 --- a/src/routes/repo/[projectId]/CommitCard.svelte +++ b/src/routes/repo/[projectId]/CommitCard.svelte @@ -12,7 +12,7 @@ {commit.description}
-
{commit.authorName}
+
{commit.author.name}
{formatDistanceToNow(commit.createdAt)} ago
diff --git a/src/routes/repo/[projectId]/Tray.svelte b/src/routes/repo/[projectId]/Tray.svelte index a7f059343..69e51b5c3 100644 --- a/src/routes/repo/[projectId]/Tray.svelte +++ b/src/routes/repo/[projectId]/Tray.svelte @@ -2,7 +2,7 @@ import { Button, Checkbox, Modal } from '$lib/components'; import type { Branch, BranchData, BaseBranch } from '$lib/vbranches'; import { formatDistanceToNow } from 'date-fns'; - import { IconGitBranch, IconRemote, IconRefresh } from '$lib/icons'; + import { IconGitBranch, IconRemote } from '$lib/icons'; import { IconTriangleDown, IconTriangleUp } from '$lib/icons'; import { accordion } from './accordion'; import PopupMenu from '$lib/components/PopupMenu/PopupMenu.svelte'; @@ -12,7 +12,6 @@ import { getContext } from 'svelte'; import { BRANCH_CONTROLLER_KEY } from '$lib/vbranches/branchController'; - export let target: BaseBranch; export let branches: Branch[]; export let remoteBranches: BranchData[]; @@ -24,14 +23,9 @@ let yourBranchContextMenu: PopupMenu; let remoteBranchContextMenu: PopupMenu; - let updateTargetModal: Modal; let applyConflictedModal: Modal; let deleteBranchModal: Modal; - $: behindMessage = target.behind > 0 ? `behind ${target.behind}` : 'up-to-date'; - - $: console.log(target); - function toggleBranch(branch: Branch) { if (branch.active) { branchController.unapplyBranch(branch.id); @@ -66,37 +60,6 @@ class="tray-scroll w-80 min-w-[216px] shrink-0 cursor-default resize-x overflow-y-scroll overscroll-y-none border-r border-light-400 bg-white text-light-800 dark:border-dark-600 dark:bg-dark-900 dark:text-dark-100" style:width={$userSettings.trayWidth ? `${$userSettings.trayWidth}px` : null} > - -
Base branch
-
-
{target.branchName}
-
-
{target.behind > 0 ? `behind ${target.behind}` : 'up-to-date'}
-
- {#if target.behind == 0} - - {:else} - - {/if} -
-
-
-
- - - - Update target -

You are about to update the base branch.

- - - - -
-