gitdataai/lib/git/cmd/branch/branch_rename.rs
2026-05-30 01:38:40 +08:00

21 lines
514 B
Rust

use crate::{bare::GitBare, errors::GitResult};
pub struct BranchReNameParams {
pub old_branch: String,
pub new_branch: String,
pub force: bool,
}
impl GitBare {
pub fn branch_rename(&self, params: BranchReNameParams) -> GitResult<()> {
let flag = if params.force { "-M" } else { "-m" };
self.git_command_trusted(vec![
"branch".to_string(),
flag.to_string(),
params.old_branch,
params.new_branch,
])?;
Ok(())
}
}