Skip to content

make fetch more error resilient #915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## Fixed
- appropriate error message when pulling deleted remote branch ([#911](https://github.com/extrawurst/gitui/issues/991))

## [0.17.1] - 2021-09-10

**fuzzy find files**
Expand Down
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