Skip to content

Commit 9955373

Browse files
committed
Switch to status tab after merge / rebase with conflicts
Issue gitui-org#926
1 parent c6abbaf commit 9955373

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
## Added
1111
- support rebasing branches with conflicts ([#895](https://github.com/extrawurst/gitui/issues/895))
12+
- switch to status tab after merging or rebasing with conflicts ([#926](https://github.com/extrawurst/gitui/issues/926))
1213

1314
## Fixed
1415
- fix supported checkout of hierarchical branchnames ([#921](https://github.com/extrawurst/gitui/issues/921))

asyncgit/src/sync/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ pub use tags::{
7979
};
8080
pub use tree::{tree_file_content, tree_files, TreeFile};
8181
pub use utils::{
82-
get_head, get_head_tuple, is_bare_repo, is_repo, repo_dir,
83-
stage_add_all, stage_add_file, stage_addremoved, Head,
82+
get_head, get_head_tuple, has_conflicts, is_bare_repo, is_repo,
83+
repo_dir, stage_add_all, stage_add_file, stage_addremoved, Head,
8484
};
8585

8686
#[cfg(test)]

asyncgit/src/sync/utils.rs

+8
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,14 @@ pub(crate) fn repo_write_file(
197197
Ok(())
198198
}
199199

200+
/// checks if repository has conflicts
201+
pub fn has_conflicts(repo_path: &str) -> Result<bool> {
202+
let repo = repo(repo_path)?;
203+
let index = repo.index()?;
204+
205+
Ok(index.has_conflicts())
206+
}
207+
200208
#[cfg(test)]
201209
pub(crate) fn repo_read_file(
202210
repo: &Repository,

src/components/branchlist.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,7 @@ impl BranchListComponent {
368368
{
369369
sync::merge_branch(CWD, &branch.name)?;
370370

371-
self.hide();
372-
self.queue.push(InternalEvent::Update(NeedsUpdate::ALL));
371+
self.hide_and_check_for_conflicts()?;
373372
}
374373

375374
Ok(())
@@ -381,9 +380,18 @@ impl BranchListComponent {
381380
{
382381
sync::rebase_branch(CWD, &branch.name)?;
383382

384-
self.hide();
383+
self.hide_and_check_for_conflicts()?;
384+
}
385+
386+
Ok(())
387+
}
388+
389+
fn hide_and_check_for_conflicts(&mut self) -> Result<()> {
390+
self.hide();
391+
self.queue.push(InternalEvent::Update(NeedsUpdate::ALL));
385392

386-
self.queue.push(InternalEvent::Update(NeedsUpdate::ALL));
393+
if sync::has_conflicts(CWD)? {
394+
self.queue.push(InternalEvent::TabSwitch);
387395
}
388396

389397
Ok(())

0 commit comments

Comments
 (0)