Fix rendering of upstream commits when remote commits exist

This commit is contained in:
Mattias Granlund 2024-05-16 15:22:38 +02:00
parent 364cacd775
commit 5cdf0b830e
3 changed files with 35 additions and 9 deletions

View File

@ -31,6 +31,8 @@
commit={localCommit?.status == 'remote' ? localCommit : undefined} commit={localCommit?.status == 'remote' ? localCommit : undefined}
line={localCommit?.status == 'remote' || remoteLine} line={localCommit?.status == 'remote' || remoteLine}
root={localLine} root={localLine}
{remoteCommit}
{upstreamLine}
{first} {first}
{base} {base}
/> />

View File

@ -32,21 +32,21 @@
<CommitLines <CommitLines
{hasLocalColumn} {hasLocalColumn}
{hasShadowColumn} {hasShadowColumn}
first={idx == 0} upstreamLine
localLine={hasLocalColumn} localLine={hasLocalColumn}
remoteCommit={commit} remoteCommit={commit}
upstreamLine first={idx == 0}
/> />
<CommitListItem {commit}> <CommitListItem {commit}>
<CommitCard <CommitCard
type="upstream"
branch={$branch} branch={$branch}
{commit} {commit}
commitUrl={$baseBranch?.commitUrl(commit.id)}
isHeadCommit={commit.id === headCommit?.id}
{isUnapplied} {isUnapplied}
first={idx == 0} first={idx == 0}
last={idx == $unknownCommits.length - 1} last={idx == $unknownCommits.length - 1}
type="upstream" commitUrl={$baseBranch?.commitUrl(commit.id)}
isHeadCommit={commit.id === headCommit?.id}
/> />
</CommitListItem> </CommitListItem>
</div> </div>
@ -85,7 +85,12 @@
{/each} {/each}
{/if} {/if}
{#if $remoteCommits.length > 0} {#if $remoteCommits.length > 0}
<CommitLines {hasShadowColumn} {hasLocalColumn} localLine /> <CommitLines
{hasShadowColumn}
{hasLocalColumn}
upstreamLine={hasUnknownCommits}
localLine
/>
{#each $remoteCommits as commit, idx (commit.id)} {#each $remoteCommits as commit, idx (commit.id)}
<div class="flex"> <div class="flex">
<CommitLines <CommitLines

View File

@ -1,12 +1,14 @@
<script lang="ts"> <script lang="ts">
import Avatar from './Avatar.svelte'; import Avatar from './Avatar.svelte';
import type { Commit } from '$lib/vbranches/types'; import type { Commit, RemoteCommit } from '$lib/vbranches/types';
export let commit: Commit | undefined; export let commit: Commit | undefined;
export let remoteCommit: RemoteCommit | undefined;
export let base: boolean; export let base: boolean;
export let first: boolean; export let first: boolean;
export let line: boolean; export let line: boolean;
export let root: boolean; export let root: boolean;
export let upstreamLine: boolean;
$: hasRoot = isRoot(commit); $: hasRoot = isRoot(commit);
@ -39,7 +41,12 @@
</div> </div>
{:else} {:else}
{#if line} {#if line}
<div class="remote-line" class:first></div> {#if upstreamLine}
<div class="remote-line tip" class:upstream={upstreamLine}></div>
{/if}
<div class="remote-line" class:short={first} />
{:else if upstreamLine}
<div class="remote-line upstream" class:short={first} />
{/if} {/if}
{#if hasRoot} {#if hasRoot}
<div class="root" /> <div class="root" />
@ -50,6 +57,12 @@
<Avatar {author} status={commit.status} /> <Avatar {author} status={commit.status} />
</div> </div>
{/if} {/if}
{#if remoteCommit}
{@const author = remoteCommit.author}
<div class="avatar" class:first>
<Avatar {author} status={remoteCommit.status} />
</div>
{/if}
{/if} {/if}
</div> </div>
@ -70,7 +83,10 @@
top: calc(var(--size-40) + var(--size-2)); top: calc(var(--size-40) + var(--size-2));
} }
&.short { &.short {
top: 1rem; top: 3rem;
}
&.tip {
bottom: calc(100% - 2.625rem);
} }
&.dashed { &.dashed {
background: repeating-linear-gradient( background: repeating-linear-gradient(
@ -81,6 +97,9 @@
var(--clr-commit-remote) 0.4375rem var(--clr-commit-remote) 0.4375rem
); );
} }
&.upstream {
background-color: var(--clr-commit-upstream);
}
} }
.avatar { .avatar {