Skip to content
GitHub no longer supports this web browser. Learn more about the browsers we support.
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time. Cannot retrieve contributors at this time
33 lines (25 sloc) 866 Bytes
use crate::git::Git;
use crate::Merge;
pub fn run(params: Merge) -> Result<(), Box<dyn std::error::Error>> {
let mut git = Git::open()?;
let current_branch = if let Some(name) = git.branch_name.as_ref() {
name.clone()
} else {
return Err("Cannot merge if you are not in a branch!".into());
};
let branch_name = params.branch_name.as_str();
git.merge_no_conflict(
branch_name,
format!("Merge branch '{}' into {}", branch_name, current_branch).as_str(),
)?;
if branch_name == "master" || branch_name.contains("/") {
return Err(format!(
"The branch '{}' has been merged but not deleted!",
branch_name
)
.into());
}
git.full_delete_branch(branch_name)?;
println!("The branch '{}' has been merged and deleted.", branch_name);
Ok(())
}
You can’t perform that action at this time.