Skip to content

Commit

Permalink
make fetch more error resilient (fixing #911)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Dilly committed Sep 24, 2021
1 parent 5d01da1 commit 62cec5a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
8 changes: 6 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ impl App {
self.compare_commits_popup.update_git(ev)?;
self.push_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)?;
}

Expand Down Expand Up @@ -686,7 +686,11 @@ impl App {
flags.insert(NeedsUpdate::ALL);
}
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);
}
InternalEvent::PushTags => {
Expand Down
21 changes: 9 additions & 12 deletions src/components/pull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,18 @@ impl PullComponent {
}

///
pub fn update_git(
&mut self,
ev: AsyncGitNotification,
) -> Result<()> {
pub fn update_git(&mut self, ev: AsyncGitNotification) {
if self.is_visible() {
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(())
}

///
Expand All @@ -135,11 +136,7 @@ impl PullComponent {
if err.is_empty() {
self.try_ff_merge()?;
} else {
self.pending = false;
self.hide();
self.queue.push(InternalEvent::ShowErrorMsg(
format!("fetch failed:\n{}", err),
));
anyhow::bail!(err);
}
}
}
Expand Down

0 comments on commit 62cec5a

Please sign in to comment.