mirror of
https://github.com/martinvonz/jj.git
synced 2024-11-28 17:41:14 +00:00
branch forget & delete: report if forgot/deleted multiple branches
This commit is contained in:
parent
f6ddd775b9
commit
333c348fb9
2 changed files with 20 additions and 8 deletions
|
@ -272,10 +272,13 @@ fn cmd_branch_delete(
|
|||
let names: BTreeSet<String> = args.names.iter().cloned().chain(globbed_names).collect();
|
||||
let branch_term = make_branch_term(names.iter().collect_vec().as_slice());
|
||||
let mut tx = workspace_command.start_transaction(&format!("delete {branch_term}"));
|
||||
for branch_name in names {
|
||||
tx.mut_repo().remove_local_branch(&branch_name);
|
||||
for branch_name in names.iter() {
|
||||
tx.mut_repo().remove_local_branch(branch_name);
|
||||
}
|
||||
tx.finish(ui)?;
|
||||
if names.len() > 1 {
|
||||
writeln!(ui, "Deleted {} branches.", names.len())?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -295,10 +298,13 @@ fn cmd_branch_forget(
|
|||
let names: BTreeSet<String> = args.names.iter().cloned().chain(globbed_names).collect();
|
||||
let branch_term = make_branch_term(names.iter().collect_vec().as_slice());
|
||||
let mut tx = workspace_command.start_transaction(&format!("forget {branch_term}"));
|
||||
for branch_name in names {
|
||||
tx.mut_repo().remove_branch(&branch_name);
|
||||
for branch_name in names.iter() {
|
||||
tx.mut_repo().remove_branch(branch_name);
|
||||
}
|
||||
tx.finish(ui)?;
|
||||
if names.len() > 1 {
|
||||
writeln!(ui, "Forgot {} branches.", names.len())?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -37,8 +37,10 @@ fn test_branch_multiple_names() {
|
|||
◉ 000000000000
|
||||
"###);
|
||||
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "delete", "foo", "bar"]);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "delete", "foo", "bar", "foo"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
Deleted 2 branches.
|
||||
"###);
|
||||
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
||||
@ 230dd059e1b0
|
||||
◉ 000000000000
|
||||
|
@ -87,7 +89,9 @@ fn test_branch_forget_glob() {
|
|||
◉ 000000000000
|
||||
"###);
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "forget", "--glob", "foo-[1-3]"]);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
Forgot 2 branches.
|
||||
"###);
|
||||
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
||||
@ bar-2 foo-4 230dd059e1b0
|
||||
◉ 000000000000
|
||||
|
@ -161,7 +165,9 @@ fn test_branch_delete_glob() {
|
|||
~
|
||||
"###);
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "delete", "--glob", "foo-[1-3]"]);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
Deleted 2 branches.
|
||||
"###);
|
||||
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
||||
@ bar-2 foo-1@origin foo-3@origin foo-4 6fbf398c2d59
|
||||
│
|
||||
|
|
Loading…
Reference in a new issue