cli: branch: move command fn next to Command/Args type

This commit is contained in:
Yuya Nishihara 2024-06-20 12:54:34 +09:00
parent 9e35b9b218
commit b9c2daa408
2 changed files with 18 additions and 18 deletions

View file

@ -40,17 +40,6 @@ pub struct BranchForgetArgs {
pub glob: Vec<StringPattern>,
}
fn find_forgettable_branches(
view: &View,
name_patterns: &[StringPattern],
) -> Result<Vec<String>, CommandError> {
find_branches_with(name_patterns, |pattern| {
view.branches()
.filter(|(name, _)| pattern.matches(name))
.map(|(name, _)| name.to_owned())
})
}
pub fn cmd_branch_forget(
ui: &mut Ui,
command: &CommandHelper,
@ -76,3 +65,14 @@ pub fn cmd_branch_forget(
}
Ok(())
}
fn find_forgettable_branches(
view: &View,
name_patterns: &[StringPattern],
) -> Result<Vec<String>, CommandError> {
find_branches_with(name_patterns, |pattern| {
view.branches()
.filter(|(name, _)| pattern.matches(name))
.map(|(name, _)| name.to_owned())
})
}

View file

@ -69,13 +69,6 @@ pub enum BranchCommand {
Untrack(BranchUntrackArgs),
}
fn make_branch_term(branch_names: &[impl fmt::Display]) -> String {
match branch_names {
[branch_name] => format!("branch {}", branch_name),
branch_names => format!("branches {}", branch_names.iter().join(", ")),
}
}
pub fn cmd_branch(
ui: &mut Ui,
command: &CommandHelper,
@ -94,6 +87,13 @@ pub fn cmd_branch(
}
}
fn make_branch_term(branch_names: &[impl fmt::Display]) -> String {
match branch_names {
[branch_name] => format!("branch {}", branch_name),
branch_names => format!("branches {}", branch_names.iter().join(", ")),
}
}
fn find_local_branches(
view: &View,
name_patterns: &[StringPattern],