33use anyhow:: { Context as _, bail} ;
44use but_core:: ref_metadata:: StackId ;
55
6- use crate :: {
7- CliId , IdMap ,
8- utils:: { Confirm , ConfirmDefault , OutputChannel } ,
9- } ;
6+ use crate :: { CliId , IdMap , utils:: OutputChannel } ;
107
118/// Handle the unapply command.
129///
@@ -20,7 +17,6 @@ pub fn handle(
2017 ctx : & mut but_ctx:: Context ,
2118 out : & mut OutputChannel ,
2219 identifier : & str ,
23- force : bool ,
2420) -> anyhow:: Result < ( ) > {
2521 let mut guard = ctx. exclusive_worktree_access ( ) ;
2622 // Fetch stacks once at the start
@@ -70,14 +66,7 @@ pub fn handle(
7066 ) ;
7167 } ;
7268
73- confirm_and_unapply_stack (
74- ctx,
75- stack_id,
76- & branches,
77- force,
78- out,
79- guard. write_permission ( ) ,
80- )
69+ unapply_stack ( ctx, stack_id, & branches, out, guard. write_permission ( ) )
8170}
8271
8372/// Get branches for a stack by ID, validating the stack exists.
@@ -121,27 +110,15 @@ fn find_stack_by_branch_name(
121110 bail ! ( "Branch '{branch_name}' not found in any applied stack" ) ;
122111}
123112
124- /// Confirm with the user and unapply the stack.
125- fn confirm_and_unapply_stack (
113+ fn unapply_stack (
126114 ctx : & mut but_ctx:: Context ,
127115 sid : StackId ,
128116 branches : & [ String ] ,
129- force : bool ,
130117 out : & mut OutputChannel ,
131118 perm : & mut but_core:: sync:: RepoExclusive ,
132119) -> anyhow:: Result < ( ) > {
133120 let branches_display = branches. join ( ", " ) ;
134121
135- if !force
136- && let Some ( mut inout) = out. prepare_for_terminal_input ( )
137- && inout. confirm (
138- format ! ( "Are you sure you want to unapply stack with branches '{branches_display}'?" ) ,
139- ConfirmDefault :: No ,
140- ) ? == Confirm :: No
141- {
142- bail ! ( "Aborted unapply operation." ) ;
143- }
144-
145122 but_api:: legacy:: virtual_branches:: unapply_stack_with_perm ( ctx, sid, perm) ?;
146123
147124 if let Some ( out) = out. for_human ( ) {
0 commit comments