Skip to content

Commit dbcdf42

Browse files
authored
Merge pull request #13661 from gitbutlerapp/ui-hide-split
UI: Remove the split branch options
2 parents 1f3e463 + 1c3c6fd commit dbcdf42

4 files changed

Lines changed: 1 addition & 211 deletions

File tree

apps/desktop/src/components/shared/ChangedFilesContextMenu.svelte

Lines changed: 0 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<!-- This is a V3 replacement for `FileContextMenu.svelte` -->
22
<script lang="ts">
3-
import ReduxResult from "$components/shared/ReduxResult.svelte";
43
import AbsorbPlanModal from "$components/stack/AbsorbPlanModal.svelte";
54
import DiscardChangesModal from "$components/workspace/DiscardChangesModal.svelte";
65
import StashIntoBranchModal from "$components/workspace/StashIntoBranchModal.svelte";
@@ -81,16 +80,9 @@
8180
const clipboardService = inject(CLIPBOARD_SERVICE);
8281
const backend = inject(BACKEND);
8382
const [, absorbingChanges] = stackService.absorb;
84-
const [splitOffChanges] = stackService.splitBranch;
85-
const [splitBranchIntoDependentBranch] = stackService.splitBranchIntoDependentBranch;
86-
8783
const projectService = inject(PROJECTS_SERVICE);
8884
8985
const isUncommitted = $derived(selectionId.type === "worktree");
90-
const isBranchFiles = $derived(selectionId.type === "branch");
91-
const selectionBranchName = $derived(
92-
selectionId.type === "branch" ? selectionId.branchName : undefined,
93-
);
9486
9587
// Platform-specific label for "Show in Finder/Explorer/File Manager"
9688
const showInFolderLabel = (() => {
@@ -165,91 +157,6 @@
165157
}
166158
});
167159
}
168-
169-
async function split(changes: TreeChange[]) {
170-
if (!stackId) {
171-
chipToasts.error("No stack selected to split off changes.");
172-
return;
173-
}
174-
175-
if (selectionId.type !== "branch") {
176-
chipToasts.error("Please select a branch to split off changes.");
177-
return;
178-
}
179-
180-
const branchName = selectionId.branchName;
181-
182-
const fileNames = changes.map((change) => change.path);
183-
184-
try {
185-
await chipToasts.promise(
186-
(async () => {
187-
const newBranchName = await stackService.fetchNewBranchName(projectId);
188-
189-
if (!newBranchName) {
190-
throw new Error("Failed to generate a new branch name.");
191-
}
192-
193-
await splitOffChanges({
194-
projectId,
195-
sourceStackId: stackId,
196-
sourceBranchName: branchName,
197-
fileChangesToSplitOff: fileNames,
198-
newBranchName: newBranchName,
199-
});
200-
})(),
201-
{
202-
loading: "Splitting off changes",
203-
success: "Changes split off into a new branch",
204-
error: "Failed to split off changes",
205-
},
206-
);
207-
} catch (error) {
208-
console.error("Failed to split off changes:", error);
209-
}
210-
}
211-
212-
async function splitIntoDependentBranch(changes: TreeChange[]) {
213-
if (!stackId) {
214-
chipToasts.error("No stack selected to split off changes.");
215-
return;
216-
}
217-
218-
if (selectionId.type !== "branch") {
219-
chipToasts.error("Please select a branch to split off changes.");
220-
return;
221-
}
222-
223-
const branchName = selectionId.branchName;
224-
const fileNames = changes.map((change) => change.path);
225-
226-
try {
227-
await chipToasts.promise(
228-
(async () => {
229-
const newBranchName = await stackService.fetchNewBranchName(projectId);
230-
231-
if (!newBranchName) {
232-
throw new Error("Failed to generate a new branch name.");
233-
}
234-
235-
await splitBranchIntoDependentBranch({
236-
projectId,
237-
sourceStackId: stackId,
238-
sourceBranchName: branchName,
239-
fileChangesToSplitOff: fileNames,
240-
newBranchName: newBranchName,
241-
});
242-
})(),
243-
{
244-
loading: "Splitting into dependent branch",
245-
success: "Changes split into a dependent branch",
246-
error: "Failed to split into dependent branch",
247-
},
248-
);
249-
} catch (error) {
250-
console.error("Failed to split into dependent branch:", error);
251-
}
252-
}
253160
</script>
254161

