Skip to content

Commit f8bad7d

Browse files
author
Stephan Dilly
committed
cleanup
1 parent 07f5d69 commit f8bad7d

File tree

3 files changed

+36
-31
lines changed

3 files changed

+36
-31
lines changed

asyncgit/src/sync/merge.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ use crate::{
88
use git2::{BranchType, Commit, MergeOptions, Repository};
99
use scopetime::scope_time;
1010

11-
use super::rebase::conflict_free_rebase;
12-
1311
///
1412
pub fn mergehead_ids(repo_path: &str) -> Result<Vec<CommitId>> {
1513
scope_time!("mergehead_ids");
@@ -53,18 +51,6 @@ pub fn merge_branch(repo_path: &str, branch: &str) -> Result<()> {
5351
Ok(())
5452
}
5553

56-
///
57-
pub fn rebase_branch(
58-
repo_path: &str,
59-
branch: &str,
60-
) -> Result<CommitId> {
61-
scope_time!("rebase_branch");
62-
63-
let repo = utils::repo(repo_path)?;
64-
65-
rebase_branch_repo(&repo, branch)
66-
}
67-
6854
///
6955
pub fn merge_branch_repo(
7056
repo: &Repository,
@@ -89,19 +75,6 @@ pub fn merge_branch_repo(
8975
Ok(())
9076
}
9177

92-
///
93-
pub fn rebase_branch_repo(
94-
repo: &Repository,
95-
branch_name: &str,
96-
) -> Result<CommitId> {
97-
let branch = repo.find_branch(branch_name, BranchType::Local)?;
98-
99-
let annotated =
100-
repo.reference_to_annotated_commit(&branch.into_reference())?;
101-
102-
conflict_free_rebase(repo, &annotated)
103-
}
104-
10578
///
10679
pub fn merge_msg(repo_path: &str) -> Result<String> {
10780
scope_time!("merge_msg");

asyncgit/src/sync/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ pub use hunks::{reset_hunk, stage_hunk, unstage_hunk};
5858
pub use ignore::add_to_ignore;
5959
pub use logwalker::{LogWalker, LogWalkerFilter};
6060
pub use merge::{
61-
abort_merge, merge_branch, merge_commit, merge_msg,
62-
mergehead_ids, rebase_branch,
61+
abort_merge, merge_branch, merge_commit, merge_msg, mergehead_ids,
6362
};
63+
pub use rebase::rebase_branch;
6464
pub use remotes::{
6565
get_default_remote, get_remotes, push::AsyncProgress,
6666
tags::PushTagsProgress,

asyncgit/src/sync/rebase.rs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,37 @@
1-
use crate::error::{Error, Result};
1+
use git2::{BranchType, Repository};
2+
use scopetime::scope_time;
3+
4+
use crate::{
5+
error::{Error, Result},
6+
sync::utils,
7+
};
28

39
use super::CommitId;
410

11+
fn rebase_branch_repo(
12+
repo: &Repository,
13+
branch_name: &str,
14+
) -> Result<CommitId> {
15+
let branch = repo.find_branch(branch_name, BranchType::Local)?;
16+
17+
let annotated =
18+
repo.reference_to_annotated_commit(&branch.into_reference())?;
19+
20+
conflict_free_rebase(repo, &annotated)
21+
}
22+
23+
///
24+
pub fn rebase_branch(
25+
repo_path: &str,
26+
branch: &str,
27+
) -> Result<CommitId> {
28+
scope_time!("rebase_branch");
29+
30+
let repo = utils::repo(repo_path)?;
31+
32+
rebase_branch_repo(&repo, branch)
33+
}
34+
535
/// rebase attempt which aborts and undo's rebase if any conflict appears
636
pub fn conflict_free_rebase(
737
repo: &git2::Repository,
@@ -40,7 +70,9 @@ pub fn conflict_free_rebase(
4070
#[cfg(test)]
4171
mod tests {
4272
use crate::sync::{
43-
checkout_branch, create_branch, rebase_branch, repo_state,
73+
checkout_branch, create_branch,
74+
rebase::rebase_branch,
75+
repo_state,
4476
tests::{repo_init, write_commit_file},
4577
CommitId, RepoState,
4678
};

0 commit comments

Comments
 (0)