@@ -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 ;
1212use gitbutler_commit:: commit_ext:: CommitExt ;
1313use gitbutler_oplog:: {
1414 OplogExt , SnapshotExt ,
1515 entry:: { OperationKind , SnapshotDetails } ,
1616} ;
17- use gitbutler_reference:: { LocalRefname , Refname } ;
1817use tracing:: instrument;
1918
2019use 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 ) ) ]
5223pub 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
0 commit comments