Skip to content

Commit

Permalink
Rename PatchSeries -> Branch
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsgrd committed Nov 8, 2024
1 parent 0bd3f6d commit bc1ad81
Show file tree
Hide file tree
Showing 20 changed files with 72 additions and 72 deletions.
4 changes: 2 additions & 2 deletions apps/desktop/src/lib/branch/BranchLaneContextMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
allowRebasing = stack.allowRebasing;
});
const allPrIds = $derived(stack.series.map((series) => series.prNumber).filter(isDefined));
const allPrIds = $derived(stack.branches.map((series) => series.prNumber).filter(isDefined));
async function toggleAllowRebasing() {
branchController.updateBranchAllowRebasing(stack.id, !allowRebasing);
Expand Down Expand Up @@ -129,7 +129,7 @@
disabled={allPrIds.length === 0}
onclick={() => {
if ($prService && stack) {
const allPrIds = stack.series.map((series) => series.prNumber).filter(isDefined);
const allPrIds = stack.branches.map((series) => series.prNumber).filter(isDefined);
updatePrDescriptionTables($prService, allPrIds);
}
contextMenuEl?.close();
Expand Down
8 changes: 4 additions & 4 deletions apps/desktop/src/lib/branch/SeriesHeader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import { openExternalUrl } from '$lib/utils/url';
import { BranchController } from '$lib/vbranches/branchController';
import { listCommitFiles } from '$lib/vbranches/remoteCommits';
import { PatchSeries, BranchStack, type CommitStatus } from '$lib/vbranches/types';
import { Branch, BranchStack, type CommitStatus } from '$lib/vbranches/types';
import { CloudBranchesService } from '@gitbutler/shared/cloud/stacks/service';
import { getContext, getContextStore } from '@gitbutler/shared/context';
import Button from '@gitbutler/ui/Button.svelte';
Expand All @@ -33,7 +33,7 @@
import { tick } from 'svelte';
interface Props {
currentSeries: PatchSeries;
currentSeries: Branch;
isTopSeries: boolean;
}
Expand Down Expand Up @@ -195,7 +195,7 @@
bind:contextMenuEl={kebabContextMenu}
target={kebabContextMenuTrigger}
headName={currentSeries.name}
seriesCount={stack.series?.length ?? 0}
seriesCount={stack.branches?.length ?? 0}
{toggleDescription}
description={currentSeries.description ?? ''}
onGenerateBranchName={generateBranchName}
Expand Down Expand Up @@ -247,7 +247,7 @@
icon={branchType === 'integrated' ? 'tick-small' : 'branch-small'}
iconColor="var(--clr-core-ntrl-100)"
color={lineColor}
lineBottom={currentSeries.patches.length > 0 || stack.series.length > 1}
lineBottom={currentSeries.patches.length > 0 || stack.branches.length > 1}
/>
<div class="branch-info__content">
<div class="text-14 text-bold branch-info__name">
Expand Down
20 changes: 10 additions & 10 deletions apps/desktop/src/lib/dragging/stackingReorderDropzoneManager.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { DraggableCommit } from '$lib/dragging/draggables';
import type { BranchController } from '$lib/vbranches/branchController';
import type { BranchStack, PatchSeries, StackOrder } from '$lib/vbranches/types';
import type { BranchStack, Branch, StackOrder } from '$lib/vbranches/types';

export class StackingReorderDropzone {
constructor(
private branchId: string,
private branchController: BranchController,
private currentSeries: PatchSeries,
private series: PatchSeries[],
private currentSeries: Branch,
private series: Branch[],
public commitId: string
) {}

Expand Down Expand Up @@ -44,14 +44,14 @@ export class StackingReorderDropzone {
}

export class StackingReorderDropzoneManager {
public series: Map<string, PatchSeries>;
public series: Map<string, Branch>;

constructor(
private branchController: BranchController,
private branch: BranchStack
) {
const seriesMap = new Map();
this.branch.series.forEach((series) => {
this.branch.branches.forEach((series) => {
seriesMap.set(series.name, series);
});
this.series = seriesMap;
Expand All @@ -67,7 +67,7 @@ export class StackingReorderDropzoneManager {
this.branch.id,
this.branchController,
currentSeries,
this.branch.series,
this.branch.branches,
'top'
);
}
Expand All @@ -82,7 +82,7 @@ export class StackingReorderDropzoneManager {
this.branch.id,
this.branchController,
currentSeries,
this.branch.series,
this.branch.branches,
commitId
);
}
Expand All @@ -97,8 +97,8 @@ export class StackingReorderDropzoneManagerFactory {
}

export function buildNewStackOrder(
allSeries: PatchSeries[],
currentSeries: PatchSeries,
allSeries: Branch[],
currentSeries: Branch,
actorCommitId: string,
targetCommitId: string
): StackOrder | undefined {
Expand Down Expand Up @@ -143,7 +143,7 @@ export function buildNewStackOrder(
}

function distanceBetweenDropzones(
allSeries: PatchSeries[],
allSeries: Branch[],
actorDropzoneId: string,
targetDropzoneId: string
) {
Expand Down
6 changes: 3 additions & 3 deletions apps/desktop/src/lib/pr/PrDetailsModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import { error } from '$lib/utils/toasts';
import { openExternalUrl } from '$lib/utils/url';
import { BranchController } from '$lib/vbranches/branchController';
import { PatchSeries, BranchStack } from '$lib/vbranches/types';
import { Branch, BranchStack } from '$lib/vbranches/types';
import { getContext, getContextStore } from '@gitbutler/shared/context';
import { persisted } from '@gitbutler/shared/persisted';
import Button from '@gitbutler/ui/Button.svelte';
Expand All @@ -58,7 +58,7 @@
interface PreviewSeriesProps {
type: 'preview-series';
currentSeries: PatchSeries;
currentSeries: Branch;
stackId: string;
}
Expand Down Expand Up @@ -207,7 +207,7 @@
}
// All ids that existed prior to creating a new one (including archived).
const priorIds = stack.series.map((series) => series.prNumber).filter(isDefined);
const priorIds = stack.branches.map((series) => series.prNumber).filter(isDefined);
const pr = await $prService.createPr({
title: params.title,
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/lib/stack/CollapsedLane.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
const stackStore = getContextStore(BranchStack);
const stack = $derived($stackStore);
const nonArchivedSeries = $derived(stack.series.filter((s) => !s.archived));
const nonArchivedSeries = $derived(stack.branches.filter((s) => !s.archived));
function expandLane() {
$isLaneCollapsed = false;
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/lib/stack/CurrentSeries.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import { getForgeListingService } from '$lib/forge/interface/forgeListingService';
import { createForgePrMonitorStore } from '$lib/forge/interface/forgePrMonitor';
import { getForgePrService } from '$lib/forge/interface/forgePrService';
import type { PatchSeries } from '$lib/vbranches/types';
import type { Branch } from '$lib/vbranches/types';
import type { Snippet } from 'svelte';
interface Props {
currentSeries: PatchSeries;
currentSeries: Branch;
children: Snippet;
}
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/lib/stack/SeriesDividerLine.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script lang="ts">
import { getColorFromBranchType } from '$lib/branch/stackingUtils';
import type { CommitStatus, PatchSeries } from '$lib/vbranches/types';
import type { CommitStatus, Branch } from '$lib/vbranches/types';
interface Props {
currentSeries: PatchSeries;
currentSeries: Branch;
}
const { currentSeries }: Props = $props();
Expand Down
10 changes: 5 additions & 5 deletions apps/desktop/src/lib/stack/SeriesList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import CardOverlay from '$lib/dropzone/CardOverlay.svelte';
import Dropzone from '$lib/dropzone/Dropzone.svelte';
import { BranchController } from '$lib/vbranches/branchController';
import { PatchSeries, type BranchStack } from '$lib/vbranches/types';
import { Branch, type BranchStack } from '$lib/vbranches/types';
import { getContext } from '@gitbutler/shared/context';
import EmptyStatePlaceholder from '@gitbutler/ui/EmptyStatePlaceholder.svelte';
Expand All @@ -23,10 +23,10 @@
const branchController = getContext(BranchController);
const hasConflicts = $derived(
branch.series.flatMap((s) => s.patches).some((patch) => patch.conflicted)
branch.branches.flatMap((s) => s.patches).some((patch) => patch.conflicted)
);
const nonArchivedSeries = $derived(branch.series.filter((s) => !s.archived));
const nonArchivedSeries = $derived(branch.branches.filter((s) => !s.archived));
const stackingReorderDropzoneManagerFactory = getContext(StackingReorderDropzoneManagerFactory);
const stackingReorderDropzoneManager = $derived(
Expand All @@ -40,7 +40,7 @@
return true;
}
function onDrop(data: DraggableCommit, allSeries: PatchSeries[], currentSeries: PatchSeries) {
function onDrop(data: DraggableCommit, allSeries: Branch[], currentSeries: Branch) {
if (!(data instanceof DraggableCommit)) return;
const stackOrder = buildNewStackOrder(allSeries, currentSeries, data.commit.id, 'top');
Expand Down Expand Up @@ -83,7 +83,7 @@
patches={currentSeries.patches}
seriesName={currentSeries.name}
isUnapplied={false}
isBottom={idx === branch.series.length - 1}
isBottom={idx === branch.branches.length - 1}
{stackingReorderDropzoneManager}
{hasConflicts}
/>
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/lib/stack/Stack.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
const upstreamPatches: DetailedCommit[] = [];
const branchPatches: DetailedCommit[] = [];
stack.series.map((series) => {
stack.branches.map((series) => {
upstreamPatches.push(...series.upstreamPatches);
branchPatches.push(...series.patches);
hasConflicts = branchPatches.some((patch) => patch.conflicted);
Expand Down Expand Up @@ -223,7 +223,7 @@
: undefined}
onclick={push}
>
{stack.requiresForce ? 'Force push' : stack.series.length > 1 ? 'Push All' : 'Push'}
{stack.requiresForce ? 'Force push' : stack.branches.length > 1 ? 'Push All' : 'Push'}
</Button>
</div>
{/if}
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/lib/stack/header/HeaderMetaSection.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import SeriesRowLabels from './SeriesLabels.svelte';
import BranchLaneContextMenu from '$lib/branch/BranchLaneContextMenu.svelte';
import ContextMenu from '$lib/components/contextmenu/ContextMenu.svelte';
import { PatchSeries } from '$lib/vbranches/types';
import { Branch } from '$lib/vbranches/types';
import Button from '@gitbutler/ui/Button.svelte';
interface Props {
series: PatchSeries[];
series: Branch[];
onCollapseButtonClick: () => void;
}
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/lib/stack/header/SeriesLabels.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script lang="ts">
import Select from '$lib/select/Select.svelte';
import { PatchSeries } from '$lib/vbranches/types';
import { Branch } from '$lib/vbranches/types';
import Icon from '@gitbutler/ui/Icon.svelte';
import SeriesLabelsRow from '@gitbutler/ui/SeriesLabelsRow.svelte';
interface Props {
series: PatchSeries[];
series: Branch[];
disableSelector?: boolean;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/lib/stack/header/StackHeader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
const { onCollapseButtonClick, branch }: Props = $props();
const nonArchivedSeries = $derived(branch.series.filter((s) => !s.archived));
const nonArchivedSeries = $derived(branch.branches.filter((s) => !s.archived));
</script>

<div class="stack-header">
Expand Down
6 changes: 3 additions & 3 deletions apps/desktop/src/lib/vbranches/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ export class BranchStack {
tree!: string;

// Used in the stacking context where VirtualBranch === Stack
@Type(() => PatchSeries)
series!: PatchSeries[];
@Type(() => Branch)
branches!: Branch[];

get localCommits() {
return this.commits.filter((c) => c.status === 'local');
Expand Down Expand Up @@ -424,7 +424,7 @@ export interface BranchPushResult {
remote: string;
}

export class PatchSeries {
export class Branch {
name!: string;
description?: string;
upstreamReference?: string;
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/lib/vbranches/virtualBranch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class VirtualBranchService {
try {
const data = await this.remoteBranchService.getRemoteBranchData(upstreamName);
const upstreamCommits = data.commits;
const stackedCommits = b.series.flatMap((series) => series.patches);
const stackedCommits = b.branches.flatMap((series) => series.patches);

upstreamCommits.forEach((uc) => {
const match = b.commits.find((c) => commitCompare(uc, c));
Expand Down Expand Up @@ -115,7 +115,7 @@ export class VirtualBranchService {
this.projectMetrics.setMetric('virtual_branch_count', branches.length);
this.projectMetrics.setMetric(
'max_stack_count',
Math.max(...branches.map((b) => b.series.length))
Math.max(...branches.map((b) => b.branches.length))
);
} catch (err: unknown) {
console.error(err);
Expand Down
Loading

0 comments on commit bc1ad81

Please sign in to comment.