Skip to content

Commit

Permalink
Fix a couple of issues in commit lines
Browse files Browse the repository at this point in the history
- local line was not using the `.first` class
- `localIn` prop must be undefined if first
- simplify and fix "out type" calculation
  • Loading branch information
mtsgrd committed Jun 11, 2024
1 parent 650a463 commit 0399f98
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
22 changes: 8 additions & 14 deletions app/src/lib/components/CommitList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
$: hasLocalColumn = $localCommits.length > 0;
$: hasCommits = $branch.commits && $branch.commits.length > 0;
$: headCommit = $branch.commits.at(0);
$: firstCommit = $branch.commits.at(-1);
$: hasLocalCommits = $localCommits.length > 0;
$: hasUnknownCommits = $unknownCommits.length > 0;
$: hasIntegratedCommits = $integratedCommits.length > 0;
Expand All @@ -61,19 +60,13 @@
return commit.next?.status;
}
let pointer: Commit | undefined = commit;
let upstreamCommit = commit.relatedTo;
let pointer: Commit | undefined = commit.next;
while (!upstreamCommit && pointer) {
pointer = pointer.prev;
upstreamCommit = pointer?.relatedTo;
while (pointer && !pointer.relatedTo) {
pointer = pointer.next;
}
if (!upstreamCommit) return hasUnknownCommits ? 'upstream' : undefined;
let nextUpstreamCommit = upstreamCommit.next?.relatedTo;
if (nextUpstreamCommit) return nextUpstreamCommit.status;
if (hasUnknownCommits) return 'upstream';
if (pointer) return pointer.status;
return hasUnknownCommits ? 'upstream' : undefined;
}
function getBaseShadowOutType(): CommitStatus | undefined {
Expand All @@ -85,7 +78,8 @@
function getBaseRemoteOutType(): CommitStatus | undefined {
if (isRebased) return;
if (firstCommit && firstCommit.status !== 'local') return firstCommit.status;
if (hasIntegratedCommits) return 'integrated';
if (hasShadowedCommits || hasRemoteCommits) return 'remote';
if (hasUnknownCommits) return 'upstream';
}
Expand Down Expand Up @@ -163,7 +157,7 @@
<CommitLines
{isRebased}
{hasLocalColumn}
localIn={'local'}
localIn={idx !== $localCommits.length - 1 ? 'local' : undefined}
localOut={'local'}
author={commit.author}
sectionFirst={idx === 0}
Expand Down
15 changes: 11 additions & 4 deletions app/src/lib/components/LocalLine.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
{#if outType}
<div
class="local-line tip"
class:first={sectionFirst}
class:dashed={outDashed}
class:integrated={inType === 'integrated'}
/>
Expand All @@ -24,7 +25,7 @@
<div
class="local-line short"
class:dashed={inDashed}
class:sectionFirst
class:first={sectionFirst}
class:has-root={root}
class:integrated={inType === 'integrated'}
/>
Expand Down Expand Up @@ -62,10 +63,16 @@
bottom: 8px;
}
&.tip {
bottom: calc(100% - var(--avatar-first-top));
bottom: calc(100% - var(--avatar-top) - 4px);
&.first {
bottom: calc(100% - var(--avatar-first-top) - 4px);
}
}
&.short {
top: var(--avatar-first-top);
top: calc(var(--avatar-top) + 4px);
&.first {
top: calc(var(--avatar-first-top) + 4px);
}
}
&.integrated {
background-color: var(--clr-commit-shadow);
Expand All @@ -75,7 +82,7 @@
.root {
position: absolute;
width: 10px;
top: calc(100% - 14px);
top: calc(var(--avatar-top) + 4px);
left: -4px;
bottom: -2px;
border-radius: 0 0 var(--radius-l) 0;
Expand Down

0 comments on commit 0399f98

Please sign in to comment.