255162
{#if menuOpen && menuItem}
@@ -309,36 +216,6 @@
309216
onclick={async () => uncommitChanges(stackId, commitId, changes)}
310217
/>
311218
{/if}
312-
313-
{#if isBranchFiles && stackId && selectionBranchName}
314-
{@const branchIsConflicted = stackService.isBranchConflicted(
315-
projectId,
316-
stackId,
317-
selectionBranchName,
318-
)}
319-
<ReduxResult {projectId} result={branchIsConflicted?.result}>
320-
{#snippet children(isConflicted)}
321-
{#if isConflicted === false}
322-
<ContextMenuItem
323-
label="Split off changes"
324-
icon="split"
325-
onclick={() => {
326-
menuOpen = false;
327-
split(changes);
328-
}}
329-
/>
330-
<ContextMenuItem
331-
label="Split into dependent branch"
332-
icon="stack-plus"
333-
onclick={() => {
334-
menuOpen = false;
335-
splitIntoDependentBranch(changes);
336-
}}
337-
/>
338-
{/if}
339-
{/snippet}
340-
</ReduxResult>
341-
{/if}
342219
</ContextMenuSection>
343220
{/if}
344221

apps/desktop/src/lib/dragging/dropHandlers/stackDropHandler.ts

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { unstackPRs, updateStackPrs } from "$lib/forge/shared/prFooter";
1010
import StackMacros from "$lib/stacks/macros";
1111
import { toMoveBranchWarning } from "$lib/stacks/stack";
1212
import { ensureValue } from "$lib/utils/validation";
13-
import { chipToasts } from "@gitbutler/ui";
1413
import type { DropResult } from "$lib/dragging/dropResult";
1514
import type { DropzoneHandler } from "$lib/dragging/handler";
1615
import type { ForgePrService } from "$lib/forge/interface/forgePrService";
@@ -43,6 +42,7 @@ export class OutsideLaneDzHandler implements DropzoneHandler {
4342
private acceptsChangeDropData(data: unknown): data is ChangeDropData {
4443
if (!(data instanceof FileChangeDropData || data instanceof FolderChangeDropData)) return false;
4544
if (data.selectionId.type === "commit" && data.stackId === undefined) return false;
45+
if (data.selectionId.type === "branch") return false;
4646
return true;
4747
}
4848

@@ -71,43 +71,6 @@ export class OutsideLaneDzHandler implements DropzoneHandler {
7171

7272
async ondropChangeData(data: ChangeDropData) {
7373
switch (data.selectionId.type) {
74-
case "branch": {
75-
const newBranchName = await this.stackService.fetchNewBranchName(this.projectId);
76-
77-
if (!newBranchName) {
78-
throw new Error("Failed to generate a new branch name.");
79-
}
80-
81-
if (!data.stackId) {
82-
throw new Error("Change drop data must specify the source stackId");
83-
}
84-
85-
const sourceStackId = data.stackId;
86-
const sourceBranchName = data.selectionId.branchName;
87-
88-
await chipToasts.promise(
89-
(async () => {
90-
const fileNames = await data
91-
.treeChanges()
92-
.then((changes) => changes.map((c) => c.path));
93-
94-
await this.stackService.splitBranchMutation({
95-
projectId: this.projectId,
96-
sourceStackId,
97-
sourceBranchName,
98-
fileChangesToSplitOff: fileNames,
99-
newBranchName: newBranchName,
100-
});
101-
})(),
102-
{
103-
loading: "Splitting branch into a new branch...",
104-
success: "Branch split successfully",
105-
error: "Failed to split branch",
106-
},
107-
);
108-
109-
break;
110-
}
11174
case "commit": {
11275
const { stack, outcome, branchName } = await this.macros.createNewStackAndCommit();
11376

apps/desktop/src/lib/stacks/stackEndpoints.ts

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -904,44 +904,6 @@ export function buildStackEndpoints(build: BackendEndpointBuilder) {
904904
transformResponse: (commits: Commit[]) =>
905905
commitAdapter.addMany(commitAdapter.getInitialState(), commits),
906906
}),
907-
splitBranch: build.mutation<
908-
{ replacedCommits: [string, string][] },
909-
{
910-
projectId: string;
911-
sourceStackId: string;
912-
sourceBranchName: string;
913-
newBranchName: string;
914-
fileChangesToSplitOff: string[];
915-
}
916-
>({
917-
extraOptions: {
918-
command: "split_branch",
919-
},
920-
query: (args) => args,
921-
invalidatesTags: (_result, _error, args) => [
922-
invalidatesList(ReduxTag.HeadSha),
923-
invalidatesItem(ReduxTag.BranchChanges, args.sourceStackId),
924-
],
925-
}),
926-
splitBranchIntoDependentBranch: build.mutation<
927-
{ replacedCommits: [string, string][] },
928-
{
929-
projectId: string;
930-
sourceStackId: string;
931-
sourceBranchName: string;
932-
newBranchName: string;
933-
fileChangesToSplitOff: string[];
934-
}
935-
>({
936-
extraOptions: {
937-
command: "split_branch_into_dependent_branch",
938-
},
939-
query: (args) => args,
940-
invalidatesTags: (_result, _error, args) => [
941-
invalidatesList(ReduxTag.HeadSha),
942-
invalidatesItem(ReduxTag.BranchChanges, args.sourceStackId),
943-
],
944-
}),
945907
createReference: build.mutation<
946908
void,
947909
{ projectId: string; stackId: string; request: CreateRefRequest }

apps/desktop/src/lib/stacks/stackService.svelte.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -841,18 +841,6 @@ export class StackService {
841841
);
842842
}
843843

844-
get splitBranch() {
845-
return this.backendApi.endpoints.splitBranch.useMutation();
846-
}
847-
848-
get splitBranchMutation() {
849-
return this.backendApi.endpoints.splitBranch.mutate;
850-
}
851-
852-
get splitBranchIntoDependentBranch() {
853-
return this.backendApi.endpoints.splitBranchIntoDependentBranch.useMutation();
854-
}
855-
856844
invalidateStacksAndDetails() {
857845
this.dispatch(
858846
this.backendApi.util.invalidateTags([

0 commit comments

Comments
 (0)