Skip to content

Commit f1d7d6d

Browse files
committed
components use refname (remote/branch)
Adapt BranchesView.svelte, StackView.svelte, and UnappliedBranchView.svelte to utilize remote/branchName tracking and pass refnames for branch-based selections or change queries. Ensures UI components conform to refname-based API.
1 parent fdacf8f commit f1d7d6d

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

apps/desktop/src/components/BranchesView.svelte

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,11 @@
6767
return createCommitSelection({ commitId: current.commitId, stackId: current.stackId });
6868
}
6969
if (current.branchName) {
70-
const branchName = current.remote
71-
? current.remote + '/' + current.branchName
72-
: current.branchName;
73-
return createBranchSelection({ stackId: current.stackId, branchName });
70+
return createBranchSelection({
71+
stackId: current.stackId,
72+
branchName: current.branchName,
73+
remote: current.remote
74+
});
7475
}
7576
});
7677

apps/desktop/src/components/StackView.svelte

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import { STACK_SERVICE } from '$lib/stacks/stackService.svelte';
3131
import { UI_STATE } from '$lib/state/uiState.svelte';
3232
33+
import { createBranchRef } from '$lib/utils/branch';
3334
import { computeChangeStatus } from '$lib/utils/fileStatus';
3435
import { inject } from '@gitbutler/shared/context';
3536
import { persistWithExpiration } from '@gitbutler/shared/persisted';
@@ -111,7 +112,7 @@
111112
if (commitId) {
112113
return createCommitSelection({ commitId, stackId: stackId });
113114
} else if (branchName) {
114-
return createBranchSelection({ stackId: stackId, branchName });
115+
return createBranchSelection({ stackId: stackId, branchName, remote: undefined });
115116
}
116117
});
117118
@@ -229,7 +230,7 @@
229230
This file is growing complex, and should be simplified where possible. It
230231
is also intentionally intriciate, as it allows us to render the components
231232
in two different configurations.
232-
233+
233234
While tedious to maintain, it is also a good forcing function for making
234235
components that compose better. Be careful when changing, especially since
235236
integration tests only covers the default layout.
@@ -344,7 +345,7 @@
344345
{@const changesResult = stackService.branchChanges({
345346
projectId,
346347
stackId: stackId,
347-
branchName
348+
branch: createBranchRef(branchName, undefined)
348349
})}
349350
<ReduxResult {projectId} {stackId} result={changesResult.current}>
350351
{#snippet children(changes, { projectId, stackId })}
@@ -354,7 +355,7 @@
354355
{stackId}
355356
draggableFiles
356357
autoselect
357-
selectionId={createBranchSelection({ stackId: stackId, branchName })}
358+
selectionId={createBranchSelection({ stackId: stackId, branchName, remote: undefined })}
358359
noshrink={!!previewKey}
359360
ontoggle={() => {
360361
changedFilesCollapsed = !changedFilesCollapsed;

apps/desktop/src/components/UnappliedBranchView.svelte

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import ReduxResult from '$components/ReduxResult.svelte';
88
import { createBranchSelection, type SelectionId } from '$lib/selection/key';
99
import { STACK_SERVICE } from '$lib/stacks/stackService.svelte';
10+
import { createBranchRef } from '$lib/utils/branch';
1011
import { inject } from '@gitbutler/shared/context';
1112
import { Icon, TestId, Tooltip } from '@gitbutler/ui';
1213
@@ -29,12 +30,12 @@
2930
? stackService.branchDetails(projectId, stackId, branchName)
3031
: stackService.unstackedBranchDetails(projectId, branchName, remote)
3132
);
32-
const changesResult = $derived(stackService.branchChanges({ projectId, branchName, remote }));
3333
3434
const selectionId: SelectionId = $derived.by(() => {
35-
const bname = remote ? remote + '/' + branchName : branchName;
36-
return createBranchSelection({ stackId, branchName: bname });
35+
return createBranchSelection({ stackId, branchName, remote });
3736
});
37+
38+
const branchRef = $derived(createBranchRef(branchName, remote));
3839
</script>
3940

4041
<ReduxResult {projectId} result={branchResult.current} {onerror}>
@@ -94,6 +95,7 @@
9495
</div>
9596
</Drawer>
9697

98+
{@const changesResult = stackService.branchChanges({ projectId, branch: branchRef })}
9799
<ReduxResult {projectId} result={changesResult.current}>
98100
{#snippet children(changes, env)}
99101
<ChangedFiles

0 commit comments

Comments
 (0)