Skip to content

Commit

Permalink
Rename branch variables -> stack
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsgrd committed Dec 21, 2024
1 parent 2f82661 commit 857c945
Show file tree
Hide file tree
Showing 16 changed files with 82 additions and 84 deletions.
8 changes: 4 additions & 4 deletions apps/desktop/src/lib/branch/ActiveBranchStatus.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
remoteExists: boolean;
} = $props();
const branch = getContextStore(BranchStack);
const upstreamName = $derived($branch.upstreamName);
const stack = getContextStore(BranchStack);
const upstreamName = $derived($stack.upstreamName);
const forge = getForge();
const forgeBranch = $derived(upstreamName ? $forge?.branch(upstreamName) : undefined);
Expand All @@ -29,7 +29,7 @@
$effect(() => {
nameNormalizationService
.normalize($branch.displayName)
.normalize($stack.displayName)
.then((name) => {
normalizedBranchName = name;
})
Expand Down Expand Up @@ -96,6 +96,6 @@
e.stopPropagation();
}}
>
{isLaneCollapsed ? 'View branch' : $branch.displayName}
{isLaneCollapsed ? 'View branch' : $stack.displayName}
</Button>
{/if}
4 changes: 2 additions & 2 deletions apps/desktop/src/lib/branch/AddSeriesModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
const { parentSeriesName }: Props = $props();
const branchController = getContext(BranchController);
const branch = getContextStore(BranchStack);
const stack = getContextStore(BranchStack);
let createRefModal = $state<ReturnType<typeof Modal>>();
let createRefName: string | undefined = $state();
Expand All @@ -36,7 +36,7 @@
return;
}
branchController.createPatchSeries($branch.id, slugifiedRefName);
branchController.createPatchSeries($stack.id, slugifiedRefName);
createRefModal?.close();
}
Expand Down
34 changes: 17 additions & 17 deletions apps/desktop/src/lib/branch/BranchLaneContextMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@
let allowRebasing = $state<boolean>();
let isDeleting = $state(false);
const branch = $derived($branchStore);
const commits = $derived(branch.validSeries.flatMap((s) => s.patches));
const stack = $derived($branchStore);
const commits = $derived(stack.validSeries.flatMap((s) => s.patches));
$effect(() => {
allowRebasing = branch.allowRebasing;
allowRebasing = stack.allowRebasing;
});
const allPrIds = $derived(branch.validSeries.map((series) => series.prNumber).filter(isDefined));
const allPrIds = $derived(stack.validSeries.map((series) => series.prNumber).filter(isDefined));
async function toggleAllowRebasing() {
branchController.updateBranchAllowRebasing(branch.id, !allowRebasing);
branchController.updateBranchAllowRebasing(stack.id, !allowRebasing);
}
function saveAndUnapply() {
branchController.saveAndUnapply(branch.id);
branchController.saveAndUnapply(stack.id);
}
</script>

