mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 17:08:21 +00:00
cleanup
This commit is contained in:
parent
07f5d69a48
commit
f8bad7d541
3 changed files with 36 additions and 31 deletions
|
|
@ -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<Vec<CommitId>> {
|
||||
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<CommitId> {
|
||||
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<CommitId> {
|
||||
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<String> {
|
||||
scope_time!("merge_msg");
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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<CommitId> {
|
||||
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<CommitId> {
|
||||
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,
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue