Fix bug in commit lines

- handle case where only some commits have been rebased
This commit is contained in:
Mattias Granlund 2024-05-30 19:17:52 +02:00
parent 10df1621a7
commit 60f289f92a
3 changed files with 26 additions and 2 deletions

View File

@ -36,6 +36,11 @@
root={localRoot ||
(localCommit?.status == 'remote' && localCommit?.children?.[0]?.status == 'local')}
remoteCommit={!hasShadowColumn ? remoteCommit : undefined}
shadowCommit={!hasShadowColumn &&
localCommit?.relatedTo &&
localCommit.relatedTo.id != localCommit.id
? localCommit.relatedTo
: undefined}
upstreamLine={upstreamLine && !hasShadowColumn}
{first}
short={(!!localCommit && !localCommit?.children?.[0] && !upstreamLine) ||

View File

@ -17,7 +17,8 @@
const baseBranch = getContextStore(BaseBranch);
const project = getContext(Project);
$: hasShadowColumn = $localCommits.some((c) => c.relatedTo && c.id != c.relatedTo.id);
$: hasShadowColumn =
$remoteCommits.length > 0 && $remoteCommits.at(0)?.relatedTo?.id != $remoteCommits.at(0)?.id;
$: hasLocalColumn = $localCommits.length > 0;
$: hasCommits = $branch.commits && $branch.commits.length > 0;
$: headCommit = $branch.commits.at(0);

View File

@ -1,10 +1,12 @@
<script lang="ts">
import Avatar from './Avatar.svelte';
import { getAvatarTooltip } from '$lib/utils/avatar';
import { tooltip } from '$lib/utils/tooltip';
import type { Commit, RemoteCommit } from '$lib/vbranches/types';
export let commit: Commit | undefined;
export let remoteCommit: RemoteCommit | undefined;
export let shadowCommit: RemoteCommit | undefined;
export let base: boolean;
export let first: boolean;
export let short: boolean;
@ -12,7 +14,7 @@
export let root: boolean;
export let upstreamLine: boolean;
$: tooltipText = getAvatarTooltip(commit || remoteCommit);
$: tooltipText = getAvatarTooltip(commit || remoteCommit || shadowCommit);
</script>
<div class="remote-column" class:has-root={root} class:base>
@ -61,6 +63,9 @@
<Avatar {author} status={remoteCommit.status} help={tooltipText} />
</div>
{/if}
{#if shadowCommit}
<div class="shadow-marker" class:first class:short use:tooltip={tooltipText}></div>
{/if}
{/if}
</div>
@ -157,4 +162,17 @@
width: var(--size-16);
}
}
.shadow-marker {
position: absolute;
width: var(--size-10);
height: var(--size-10);
border-radius: 100%;
background-color: var(--clr-commit-upstream);
top: calc(var(--avatar-top) + var(--size-4));
left: calc(var(--size-6) + var(--size-1));
&.first {
top: calc(var(--avatar-first-top) + var(--size-2) + var(--size-1));
}
}
</style>