diff --git a/asyncgit/src/sync/merge.rs b/asyncgit/src/sync/merge.rs index f087bb17..f91b33a4 100644 --- a/asyncgit/src/sync/merge.rs +++ b/asyncgit/src/sync/merge.rs @@ -8,8 +8,6 @@ use crate::{ use git2::{BranchType, Commit, MergeOptions, Repository}; use scopetime::scope_time; -use super::rebase::conflict_free_rebase; - /// pub fn mergehead_ids(repo_path: &str) -> Result> { scope_time!("mergehead_ids"); @@ -53,18 +51,6 @@ pub fn merge_branch(repo_path: &str, branch: &str) -> Result<()> { Ok(()) } -/// -pub fn rebase_branch( - repo_path: &str, - branch: &str, -) -> Result { - scope_time!("rebase_branch"); - - let repo = utils::repo(repo_path)?; - - rebase_branch_repo(&repo, branch) -} - /// pub fn merge_branch_repo( repo: &Repository, @@ -89,19 +75,6 @@ pub fn merge_branch_repo( Ok(()) } -/// -pub fn rebase_branch_repo( - repo: &Repository, - branch_name: &str, -) -> Result { - let branch = repo.find_branch(branch_name, BranchType::Local)?; - - let annotated = - repo.reference_to_annotated_commit(&branch.into_reference())?; - - conflict_free_rebase(repo, &annotated) -} - /// pub fn merge_msg(repo_path: &str) -> Result { scope_time!("merge_msg"); diff --git a/asyncgit/src/sync/mod.rs b/asyncgit/src/sync/mod.rs index 1c8df9dd..331e3c8a 100644 --- a/asyncgit/src/sync/mod.rs +++ b/asyncgit/src/sync/mod.rs @@ -58,9 +58,9 @@ pub use hunks::{reset_hunk, stage_hunk, unstage_hunk}; pub use ignore::add_to_ignore; pub use logwalker::{LogWalker, LogWalkerFilter}; pub use merge::{ - abort_merge, merge_branch, merge_commit, merge_msg, - mergehead_ids, rebase_branch, + abort_merge, merge_branch, merge_commit, merge_msg, mergehead_ids, }; +pub use rebase::rebase_branch; pub use remotes::{ get_default_remote, get_remotes, push::AsyncProgress, tags::PushTagsProgress, diff --git a/asyncgit/src/sync/rebase.rs b/asyncgit/src/sync/rebase.rs index 053eb483..c7aa1fd4 100644 --- a/asyncgit/src/sync/rebase.rs +++ b/asyncgit/src/sync/rebase.rs @@ -1,7 +1,37 @@ -use crate::error::{Error, Result}; +use git2::{BranchType, Repository}; +use scopetime::scope_time; + +use crate::{ + error::{Error, Result}, + sync::utils, +}; use super::CommitId; +fn rebase_branch_repo( + repo: &Repository, + branch_name: &str, +) -> Result { + let branch = repo.find_branch(branch_name, BranchType::Local)?; + + let annotated = + repo.reference_to_annotated_commit(&branch.into_reference())?; + + conflict_free_rebase(repo, &annotated) +} + +/// +pub fn rebase_branch( + repo_path: &str, + branch: &str, +) -> Result { + scope_time!("rebase_branch"); + + let repo = utils::repo(repo_path)?; + + rebase_branch_repo(&repo, branch) +} + /// rebase attempt which aborts and undo's rebase if any conflict appears pub fn conflict_free_rebase( repo: &git2::Repository, @@ -40,7 +70,9 @@ pub fn conflict_free_rebase( #[cfg(test)] mod tests { use crate::sync::{ - checkout_branch, create_branch, rebase_branch, repo_state, + checkout_branch, create_branch, + rebase::rebase_branch, + repo_state, tests::{repo_init, write_commit_file}, CommitId, RepoState, };