Skip to content

Commit e3540e7

Browse files
authored
Merge pull request #13913 from gitbutlerapp/remove-unapply-prompt
breaking(but): remove confirmation prompt for `but unapply`
2 parents 02f07cc + c438edc commit e3540e7

3 files changed

Lines changed: 5 additions & 31 deletions

File tree

crates/but/src/args/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,9 +1016,6 @@ pub enum Subcommands {
10161016
Unapply {
10171017
/// CLI ID or name of the branch/stack to unapply
10181018
identifier: String,
1019-
/// Force unapply without confirmation
1020-
#[clap(long, short = 'f')]
1021-
force: bool,
10221019
},
10231020

10241021
/// Apply a branch to the workspace.

crates/but/src/command/legacy/unapply.rs

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
use anyhow::{Context as _, bail};
44
use 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() {

crates/but/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,7 @@ async fn match_subcommand(
14481448
.show_root_cause_error_then_exit_without_destructors(output)
14491449
}
14501450
#[cfg(feature = "legacy")]
1451-
Subcommands::Unapply { identifier, force } => {
1451+
Subcommands::Unapply { identifier } => {
14521452
let mut ctx = setup::init_ctx(
14531453
&args,
14541454
InitCtxOptions {
@@ -1457,7 +1457,7 @@ async fn match_subcommand(
14571457
},
14581458
out,
14591459
)?;
1460-
command::legacy::unapply::handle(&mut ctx, out, &identifier, force)
1460+
command::legacy::unapply::handle(&mut ctx, out, &identifier)
14611461
.context("Failed to unapply branch.")
14621462
.emit_metrics(metrics_ctx)
14631463
.show_root_cause_error_then_exit_without_destructors(output)

0 commit comments

Comments
 (0)