Switch to new style of upstream commit list

- this work was left uncompleted a month back
This commit is contained in:
Mattias Granlund 2024-03-13 19:35:09 +01:00 committed by GitButler
parent 4d6b1daafb
commit 82650a5500
4 changed files with 48 additions and 46 deletions

View File

@ -6,7 +6,6 @@
import DropzoneOverlay from './DropzoneOverlay.svelte'; import DropzoneOverlay from './DropzoneOverlay.svelte';
import PullRequestCard from './PullRequestCard.svelte'; import PullRequestCard from './PullRequestCard.svelte';
import ScrollableContainer from './ScrollableContainer.svelte'; import ScrollableContainer from './ScrollableContainer.svelte';
import UpstreamCommits from './UpstreamCommits.svelte';
import { ButlerAIProvider } from '$lib/backend/aiProviders'; import { ButlerAIProvider } from '$lib/backend/aiProviders';
import { Summarizer } from '$lib/backend/summarizer'; import { Summarizer } from '$lib/backend/summarizer';
import ImgThemed from '$lib/components/ImgThemed.svelte'; import ImgThemed from '$lib/components/ImgThemed.svelte';
@ -38,13 +37,7 @@
import type { GitHubService } from '$lib/github/service'; import type { GitHubService } from '$lib/github/service';
import type { Persisted } from '$lib/persisted/persisted'; import type { Persisted } from '$lib/persisted/persisted';
import type { BranchController } from '$lib/vbranches/branchController'; import type { BranchController } from '$lib/vbranches/branchController';
import type { import type { BaseBranch, Branch, LocalFile, RemoteBranchData } from '$lib/vbranches/types';
BaseBranch,
Branch,
LocalFile,
RemoteBranchData,
RemoteCommit
} from '$lib/vbranches/types';
export let branch: Branch; export let branch: Branch;
export let isUnapplied = false; export let isUnapplied = false;
@ -74,18 +67,14 @@
const newVbranchNameRegex = /^virtual\sbranch\s*[\d]*$/; const newVbranchNameRegex = /^virtual\sbranch\s*[\d]*$/;
let laneWidth: number; let laneWidth: number;
let upstreamData: RemoteBranchData | undefined; let remoteBranchData: RemoteBranchData | undefined;
let unknownCommits: RemoteCommit[] | undefined;
$: upstream = branch.upstream; $: upstream = branch.upstream;
$: if (upstream) reloadUpstream(); $: if (upstream) reloadRemoteBranch();
async function reloadUpstream() { async function reloadRemoteBranch() {
if (upstream?.name) { if (upstream?.name) {
upstreamData = await getRemoteBranchData(project.id, upstream.name); remoteBranchData = await getRemoteBranchData(project.id, upstream.name);
unknownCommits = upstreamData.commits.filter(
(remoteCommit) => !branch.commits.find((commit) => remoteCommit.id == commit.id)
);
} }
} }
@ -229,18 +218,6 @@
{isUnapplied} {isUnapplied}
isLaneCollapsed={$isLaneCollapsed} isLaneCollapsed={$isLaneCollapsed}
/> />
{#if unknownCommits && unknownCommits.length > 0 && !branch.conflicted}
<UpstreamCommits
upstream={upstreamData}
branchId={branch.id}
{project}
{branchController}
{branchCount}
projectId={project.id}
{selectedFiles}
{base}
/>
{/if}
<!-- DROPZONES --> <!-- DROPZONES -->
<DropzoneOverlay class="cherrypick-dz-marker" label="Apply here" /> <DropzoneOverlay class="cherrypick-dz-marker" label="Apply here" />
<DropzoneOverlay class="cherrypick-dz-marker" label="Apply here" /> <DropzoneOverlay class="cherrypick-dz-marker" label="Apply here" />
@ -364,6 +341,7 @@
{branchCount} {branchCount}
{isUnapplied} {isUnapplied}
{selectedFiles} {selectedFiles}
{remoteBranchData}
/> />
</div> </div>
</ScrollableContainer> </ScrollableContainer>

View File

@ -4,7 +4,7 @@
import type { BranchService } from '$lib/branches/service'; import type { BranchService } from '$lib/branches/service';
import type { GitHubService } from '$lib/github/service'; import type { GitHubService } from '$lib/github/service';
import type { BranchController } from '$lib/vbranches/branchController'; import type { BranchController } from '$lib/vbranches/branchController';
import type { BaseBranch, Branch, AnyFile } from '$lib/vbranches/types'; import type { BaseBranch, Branch, AnyFile, RemoteBranchData } from '$lib/vbranches/types';
import type { Writable } from 'svelte/store'; import type { Writable } from 'svelte/store';
export let project: Project; export let project: Project;
@ -16,9 +16,15 @@
export let selectedFiles: Writable<AnyFile[]>; export let selectedFiles: Writable<AnyFile[]>;
export let isUnapplied: boolean; export let isUnapplied: boolean;
export let branchCount: number; export let branchCount: number;
export let remoteBranchData: RemoteBranchData | undefined;
$: unknownCommits = remoteBranchData?.commits.filter(
(remoteCommit) => !branch.commits.find((commit) => remoteCommit.id == commit.id)
);
</script> </script>
<CommitList {#if unknownCommits && unknownCommits.length > 0}
<CommitList
{branch} {branch}
{base} {base}
{project} {project}
@ -28,8 +34,10 @@
{githubService} {githubService}
{isUnapplied} {isUnapplied}
{selectedFiles} {selectedFiles}
commits={unknownCommits}
type="upstream" type="upstream"
/> />
{/if}
<CommitList <CommitList
{branch} {branch}
{base} {base}
@ -39,6 +47,7 @@
{githubService} {githubService}
{isUnapplied} {isUnapplied}
{selectedFiles} {selectedFiles}
commits={branch.commits.filter((c) => c.status == 'local')}
type="local" type="local"
/> />
<CommitList <CommitList
@ -51,6 +60,7 @@
{isUnapplied} {isUnapplied}
{selectedFiles} {selectedFiles}
type="remote" type="remote"
commits={branch.commits.filter((c) => c.status == 'remote')}
/> />
<CommitList <CommitList
{branch} {branch}
@ -62,4 +72,5 @@
{isUnapplied} {isUnapplied}
{selectedFiles} {selectedFiles}
type="integrated" type="integrated"
commits={branch.commits.filter((c) => c.status == 'integrated')}
/> />

View File

@ -6,7 +6,14 @@
import type { BranchService } from '$lib/branches/service'; import type { BranchService } from '$lib/branches/service';
import type { GitHubService } from '$lib/github/service'; import type { GitHubService } from '$lib/github/service';
import type { BranchController } from '$lib/vbranches/branchController'; import type { BranchController } from '$lib/vbranches/branchController';
import type { AnyFile, BaseBranch, Branch, CommitStatus } from '$lib/vbranches/types'; import type {
AnyFile,
BaseBranch,
Branch,
Commit,
CommitStatus,
RemoteCommit
} from '$lib/vbranches/types';
import type { Writable } from 'svelte/store'; import type { Writable } from 'svelte/store';
export let branch: Branch; export let branch: Branch;
@ -19,12 +26,12 @@
export let selectedFiles: Writable<AnyFile[]>; export let selectedFiles: Writable<AnyFile[]>;
export let isUnapplied: boolean; export let isUnapplied: boolean;
export let branchCount: number = 0; export let branchCount: number = 0;
export let commits: Commit[] | RemoteCommit[];
let headerHeight: number; let headerHeight: number;
$: headCommit = branch.commits[0]; $: headCommit = branch.commits[0];
$: commits = type == 'upstream' ? [] : branch.commits.filter((c) => c.status == type);
$: hasCommits = commits && commits.length > 0; $: hasCommits = commits && commits.length > 0;
$: remoteRequiresForcePush = type === 'remote' && branch.requiresForce; $: remoteRequiresForcePush = type === 'remote' && branch.requiresForce;
@ -33,7 +40,13 @@
{#if hasCommits || remoteRequiresForcePush} {#if hasCommits || remoteRequiresForcePush}
<div class="commit-list card" class:upstream={type == 'upstream'}> <div class="commit-list card" class:upstream={type == 'upstream'}>
<CommitListHeader {type} bind:expanded bind:height={headerHeight} isExpandable={hasCommits} /> <CommitListHeader
{type}
bind:expanded
bind:height={headerHeight}
isExpandable={hasCommits}
commitCount={commits.length}
/>
{#if expanded} {#if expanded}
<div class="commit-list__content"> <div class="commit-list__content">
{#if hasCommits} {#if hasCommits}

View File

@ -7,7 +7,7 @@
export let expanded: boolean; export let expanded: boolean;
export let type: CommitStatus; export let type: CommitStatus;
export let height: number | undefined; export let height: number | undefined;
export let upstreamCommitCount = 0; export let commitCount = 0;
let element: HTMLButtonElement | undefined = undefined; let element: HTMLButtonElement | undefined = undefined;
@ -23,7 +23,7 @@
{:else if type == 'integrated'} {:else if type == 'integrated'}
Integrated Integrated
{:else if type == 'upstream'} {:else if type == 'upstream'}
{upstreamCommitCount} upstream {upstreamCommitCount == 1 ? 'commit' : 'commits'} {commitCount} upstream {commitCount == 1 ? 'commit' : 'commits'}
<Icon name="warning" color="warn" /> <Icon name="warning" color="warn" />
{/if} {/if}
</div> </div>