forked from mirrors/jj
branch.rs: move find_globs
function out of cmd_branch_forget
This prepares for using it in `cmd_branch_delete`.
This commit is contained in:
parent
144a44914a
commit
97815851f7
1 changed files with 35 additions and 34 deletions
|
@ -201,36 +201,7 @@ fn cmd_branch_set(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cmd_branch_delete(
|
/// This function may return the same branch more than once
|
||||||
ui: &mut Ui,
|
|
||||||
command: &CommandHelper,
|
|
||||||
args: &BranchDeleteArgs,
|
|
||||||
) -> Result<(), CommandError> {
|
|
||||||
let mut workspace_command = command.workspace_helper(ui)?;
|
|
||||||
for branch_name in &args.names {
|
|
||||||
if workspace_command
|
|
||||||
.repo()
|
|
||||||
.view()
|
|
||||||
.get_local_branch(branch_name)
|
|
||||||
.is_none()
|
|
||||||
{
|
|
||||||
return Err(user_error(format!("No such branch: {branch_name}")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let mut tx =
|
|
||||||
workspace_command.start_transaction(&format!("delete {}", make_branch_term(&args.names)));
|
|
||||||
for branch_name in &args.names {
|
|
||||||
tx.mut_repo().remove_local_branch(branch_name);
|
|
||||||
}
|
|
||||||
tx.finish(ui)?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn cmd_branch_forget(
|
|
||||||
ui: &mut Ui,
|
|
||||||
command: &CommandHelper,
|
|
||||||
args: &BranchForgetArgs,
|
|
||||||
) -> Result<(), CommandError> {
|
|
||||||
fn find_globs(view: &View, globs: &[String]) -> Result<Vec<String>, CommandError> {
|
fn find_globs(view: &View, globs: &[String]) -> Result<Vec<String>, CommandError> {
|
||||||
let mut matching_branches: Vec<String> = vec![];
|
let mut matching_branches: Vec<String> = vec![];
|
||||||
let mut failed_globs = vec![];
|
let mut failed_globs = vec![];
|
||||||
|
@ -265,6 +236,36 @@ fn cmd_branch_forget(
|
||||||
Ok(matching_branches)
|
Ok(matching_branches)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn cmd_branch_delete(
|
||||||
|
ui: &mut Ui,
|
||||||
|
command: &CommandHelper,
|
||||||
|
args: &BranchDeleteArgs,
|
||||||
|
) -> Result<(), CommandError> {
|
||||||
|
let mut workspace_command = command.workspace_helper(ui)?;
|
||||||
|
for branch_name in &args.names {
|
||||||
|
if workspace_command
|
||||||
|
.repo()
|
||||||
|
.view()
|
||||||
|
.get_local_branch(branch_name)
|
||||||
|
.is_none()
|
||||||
|
{
|
||||||
|
return Err(user_error(format!("No such branch: {branch_name}")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let mut tx =
|
||||||
|
workspace_command.start_transaction(&format!("delete {}", make_branch_term(&args.names)));
|
||||||
|
for branch_name in &args.names {
|
||||||
|
tx.mut_repo().remove_local_branch(branch_name);
|
||||||
|
}
|
||||||
|
tx.finish(ui)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn cmd_branch_forget(
|
||||||
|
ui: &mut Ui,
|
||||||
|
command: &CommandHelper,
|
||||||
|
args: &BranchForgetArgs,
|
||||||
|
) -> Result<(), CommandError> {
|
||||||
let mut workspace_command = command.workspace_helper(ui)?;
|
let mut workspace_command = command.workspace_helper(ui)?;
|
||||||
let view = workspace_command.repo().view();
|
let view = workspace_command.repo().view();
|
||||||
for branch_name in args.names.iter() {
|
for branch_name in args.names.iter() {
|
||||||
|
|
Loading…
Reference in a new issue