Skip to content

Commit 08d2fee

Browse files
authored
Merge pull request #13662 from gitbutlerapp/kv-branch-114
remove legacy branch splitting API and implementation
2 parents dbcdf42 + 89fc572 commit 08d2fee

9 files changed

Lines changed: 1 addition & 602 deletions

File tree

crates/but-api/src/legacy/workspace.rs

Lines changed: 1 addition & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -8,45 +8,16 @@ use but_workspace::{
88
commit_engine::{self, StackSegmentId},
99
legacy::{StacksFilter, ui::StackEntry},
1010
};
11-
use gitbutler_branch_actions::{BranchManagerExt, update_workspace_commit};
11+
use gitbutler_branch_actions::BranchManagerExt;
1212
use gitbutler_commit::commit_ext::CommitExt;
1313
use gitbutler_oplog::{
1414
OplogExt, SnapshotExt,
1515
entry::{OperationKind, SnapshotDetails},
1616
};
17-
use gitbutler_reference::{LocalRefname, Refname};
1817
use tracing::instrument;
1918

2019
use crate::json::HexHash;
2120

22-
mod json {
23-
use but_workspace::legacy::MoveChangesResult as LegacyMoveChangesResult;
24-
use serde::Serialize;
25-
26-
use crate::json::HexHash;
27-
28-
/// JSON transport type for moving changes between commits.
29-
#[derive(Debug, Serialize)]
30-
#[serde(rename_all = "camelCase")]
31-
pub struct MoveChangesResult {
32-
/// Commits that have been mapped from one thing to another
33-
pub replaced_commits: Vec<(HexHash, HexHash)>,
34-
}
35-
36-
impl From<LegacyMoveChangesResult> for MoveChangesResult {
37-
fn from(value: LegacyMoveChangesResult) -> Self {
38-
let LegacyMoveChangesResult { replaced_commits } = value;
39-
40-
Self {
41-
replaced_commits: replaced_commits
42-
.into_iter()
43-
.map(|(x, y)| (x.into(), y.into()))
44-
.collect(),
45-
}
46-
}
47-
}
48-
}
49-
5021
#[but_api(napi, try_from = but_workspace::ui::RefInfo)]
5122
#[instrument(err(Debug))]
5223
pub fn head_info(ctx: &but_ctx::Context) -> Result<but_workspace::RefInfo> {
@@ -345,75 +316,6 @@ pub fn discard_worktree_changes(
345316
Ok(refused)
346317
}
347318

348-
#[but_api(json::MoveChangesResult)]
349-
#[instrument(err(Debug))]
350-
pub fn split_branch(
351-
ctx: &mut Context,
352-
source_stack_id: StackId,
353-
source_branch_name: String,
354-
new_branch_name: String,
355-
file_changes_to_split_off: Vec<String>,
356-
) -> Result<but_workspace::legacy::MoveChangesResult> {
357-
let mut guard = ctx.exclusive_worktree_access();
358-
let _ = ctx.create_snapshot(
359-
SnapshotDetails::new(OperationKind::SplitBranch),
360-
guard.write_permission(),
361-
);
362-
363-
let (_, move_changes_result) = but_workspace::legacy::split_branch(
364-
ctx,
365-
source_stack_id,
366-
source_branch_name,
367-
new_branch_name.clone(),
368-
&file_changes_to_split_off,
369-
guard.write_permission(),
370-
)?;
371-
372-
// TODO(ctx): remove this, it's done above
373-
update_workspace_commit(ctx, false)?;
374-
375-
let refname = Refname::Local(LocalRefname::new(&new_branch_name, None));
376-
let branch_manager = ctx.branch_manager();
377-
branch_manager.create_virtual_branch_from_branch(&refname, None, guard.write_permission())?;
378-
379-
// TODO(ctx): use new branch creation, which would update the ctx workspace as well.
380-
let meta = ctx.meta()?;
381-
let (repo, mut ws, _) = ctx.workspace_mut_and_db_with_perm(guard.write_permission())?;
382-
ws.refresh_from_head(&repo, &meta)?;
383-
384-
Ok(move_changes_result)
385-
}
386-
387-
#[but_api(json::MoveChangesResult)]
388-
#[instrument(err(Debug))]
389-
pub fn split_branch_into_dependent_branch(
390-
ctx: &mut but_ctx::Context,
391-
source_stack_id: StackId,
392-
source_branch_name: String,
393-
new_branch_name: String,
394-
file_changes_to_split_off: Vec<String>,
395-
) -> Result<but_workspace::legacy::MoveChangesResult> {
396-
let mut guard = ctx.exclusive_worktree_access();
397-
398-
let _ = ctx.create_snapshot(
399-
SnapshotDetails::new(OperationKind::SplitBranch),
400-
guard.write_permission(),
401-
);
402-
403-
let move_changes_result = but_workspace::legacy::split_into_dependent_branch(
404-
ctx,
405-
source_stack_id,
406-
source_branch_name,
407-
new_branch_name.clone(),
408-
&file_changes_to_split_off,
409-
guard.write_permission(),
410-
)?;
411-
412-
update_workspace_commit(ctx, false)?;
413-
414-
Ok(move_changes_result)
415-
}
416-
417319
/// This API allows the user to quickly "stash" a bunch of uncommitted changes - getting them out of the worktree.
418320
/// Unlike the regular stash, the user specifies a new branch where those changes will be 'saved'/committed.
419321
/// Immediately after the changes are committed, the branch is unapplied from the workspace, and the "stash" branch can be re-applied at a later time

crates/but-server/src/lib.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -806,14 +806,6 @@ pub async fn run(config: Config) -> anyhow::Result<()> {
806806
"/discard_worktree_changes",
807807
but_post(legacy::workspace::discard_worktree_changes_cmd),
808808
)
809-
.route(
810-
"/split_branch",
811-
but_post(legacy::workspace::split_branch_cmd),
812-
)
813-
.route(
814-
"/split_branch_into_dependent_branch",
815-
but_post(legacy::workspace::split_branch_into_dependent_branch_cmd),
816-
)
817809
.route(
818810
"/stash_into_branch",
819811
but_post(legacy::workspace::stash_into_branch_cmd),

crates/but-workspace/src/legacy/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,11 @@ pub use head::{
1717
merge_worktree_with_workspace, remerged_workspace_commit_v2, remerged_workspace_tree_v2,
1818
};
1919

20-
pub mod tree_manipulation;
2120
// TODO: _v3 versions are specifically for the UI, so import them into `ui` instead.
2221
#[expect(deprecated, reason = "re-exports stacks_v3 and stack_details_v3")]
2322
pub use stacks::{
2423
local_and_remote_commits, stack_branches, stack_details_v3, stack_heads_info, stacks_v3,
2524
};
26-
pub use tree_manipulation::{
27-
MoveChangesResult,
28-
split_branch::{split_branch, split_into_dependent_branch},
29-
};
3025

3126
/// Various types for the frontend.
3227
pub mod ui;

crates/but-workspace/src/legacy/tree_manipulation/mod.rs

Lines changed: 0 additions & 16 deletions
This file was deleted.

crates/but-workspace/src/legacy/tree_manipulation/remove_changes_from_commit_in_stack.rs

Lines changed: 0 additions & 99 deletions
This file was deleted.

0 commit comments

Comments
 (0)