diff --git a/cli/src/commands/branch.rs b/cli/src/commands/branch.rs index 12efd26f198..a0627340711 100644 --- a/cli/src/commands/branch.rs +++ b/cli/src/commands/branch.rs @@ -17,7 +17,6 @@ use crate::cli_util::{ parse_string_pattern, user_error, user_error_with_hint, CommandError, CommandHelper, RevisionArg, }; -use crate::commands::make_branch_term; use crate::formatter::Formatter; use crate::ui::Ui; @@ -231,6 +230,13 @@ impl fmt::Display for RemoteBranchNamePattern { } } +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, diff --git a/cli/src/commands/git.rs b/cli/src/commands/git.rs index 496524e1908..745abbc4c28 100644 --- a/cli/src/commands/git.rs +++ b/cli/src/commands/git.rs @@ -5,7 +5,7 @@ use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; use std::sync::Mutex; use std::time::Instant; -use std::{fs, io}; +use std::{fmt, fs, io}; use clap::{ArgGroup, Subcommand}; use itertools::Itertools; @@ -33,7 +33,6 @@ use crate::cli_util::{ resolve_multiple_nonempty_revsets, short_change_hash, short_commit_hash, user_error, user_error_with_hint, CommandError, CommandHelper, RevisionArg, WorkspaceCommandHelper, }; -use crate::commands::make_branch_term; use crate::progress::Progress; use crate::ui::Ui; @@ -191,6 +190,13 @@ pub struct GitSubmodulePrintGitmodulesArgs { revisions: RevisionArg, } +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 get_git_repo(store: &Store) -> Result { match store.backend_impl().downcast_ref::() { None => Err(user_error("The repo is not backed by a git repo")), diff --git a/cli/src/commands/mod.rs b/cli/src/commands/mod.rs index f52ed8d38a9..589cf06e4d9 100644 --- a/cli/src/commands/mod.rs +++ b/cli/src/commands/mod.rs @@ -55,11 +55,9 @@ mod util; mod version; mod workspace; -use std::fmt; use std::fmt::Debug; use clap::{Command, CommandFactory, FromArgMatches, Subcommand}; -use itertools::Itertools; use tracing::instrument; use crate::cli_util::{user_error_with_hint, Args, CommandError, CommandHelper}; @@ -147,13 +145,6 @@ struct DummyCommandArgs { _args: Vec, } -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 default_app() -> Command { Commands::augment_subcommands(Args::command()) }