Update commit terminology in frontend

This commit is contained in:
Caleb Owens 2024-06-19 16:33:28 +02:00
parent 28d72ae5c0
commit f869293d1f
14 changed files with 97 additions and 94 deletions

View File

@ -7,7 +7,11 @@
import { getContext, getContextStore } from '$lib/utils/context';
import { intersectionObserver } from '$lib/utils/intersectionObserver';
import { BranchController } from '$lib/vbranches/branchController';
import { getLocalCommits, getRemoteCommits, getUnknownCommits } from '$lib/vbranches/contexts';
import {
getLocalCommits,
getLocalAndRemoteCommits,
getRemoteCommits
} from '$lib/vbranches/contexts';
import { Branch } from '$lib/vbranches/types';
export let isUnapplied: boolean;
@ -22,8 +26,8 @@
});
const localCommits = getLocalCommits();
const remoteCommits = getRemoteCommits();
const unknownCommits = getUnknownCommits();
const remoteCommits = getLocalAndRemoteCommits();
const unknownCommits = getRemoteCommits();
let isLoading: boolean;
let isInViewport = false;

View File

@ -8,11 +8,10 @@
import Resizer from '$lib/shared/Resizer.svelte';
import { getContext, getContextStoreBySymbol, createContextStore } from '$lib/utils/context';
import {
createIntegratedContextStore,
createLocalContextStore,
createRemoteContextStore,
createUnknownCommitsStore,
createUpstreamContextStore
createIntegratedCommitsContextStore,
createLocalCommitsContextStore,
createLocalAndRemoteCommitsContextStore,
createRemoteCommitsContextStore
} from '$lib/vbranches/contexts';
import { FileIdSelection } from '$lib/vbranches/fileIdSelection';
import { Ownership } from '$lib/vbranches/ownership';
@ -33,20 +32,17 @@
const branchStore = createContextStore(Branch, undefined);
$: branchStore.set(branch);
const localCommits = createLocalContextStore(undefined);
const localCommits = createLocalCommitsContextStore(undefined);
$: localCommits.set(branch.localCommits);
const remoteCommits = createRemoteContextStore(undefined);
$: remoteCommits.set(branch.remoteCommits);
const localAndRemoteCommits = createLocalAndRemoteCommitsContextStore(undefined);
$: localAndRemoteCommits.set(branch.remoteCommits);
// Set the store immediately so it can be updated later.
const upstreamCommits = createUpstreamContextStore([]);
$: upstreamCommits.set(branch.upstreamData?.commits ?? []);
const remoteCommits = createRemoteCommitsContextStore([]);
$: allUpstreamCommits = branch.upstreamData?.commits ?? [];
$: remoteCommits.set(allUpstreamCommits.filter((c) => !c.relatedTo));
const unknownCommits = createUnknownCommitsStore([]);
$: unknownCommits.set($upstreamCommits.filter((c) => !c.relatedTo));
const integratedCommits = createIntegratedContextStore([]);
const integratedCommits = createIntegratedCommitsContextStore([]);
$: integratedCommits.set(branch.integratedCommits);
const project = getContext(Project);

View File

