make fetch more error resilient (#915)

fixing #911
This commit is contained in:
Stephan Dilly 2021-09-24 13:01:55 +02:00 committed by GitHub
parent 5d01da1c93
commit d541d0d9f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 14 deletions

View file

@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased ## Unreleased
## Fixed
- appropriate error message when pulling deleted remote branch ([#911](https://github.com/extrawurst/gitui/issues/991))
## [0.17.1] - 2021-09-10 ## [0.17.1] - 2021-09-10
**fuzzy find files** **fuzzy find files**

View file

@ -385,7 +385,7 @@ impl App {
self.compare_commits_popup.update_git(ev)?; self.compare_commits_popup.update_git(ev)?;
self.push_popup.update_git(ev)?; self.push_popup.update_git(ev)?;
self.push_tags_popup.update_git(ev)?; self.push_tags_popup.update_git(ev)?;
self.pull_popup.update_git(ev)?; self.pull_popup.update_git(ev);
self.select_branch_popup.update_git(ev)?; self.select_branch_popup.update_git(ev)?;
} }
@ -686,7 +686,11 @@ impl App {
flags.insert(NeedsUpdate::ALL); flags.insert(NeedsUpdate::ALL);
} }
InternalEvent::Pull(branch) => { InternalEvent::Pull(branch) => {
self.pull_popup.fetch(branch)?; if let Err(error) = self.pull_popup.fetch(branch) {
self.queue.push(InternalEvent::ShowErrorMsg(
error.to_string(),
));
}
flags.insert(NeedsUpdate::ALL); flags.insert(NeedsUpdate::ALL);
} }
InternalEvent::PushTags => { InternalEvent::PushTags => {

View file

@ -110,17 +110,18 @@ impl PullComponent {
} }
/// ///
pub fn update_git( pub fn update_git(&mut self, ev: AsyncGitNotification) {
&mut self,
ev: AsyncGitNotification,
) -> Result<()> {
if self.is_visible() { if self.is_visible() {
if let AsyncGitNotification::Fetch = ev { if let AsyncGitNotification::Fetch = ev {
self.update()?; if let Err(error) = self.update() {
self.pending = false;
self.hide();
self.queue.push(InternalEvent::ShowErrorMsg(
format!("fetch failed:\n{}", error),
));
}
} }
} }
Ok(())
} }
/// ///
@ -135,11 +136,7 @@ impl PullComponent {
if err.is_empty() { if err.is_empty() {
self.try_ff_merge()?; self.try_ff_merge()?;
} else { } else {
self.pending = false; anyhow::bail!(err);
self.hide();
self.queue.push(InternalEvent::ShowErrorMsg(
format!("fetch failed:\n{}", err),
));
} }
} }
} }