use std::path::PathBuf;
use iced::Task;
use crate::message::Message;
pub fn checkout_branch(path: PathBuf, branch_name: String) -> Task<Message> {
git_task!(
Message::BranchCheckedOut,
(|| {
let repo = open_repo!(&path);
gitkraft_core::features::branches::checkout_branch(&repo, &branch_name)
.map_err(|e| e.to_string())
})()
)
}
pub fn create_branch(path: PathBuf, branch_name: String) -> Task<Message> {
git_task!(
Message::BranchCreated,
(|| {
let repo = open_repo!(&path);
gitkraft_core::features::branches::create_branch(&repo, &branch_name)
.map(|_| ())
.map_err(|e| e.to_string())
})()
)
}
pub fn delete_branch(path: PathBuf, branch_name: String) -> Task<Message> {
git_task!(
Message::BranchDeleted,
(|| {
let repo = open_repo!(&path);
gitkraft_core::features::branches::delete_branch(&repo, &branch_name)
.map_err(|e| e.to_string())
})()
)
}