Expand All @@ -68,8 +68,8 @@
<ContextMenuItem
label="Unapply"
onclick={async () => {
if (commits.length === 0 && branch.files?.length === 0) {
await branchController.unapplyWithoutSaving(branch.id);
if (commits.length === 0 && stack.files?.length === 0) {
await branchController.unapplyWithoutSaving(stack.id);
} else {
saveAndUnapply();
}
Expand All @@ -81,13 +81,13 @@
label="Unapply and drop changes"
onclick={async () => {
if (
branch.name.toLowerCase().includes('lane') &&
stack.name.toLowerCase().includes('lane') &&
commits.length === 0 &&
branch.files?.length === 0
stack.files?.length === 0
) {
await branchController.unapplyWithoutSaving(branch.id);
await branchController.unapplyWithoutSaving(stack.id);
} else {
deleteBranchModal.show(branch);
deleteBranchModal.show(stack);
}
contextMenuEl?.close();
}}
Expand All @@ -108,15 +108,15 @@
<ContextMenuItem
label={`Create stack to the left`}
onclick={() => {
branchController.createBranch({ order: branch.order });
branchController.createBranch({ order: stack.order });
contextMenuEl?.close();
}}
/>

<ContextMenuItem
label={`Create stack to the right`}
onclick={() => {
branchController.createBranch({ order: branch.order + 1 });
branchController.createBranch({ order: stack.order + 1 });
contextMenuEl?.close();
}}
/>
Expand All @@ -128,8 +128,8 @@
label="Update PR footers"
disabled={allPrIds.length === 0}
onclick={() => {
if ($prService && branch) {
const allPrIds = branch.validSeries.map((series) => series.prNumber).filter(isDefined);
if ($prService && stack) {
const allPrIds = stack.validSeries.map((series) => series.prNumber).filter(isDefined);
updatePrDescriptionTables($prService, allPrIds);
}
contextMenuEl?.close();
Expand All @@ -145,7 +145,7 @@
onSubmit={async (close) => {
try {
isDeleting = true;
await branchController.unapplyWithoutSaving(branch.id);
await branchController.unapplyWithoutSaving(stack.id);
close();
} finally {
isDeleting = false;
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/lib/branch/Dropzones.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import type { Snippet } from 'svelte';
const branchDragActionsFactory = getContext(BranchDragActionsFactory);
const branch = getContextStore(BranchStack);
const stack = getContextStore(BranchStack);
interface Props {
children: Snippet;
Expand All @@ -16,7 +16,7 @@
const { children, type = 'all' }: Props = $props();
const actions = $derived(branchDragActionsFactory.build($branch));
const actions = $derived(branchDragActionsFactory.build($stack));
const commitTypes: Props['type'][] = ['commit', 'all'];
function acceptsCommits(dropData: unknown) {
Expand Down
12 changes: 6 additions & 6 deletions apps/desktop/src/lib/branch/SeriesHeaderContextMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@
aiConfigurationValid = await aiService.validateConfiguration();
}
const branch = $derived($branchStore);
const stack = $derived($branchStore);
export function showSeriesRenameModal(seriesName: string) {
renameSeriesModal.show(branch.validSeries.find((s) => s.name === seriesName));
renameSeriesModal.show(stack.validSeries.find((s) => s.name === seriesName));
}
let isOpenedByMouse = $state(false);
Expand Down Expand Up @@ -152,7 +152,7 @@
<ContextMenuItem
label="Rename"
onclick={async () => {
renameSeriesModal.show(branch);
renameSeriesModal.show(stack);
contextMenuEl?.close();
}}
/>
Expand All @@ -161,7 +161,7 @@
<ContextMenuItem
label="Delete"
onclick={() => {
deleteSeriesModal.show(branch);
deleteSeriesModal.show(stack);
contextMenuEl?.close();
}}
/>
Expand Down Expand Up @@ -212,7 +212,7 @@
bind:this={renameSeriesModal}
onSubmit={(close) => {
if (newHeadName && newHeadName !== headName) {
branchController.updateSeriesName(branch.id, headName, newHeadName);
branchController.updateSeriesName(stack.id, headName, newHeadName);
}
close();
}}
Expand All @@ -239,7 +239,7 @@
onSubmit={async (close) => {
try {
isDeleting = true;
await branchController.removePatchSeries(branch.id, headName);
await branchController.removePatchSeries(stack.id, headName);
close();
} finally {
isDeleting = false;
Expand Down
10 changes: 5 additions & 5 deletions apps/desktop/src/lib/commit/CommitDialog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
const syncedSnapshotService = getContext(SyncedSnapshotService);
const canTakeSnapshot = syncedSnapshotService.canTakeSnapshot;
const selectedOwnership = getContextStore(SelectedOwnership);
const branch = getContextStore(BranchStack);
const stack = getContextStore(BranchStack);
const runCommitHooks = projectRunCommitHooks(projectId);
const commitMessage = persistedCommitMessage(projectId, $branch.id);
const commitMessage = persistedCommitMessage(projectId, $stack.id);
let commitMessageInput = $state<CommitMessageInput>();
let isCommitting = $state(false);
Expand All @@ -43,16 +43,16 @@
isCommitting = true;
try {
await branchController.commitBranch(
$branch.id,
$branch.name,
$stack.id,
$stack.name,
message.trim(),
$selectedOwnership.toString(),
$runCommitHooks
);
$commitMessage = '';
if (commitAndPublish) {
syncedSnapshotService.takeSyncedSnapshot($branch.id);
syncedSnapshotService.takeSyncedSnapshot($stack.id);
}
} finally {
isCommitting = false;
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/lib/commit/CommitDragItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
const { commit, children }: Props = $props();
const branch = maybeGetContextStore(BranchStack);
const stack = maybeGetContextStore(BranchStack);
const actions = $derived<CommitDragActions | undefined>(
$branch && commitDragActionsFactory.build($branch, commit)
$stack && commitDragActionsFactory.build($stack, commit)
);
</script>

Expand Down
10 changes: 5 additions & 5 deletions apps/desktop/src/lib/commit/CommitList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
isBottom = false
}: Props = $props();
const branch = getContextStore(BranchStack);
const stack = getContextStore(BranchStack);
const branchController = getContext(BranchController);
const lineManagerFactory = getContext(LineManagerFactory);
Expand Down Expand Up @@ -104,7 +104,7 @@
async function integrate(strategy?: SeriesIntegrationStrategy): Promise<void> {
isIntegratingCommits = true;
try {
await branchController.integrateUpstreamForSeries($branch.id, currentSeries.name, strategy);
await branchController.integrateUpstreamForSeries($stack.id, currentSeries.name, strategy);
} catch (e) {
console.error(e);
} finally {
Expand Down Expand Up @@ -157,7 +157,7 @@
{#each remoteOnlyPatches as commit, idx (commit.id)}
<CommitCard
type="remote"
branch={$branch}
branch={$stack}
{commit}
{isUnapplied}
{currentSeries}
Expand Down Expand Up @@ -199,7 +199,7 @@
<CommitDragItem {commit}>
<CommitCard
type={commit.status}
branch={$branch}
branch={$stack}
{commit}
{isUnapplied}
{currentSeries}
Expand Down Expand Up @@ -252,7 +252,7 @@
{#each remoteIntegratedPatches as commit, idx (commit.id)}
<CommitCard
type={commit.status}
branch={$branch}
branch={$stack}
{commit}
{currentSeries}
{isUnapplied}
Expand Down
6 changes: 3 additions & 3 deletions apps/desktop/src/lib/commit/CommitMessageInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
const selectedOwnership = getContextStore(SelectedOwnership);
const aiService = getContext(AIService);
const branch = getContextStore(BranchStack);
const stack = getContextStore(BranchStack);
const project = getContext(Project);
const promptService = getContext(PromptService);
Expand Down Expand Up @@ -72,7 +72,7 @@
async function getDiffInput(): Promise<DiffInput[]> {
if (!existingCommit) {
return $branch.files.flatMap((f) =>
return $stack.files.flatMap((f) =>
f.hunks
.filter((h) => $selectedOwnership.isSelected(f.id, h.id))
.map((h) => ({
Expand Down Expand Up @@ -105,7 +105,7 @@
useEmojiStyle: $commitGenerationUseEmojis,
useBriefStyle: $commitGenerationExtraConcise,
commitTemplate: prompt,
branchName: $branch.series[0]?.name,
branchName: $stack.series[0]?.name,
onToken: (t) => {
if (firstToken) {
commitMessage = '';
Expand Down
6 changes: 3 additions & 3 deletions apps/desktop/src/lib/file/FileListItemWrapper.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
const { file, isUnapplied, selected, showCheckbox, readonly, onclick, onkeydown }: Props =
$props();
const branch = maybeGetContextStore(VirtualBranch);
const branchId = $derived($branch?.id);
const stack = maybeGetContextStore(BranchStack);
const branchId = $derived($stack?.id);
const selectedOwnership: Writable<SelectedOwnership> | undefined =
maybeGetContextStore(SelectedOwnership);
const fileIdSelection = getContext(FileIdSelection);
Expand Down Expand Up @@ -100,7 +100,7 @@
bind:this={contextMenu}
trigger={draggableEl}
{isUnapplied}
branchId={$branch?.id}
branchId={$stack?.id}
isBinary={file.binary}
/>

Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/lib/hunk/HunkViewer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
const selectedOwnership: Writable<SelectedOwnership> | undefined =
maybeGetContextStore(SelectedOwnership);
const userSettings = getContextStoreBySymbol<Settings>(SETTINGS);
const branch = maybeGetContextStore(BranchStack);
const stack = maybeGetContextStore(BranchStack);
const project = getContext(Project);
let alwaysShow = $state(false);
Expand Down Expand Up @@ -78,7 +78,7 @@
class:opacity-60={section.hunk.locked && !isFileLocked}
oncontextmenu={(e) => e.preventDefault()}
use:draggableElement={{
data: new HunkDropData($branch?.id || '', section.hunk, section.hunk.lockedTo, commitId),
data: new HunkDropData($stack?.id || '', section.hunk, section.hunk.lockedTo, commitId),
disabled: draggingDisabled
}}
>
Expand Down
Loading

0 comments on commit 857c945

Please sign in to comment.