@ -16,7 +16,7 @@
<div
class="shadow-marker"
class:first={sectionFirst}
class:upstream={status === 'upstream'}
class:remote={status === 'remote'}
class:integrated={status === 'integrated'}
class:shadow-lane={shadowLane}
use:tooltip={help}
@ -30,8 +30,8 @@
height="100"
class:first={sectionFirst}
class:local={status === 'local'}
class:local-and-remote={status === 'localAndRemote'}
class:remote={status === 'remote'}
class:upstream={status === 'upstream'}
class:integrated={status === 'integrated'}
class:remote-lane={remoteLane}
class:shadow-lane={shadowLane}
@ -53,14 +53,14 @@
&.remote-lane {
left: 4px;
}
&.remote {
&.local-and-remote {
border: 2px solid var(--clr-commit-remote);
left: 4px;
}
&.local {
border: 2px solid var(--clr-commit-local);
}
&.upstream {
&.remote {
border: 2px solid var(--clr-commit-upstream);
}
&.integrated {
@ -92,7 +92,7 @@
left: 8px;
background-color: var(--clr-commit-shadow);
}
&.upstream {
&.remote {
background-color: var(--clr-commit-upstream);
}
}

View File

@ -137,8 +137,8 @@
class:is-first={first}
class:is-last={last}
class:local={type === 'local'}
class:remote={type === 'remote'}
class:upstream={type === 'upstream'}
class:local-and-remote={type === 'localAndRemote'}
class:upstream={type === 'remote'}
class:integrated={type === 'integrated'}
></div>
@ -162,11 +162,11 @@
{#if first}
<div class="commit__type text-semibold text-base-12">
{#if type === 'upstream'}
{#if type === 'remote'}
Remote <Icon name="remote" />
{:else if type === 'local'}
Local <Icon name="local" />
{:else if type === 'remote'}
{:else if type === 'localAndRemote'}
Local and remote
{:else if type === 'integrated'}
Integrated
@ -223,7 +223,7 @@
<span class="commit__subtitle-divider"></span>
<span
>{getTimeAgo(commit.createdAt)}{type === 'remote' || type === 'upstream'
>{getTimeAgo(commit.createdAt)}{type === 'localAndRemote' || type === 'remote'
? ` by ${commit.author.name}`
: ' by you'}</span
>
@ -269,7 +269,7 @@
{/if}
<div class="files-container">
<BranchFilesList {files} {isUnapplied} readonly={type === 'upstream'} />
<BranchFilesList {files} {isUnapplied} readonly={type === 'remote'} />
</div>
{/if}
</div>
@ -338,7 +338,7 @@
&.local {
background-color: var(--clr-commit-local);
}
&.remote {
&.local-and-remote {
background-color: var(--clr-commit-remote);
}
&.upstream {

View File

@ -44,13 +44,13 @@
outDashed={base}
inDashed={base}
>
{#if author && (commitStatus === 'upstream' || relatedToOther)}
{#if author && (commitStatus === 'remote' || relatedToOther)}
<Avatar
{author}
{sectionFirst}
status={shadowIn}
help={shadowHelp || help}
shadow={commitStatus && commitStatus !== 'upstream'}
shadow={commitStatus && commitStatus !== 'remote'}
shadowLane
/>
{/if}

View File

@ -16,8 +16,8 @@
import {
getIntegratedCommits,
getLocalCommits,
getRemoteCommits,
getUnknownCommits
getLocalAndRemoteCommits,
getRemoteCommits
} from '$lib/vbranches/contexts';
import { BaseBranch, Branch, Commit, type CommitStatus } from '$lib/vbranches/types';
import { goto } from '$app/navigation';
@ -26,8 +26,8 @@
const branch = getContextStore(Branch);
const localCommits = getLocalCommits();
const remoteCommits = getRemoteCommits();
const unknownCommits = getUnknownCommits();
const localAndRemoteCommits = getLocalAndRemoteCommits();
const upstreamCommits = getRemoteCommits();
const integratedCommits = getIntegratedCommits();
const baseBranch = getContextStore(BaseBranch);
const project = getContext(Project);
@ -45,14 +45,16 @@
$: hasLocalColumn = $localCommits.length > 0;
$: hasCommits = $branch.commits && $branch.commits.length > 0;
$: headCommit = $branch.commits.at(0);
$: hasLocalCommits = $localCommits.length > 0;
$: hasUnknownCommits = $unknownCommits.length > 0;
$: hasLocalAndRemoteCommits = $localAndRemoteCommits.length > 0;
$: hasRemoteCommits = $upstreamCommits.length > 0;
$: hasIntegratedCommits = $integratedCommits.length > 0;
$: hasRemoteCommits = $remoteCommits.length > 0;
$: hasShadowedCommits = $localCommits.some((c) => c.relatedTo);
$: reorderDropzoneManager = reorderDropzoneManagerFactory.build($branch, [
...$localCommits,
...$remoteCommits
...$localAndRemoteCommits
]);
$: forkPoint = $branch.forkPoint;
@ -64,7 +66,7 @@
function getOutType(commit: Commit): CommitStatus | undefined {
if (!hasShadowedCommits) {
if (!commit.next || commit.next.status === 'local') {
return $unknownCommits.length > 0 ? 'upstream' : undefined;
return $upstreamCommits.length > 0 ? 'remote' : undefined;
}
return commit.next?.status;
}
@ -75,26 +77,26 @@
pointer = pointer.next;
}
if (pointer) return pointer.status;
return hasUnknownCommits ? 'upstream' : undefined;
return hasRemoteCommits ? 'remote' : undefined;
}
function getBaseShadowOutType(): CommitStatus | undefined {
if (!isRebased) return;
if (hasIntegratedCommits) return 'integrated';
if (hasShadowedCommits) return 'remote';
if (hasUnknownCommits) return 'upstream';
if (hasShadowedCommits) return 'localAndRemote';
if (hasRemoteCommits) return 'remote';
}
function getBaseRemoteOutType(): CommitStatus | undefined {
if (isRebased) return;
if (hasIntegratedCommits) return 'integrated';
if (hasShadowedCommits || hasRemoteCommits) return 'remote';
if (hasUnknownCommits) return 'upstream';
if (hasShadowedCommits || hasLocalAndRemoteCommits) return 'localAndRemote';
if (hasRemoteCommits) return 'remote';
}
function getInType(commit: Commit): CommitStatus | undefined {
if (commit.prev) return getOutType(commit.prev || commit);
if (commit.status === 'remote' || commit.relatedTo) return 'remote';
if (commit.status === 'localAndRemote' || commit.relatedTo) return 'localAndRemote';
if (commit.status === 'integrated') return 'integrated';
if (commit) return getOutType(commit);
}
@ -131,18 +133,18 @@
</Dropzone>
{/snippet}
{#if hasCommits || hasUnknownCommits}
{#if hasCommits || hasRemoteCommits}
<div class="commits">
<!-- UPSTREAM COMMITS -->
{#if $unknownCommits.length > 0}
{#each $unknownCommits as commit, idx (commit.id)}
{#if $upstreamCommits.length > 0}
{#each $upstreamCommits as commit, idx (commit.id)}
<CommitCard
type="upstream"
type="remote"
branch={$branch}
{commit}
{isUnapplied}
first={idx === 0}
last={idx === $unknownCommits.length - 1}
last={idx === $upstreamCommits.length - 1}
commitUrl={$baseBranch?.commitUrl(commit.id)}
isHeadCommit={commit.id === headCommit?.id}
>
@ -158,10 +160,10 @@
outDashed={hasLocalColumn}
commitStatus={commit.status}
help={getAvatarTooltip(commit)}
remoteIn={!isRebased ? 'upstream' : undefined}
remoteOut={!isRebased && idx !== 0 ? 'upstream' : undefined}
shadowIn={isRebased ? 'upstream' : undefined}
shadowOut={idx !== 0 && isRebased ? 'upstream' : undefined}
remoteIn={!isRebased ? 'remote' : undefined}
remoteOut={!isRebased && idx !== 0 ? 'remote' : undefined}
shadowIn={isRebased ? 'remote' : undefined}
shadowOut={idx !== 0 && isRebased ? 'remote' : undefined}
/>
</svelte:fragment>
</CommitCard>
@ -203,7 +205,9 @@
shadowOut={isRebased ? getOutType(commit) : undefined}
relatedToOther={commit?.relatedTo && commit.relatedTo.id !== commit.id}
remoteRoot={idx === $localCommits.length - 1}
last={idx === $localCommits.length - 1 && !hasRemoteCommits && !hasIntegratedCommits}
last={idx === $localCommits.length - 1 &&
!hasLocalAndRemoteCommits &&
!hasIntegratedCommits}
/>
</svelte:fragment>
</CommitCard>
@ -211,28 +215,28 @@
{@render reorderDropzone(
reorderDropzoneManager.dropzoneBelowCommit(commit.id),
getReorderDropzoneOffset({
isLast: $remoteCommits.length === 0 && idx + 1 === $localCommits.length,
isMiddle: $remoteCommits.length > 0 && idx + 1 === $localCommits.length
isLast: $localAndRemoteCommits.length === 0 && idx + 1 === $localCommits.length,
isMiddle: $localAndRemoteCommits.length > 0 && idx + 1 === $localCommits.length
})
)}
<InsertEmptyCommitAction
isLast={$remoteCommits.length === 0 && idx + 1 === $localCommits.length}
isMiddle={$remoteCommits.length > 0 && idx + 1 === $localCommits.length}
isLast={$localAndRemoteCommits.length === 0 && idx + 1 === $localCommits.length}
isMiddle={$localAndRemoteCommits.length > 0 && idx + 1 === $localCommits.length}
on:click={() => insertBlankCommit(commit.id, 'below')}
/>
{/each}
{/if}
<!-- REMOTE COMMITS -->
{#if $remoteCommits.length > 0}
{#each $remoteCommits as commit, idx (commit.id)}
<!-- LOCAL AND REMOTE COMMITS -->
{#if $localAndRemoteCommits.length > 0}
{#each $localAndRemoteCommits as commit, idx (commit.id)}
<CommitCard
{commit}
{isUnapplied}
type="remote"
type="localAndRemote"
first={idx === 0}
branch={$branch}
last={idx === $remoteCommits.length - 1}
last={idx === $localAndRemoteCommits.length - 1}
isHeadCommit={commit.id === headCommit?.id}
commitUrl={$baseBranch?.commitUrl(commit.id)}
>
@ -258,11 +262,11 @@
{@render reorderDropzone(
reorderDropzoneManager.dropzoneBelowCommit(commit.id),
getReorderDropzoneOffset({
isLast: idx + 1 === $remoteCommits.length
isLast: idx + 1 === $localAndRemoteCommits.length
})
)}
<InsertEmptyCommitAction
isLast={idx + 1 === $remoteCommits.length}
isLast={idx + 1 === $localAndRemoteCommits.length}
on:click={() => insertBlankCommit(commit.id, 'below')}
/>
{/each}
@ -293,7 +297,7 @@
remoteIn={!isRebased ? getInType(commit) : undefined}
remoteOut={!isRebased ? getOutType(commit) : undefined}
integrated={true}
localRoot={idx === 0 && !hasRemoteCommits && hasLocalCommits}
localRoot={idx === 0 && !hasLocalAndRemoteCommits && hasLocalCommits}
/>
</svelte:fragment>
</CommitCard>
@ -313,7 +317,7 @@
<CommitLines
{hasLocalColumn}
{isRebased}
localRoot={!hasRemoteCommits && !hasIntegratedCommits && hasLocalCommits}
localRoot={!hasLocalAndRemoteCommits && !hasIntegratedCommits && hasLocalCommits}
shadowOut={getBaseShadowOutType()}
remoteOut={getBaseRemoteOutType()}
base

View File

@ -20,7 +20,7 @@
<div
class="remote-line base tip"
class:dashed={outDashed}
class:upstream={outType === 'upstream'}
class:upstream={outType === 'remote'}
></div>
{/if}
{#if root}
@ -47,8 +47,8 @@
<div
class="remote-line tip"
class:integrated
class:upstream={outType === 'upstream'}
class:remote={outType === 'remote'}
class:upstream={outType === 'remote'}
class:remote={outType === 'localAndRemote'}
class:dashed={outDashed}
class:first={sectionFirst}
></div>
@ -58,8 +58,8 @@
class="remote-line short"
class:integrated
class:first={sectionFirst}
class:upstream={inType === 'upstream'}
class:remote={inType === 'remote'}
class:upstream={inType === 'remote'}
class:remote={inType === 'localAndRemote'}
class:dashed={inDashed}
></div>
{/if}

View File

@ -15,13 +15,13 @@
<div
class="shadow-line tip"
class:dashed={outDashed}
class:upstream={outType === 'upstream'}
class:upstream={outType === 'remote'}
></div>
{/if}
{#if inType}
<div
class="shadow-line short"
class:upstream={inType === 'upstream'}
class:upstream={inType === 'remote'}
class:first={sectionFirst}
class:dashed={inDashed}
></div>

View File

@ -62,7 +62,7 @@
last={index === base.upstreamCommits.length - 1}
isUnapplied={true}
commitUrl={base.commitUrl(commit.id)}
type="upstream"
type="remote"
/>
{/each}
</div>
@ -83,7 +83,7 @@
last={index === base.recentCommits.length - 1}
isUnapplied={true}
commitUrl={base.commitUrl(commit.id)}
type="remote"
type="localAndRemote"
/>
{/each}
</div>

View File

@ -71,7 +71,7 @@
last={index === branchData.commits.length - 1}
{commit}
commitUrl={$baseBranch?.commitUrl(commit.id)}
type="remote"
type="localAndRemote"
/>
{/each}
</div>

View File

@ -4,7 +4,7 @@
import LargeDiffMessage from '$lib/shared/LargeDiffMessage.svelte';
import { computeAddedRemovedByHunk } from '$lib/utils/metrics';
import { tooltip } from '$lib/utils/tooltip';
import { getLocalCommits, getRemoteCommits } from '$lib/vbranches/contexts';
import { getLocalCommits, getLocalAndRemoteCommits } from '$lib/vbranches/contexts';
import { getLockText } from '$lib/vbranches/tooltip';
import type { HunkSection, ContentSection } from '$lib/utils/fileSections';
@ -21,7 +21,7 @@
$: minWidth = getGutterMinWidth(maxLineNumber);
const localCommits = isFileLocked ? getLocalCommits() : undefined;
const remoteCommits = isFileLocked ? getRemoteCommits() : undefined;
const remoteCommits = isFileLocked ? getLocalAndRemoteCommits() : undefined;
const commits = isFileLocked ? ($localCommits || []).concat($remoteCommits || []) : undefined;
let alwaysShow = false;

View File

@ -3,7 +3,7 @@
import Icon from '$lib/shared/Icon.svelte';
import { computeFileStatus } from '$lib/utils/fileStatus';
import { tooltip } from '$lib/utils/tooltip';
import { getLocalCommits, getRemoteCommits } from '$lib/vbranches/contexts';
import { getLocalCommits, getLocalAndRemoteCommits } from '$lib/vbranches/contexts';
import { getLockText } from '$lib/vbranches/tooltip';
import { type AnyFile, LocalFile } from '$lib/vbranches/types';
@ -11,7 +11,7 @@
// TODO: Refactor this into something more meaningful.
const localCommits = file instanceof LocalFile ? getLocalCommits() : undefined;
const remoteCommits = file instanceof LocalFile ? getRemoteCommits() : undefined;
const remoteCommits = file instanceof LocalFile ? getLocalAndRemoteCommits() : undefined;
$: lockedIds = file.lockedIds;
$: lockText =

View File

@ -3,16 +3,14 @@ import type { AnyCommit, Commit, RemoteCommit } from './types';
// When we can't use type for context objects we build typed getter/setter pairs
// to avoid using symbols explicitly.
export const [getLocalCommits, createLocalContextStore] =
export const [getLocalCommits, createLocalCommitsContextStore] =
buildContextStore<Commit[]>('localCommits');
export const [getRemoteCommits, createRemoteContextStore] =
export const [getLocalAndRemoteCommits, createLocalAndRemoteCommitsContextStore] =
buildContextStore<Commit[]>('remoteCommits');
export const [getUpstreamCommits, createUpstreamContextStore] =
buildContextStore<RemoteCommit[]>('upstreamCommits');
export const [getIntegratedCommits, createIntegratedContextStore] =
export const [getIntegratedCommits, createIntegratedCommitsContextStore] =
buildContextStore<Commit[]>('integratedCommits');
export const [getUnknownCommits, createUnknownCommitsStore] =
buildContextStore<RemoteCommit[]>('unknownCommits');
export const [getRemoteCommits, createRemoteCommitsContextStore] =
buildContextStore<RemoteCommit[]>('remoteCommits');
export const [getCommitStore, createCommitStore] = buildContextStore<AnyCommit | undefined>(
'commit'
);

View File

@ -136,7 +136,7 @@ export class Branch {
}
get remoteCommits() {
return this.commits.filter((c) => c.status === 'remote');
return this.commits.filter((c) => c.status === 'localAndRemote');
}
get integratedCommits() {
@ -161,7 +161,7 @@ export type ComponentColor =
| 'error'
| 'warning'
| 'purple';
export type CommitStatus = 'local' | 'remote' | 'integrated' | 'upstream';
export type CommitStatus = 'local' | 'localAndRemote' | 'integrated' | 'remote';
export class Commit {
id!: string;
@ -188,7 +188,8 @@ export class Commit {
get status(): CommitStatus {
if (this.isIntegrated) return 'integrated';
if (this.isRemote && (!this.relatedTo || this.id === this.relatedTo.id)) return 'remote';
if (this.isRemote && (!this.relatedTo || this.id === this.relatedTo.id))
return 'localAndRemote';
return 'local';
}
@ -240,7 +241,7 @@ export class RemoteCommit {
}
get status(): CommitStatus {
return 'upstream';
return 'remote';
}
isMergeCommit() {