Merge pull request #1421 from gitbutlerapp/handle-upstream-branch-not-found

🔨 chore: improve error handling when finding upstream branch for list…
This commit is contained in:
Nikita Galaiko 2023-10-19 10:54:04 +02:00 committed by GitHub
commit 0fe5f109c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -654,11 +654,20 @@ pub fn list_virtual_branches(
let repo = &project_repository.git_repository;
let upstream_branch = branch
let upstream_branch = match branch
.upstream
.as_ref()
.map(|name| repo.find_branch(&git::BranchName::from(name.clone())))
.transpose()?;
.transpose()
{
Err(git::Error::NotFound(_)) => Ok(None),
Err(error) => Err(error),
Ok(branch) => Ok(branch),
}
.context(format!(
"failed to find upstream branch for {}",
branch.name
))?;
let upstram_branch_commit = upstream_branch
.as_ref()