Skip to content

Commit

Permalink
Merge pull request #4452 from Byron/fix-4389
Browse files Browse the repository at this point in the history
fix 4389
  • Loading branch information
krlvi authored Jul 20, 2024
2 parents bcb0916 + 5cfa2fd commit 63863f9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion app/src/lib/baseBranch/baseBranchService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class BaseBranchService {
return;
} else if (err.code === Code.ProjectsGitAuth) {
showError('Failed to authenticate', err);
} else {
} else if (action !== undefined) {
showError('Failed to fetch', err);
}
console.error(err);
Expand Down
29 changes: 13 additions & 16 deletions crates/gitbutler-branch-actions/src/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,26 +428,23 @@ impl VirtualBranchActions {

let helper = Helper::default();
let remotes = project_repository.repo().remotes_as_string()?;
let fetch_results: Vec<Result<(), _>> = remotes
let fetch_errors: Vec<_> = remotes
.iter()
.map(|remote| project_repository.fetch(remote, &helper, askpass.clone()))
.filter_map(|remote| {
project_repository
.fetch(remote, &helper, askpass.clone())
.err()
.map(|err| err.to_string())
})
.collect();

let project_data_last_fetched = if fetch_results.iter().any(Result::is_err) {
FetchResult::Error {
timestamp: std::time::SystemTime::now(),
error: fetch_results
.iter()
.filter_map(|result| match result {
Ok(_) => None,
Err(error) => Some(error.to_string()),
})
.collect::<Vec<_>>()
.join("\n"),
}
let timestamp = std::time::SystemTime::now();
let project_data_last_fetched = if fetch_errors.is_empty() {
FetchResult::Fetched { timestamp }
} else {
FetchResult::Fetched {
timestamp: std::time::SystemTime::now(),
FetchResult::Error {
timestamp,
error: fetch_errors.join("\n"),
}
};

Expand Down
8 changes: 6 additions & 2 deletions crates/gitbutler-tauri/src/virtual_branches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub mod commands {
use gitbutler_branch_actions::{RemoteBranch, RemoteBranchData};
use gitbutler_error::error::Code;
use gitbutler_project as projects;
use gitbutler_project::ProjectId;
use gitbutler_project::{FetchResult, ProjectId};
use gitbutler_reference::normalize_branch_name as normalize_name;
use gitbutler_reference::ReferenceName;
use gitbutler_reference::{Refname, RemoteRefname};
Expand Down Expand Up @@ -478,12 +478,16 @@ pub mod commands {
projects
.update(&projects::UpdateRequest {
id: project.id,
project_data_last_fetched: Some(project_data_last_fetched),
project_data_last_fetched: Some(project_data_last_fetched.clone()),
..Default::default()
})
.await
.context("failed to update project with last fetched timestamp")?;

if let FetchResult::Error { error, .. } = project_data_last_fetched {
return Err(anyhow!(error).into());
}

let base_branch = VirtualBranchActions::get_base_branch_data(&project).await?;
Ok(base_branch)
}
Expand Down

0 comments on commit 63863f9

Please sign in to comment.