mirror of
https://github.com/extrawurst/gitui.git
synced 2024-12-27 11:03:03 +03:00
Conflict free rebase (#896)
* unittest for rebasing with conflicts * hide branchlist after rebase
This commit is contained in:
parent
bf56d3bff2
commit
f27227af41
@ -16,7 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
![emojified-commit-message](assets/emojified-commit-message.png)
|
||||
|
||||
## Added
|
||||
- add supporting rebasing on branch ([#816](https://github.com/extrawurst/gitui/issues/816))
|
||||
- add supporting rebasing on branch (if conflict-free) ([#816](https://github.com/extrawurst/gitui/issues/816))
|
||||
- fuzzy find files ([#891](https://github.com/extrawurst/gitui/issues/891))
|
||||
- visualize progress during async syntax highlighting ([#889](https://github.com/extrawurst/gitui/issues/889))
|
||||
- added support for markdown emoji's in commits [[@andrewpollack](https://github.com/andrewpollack)] ([#768](https://github.com/extrawurst/gitui/issues/768))
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use crate::{
|
||||
error::{Error, Result},
|
||||
sync::{rebase::conflict_free_rebase, utils},
|
||||
sync::{rebase::conflict_free_rebase, utils, CommitId},
|
||||
};
|
||||
use git2::BranchType;
|
||||
use scopetime::scope_time;
|
||||
@ -11,7 +11,7 @@ use scopetime::scope_time;
|
||||
pub fn merge_upstream_rebase(
|
||||
repo_path: &str,
|
||||
branch_name: &str,
|
||||
) -> Result<()> {
|
||||
) -> Result<CommitId> {
|
||||
scope_time!("merge_upstream_rebase");
|
||||
|
||||
let repo = utils::repo(repo_path)?;
|
||||
@ -27,9 +27,7 @@ pub fn merge_upstream_rebase(
|
||||
let annotated_upstream =
|
||||
repo.find_annotated_commit(upstream_commit.id())?;
|
||||
|
||||
conflict_free_rebase(&repo, &annotated_upstream)?;
|
||||
|
||||
Ok(())
|
||||
conflict_free_rebase(&repo, &annotated_upstream)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -40,9 +40,9 @@ pub fn conflict_free_rebase(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::sync::{
|
||||
checkout_branch, create_branch, rebase_branch,
|
||||
checkout_branch, create_branch, rebase_branch, repo_state,
|
||||
tests::{repo_init, write_commit_file},
|
||||
CommitId,
|
||||
CommitId, RepoState,
|
||||
};
|
||||
use git2::Repository;
|
||||
|
||||
@ -84,4 +84,29 @@ mod tests {
|
||||
|
||||
assert_eq!(parent_ids(&repo, r), vec![c3]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_conflict() {
|
||||
let (_td, repo) = repo_init().unwrap();
|
||||
let root = repo.path().parent().unwrap();
|
||||
let repo_path = root.as_os_str().to_str().unwrap();
|
||||
|
||||
write_commit_file(&repo, "test.txt", "test1", "commit1");
|
||||
|
||||
create_branch(repo_path, "foo").unwrap();
|
||||
|
||||
write_commit_file(&repo, "test.txt", "test2", "commit2");
|
||||
|
||||
checkout_branch(repo_path, "refs/heads/master").unwrap();
|
||||
|
||||
write_commit_file(&repo, "test.txt", "test3", "commit3");
|
||||
|
||||
checkout_branch(repo_path, "refs/heads/foo").unwrap();
|
||||
|
||||
let res = rebase_branch(repo_path, "master");
|
||||
|
||||
assert!(res.is_err());
|
||||
|
||||
assert_eq!(repo_state(repo_path).unwrap(), RepoState::Clean);
|
||||
}
|
||||
}
|
||||
|
@ -375,12 +375,14 @@ impl BranchListComponent {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn rebase_branch(&self) -> Result<()> {
|
||||
fn rebase_branch(&mut self) -> Result<()> {
|
||||
if let Some(branch) =
|
||||
self.branches.get(usize::from(self.selection))
|
||||
{
|
||||
sync::rebase_branch(CWD, &branch.name)?;
|
||||
|
||||
self.hide();
|
||||
|
||||
self.queue.push(InternalEvent::Update(NeedsUpdate::ALL));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user