mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-18 06:22:28 +03:00
less cumbersome error handling for Git errors
This commit is contained in:
parent
e0c2d82127
commit
066d520f1a
@ -55,6 +55,8 @@ pub enum ResetBranchError {
|
||||
DefaultTargetNotSet(DefaultTargetNotSet),
|
||||
#[error(transparent)]
|
||||
Other(#[from] anyhow::Error),
|
||||
#[error(transparent)]
|
||||
Git(#[from] git::Error),
|
||||
}
|
||||
|
||||
impl ErrorWithContext for ResetBranchError {
|
||||
@ -66,6 +68,7 @@ impl ErrorWithContext for ResetBranchError {
|
||||
error::Context::new(Code::Branches, format!("commit {} not found", oid))
|
||||
}
|
||||
ResetBranchError::Other(error) => return error.custom_context_or_root_cause().into(),
|
||||
ResetBranchError::Git(_err) => return None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -2056,16 +2056,8 @@ pub fn reset_branch(
|
||||
let repo = &project_repository.git_repository;
|
||||
let diff = trees(
|
||||
repo,
|
||||
&repo
|
||||
.find_commit(updated_head)
|
||||
.map_err(anyhow::Error::from)?
|
||||
.tree()
|
||||
.map_err(anyhow::Error::from)?,
|
||||
&repo
|
||||
.find_commit(old_head)
|
||||
.map_err(anyhow::Error::from)?
|
||||
.tree()
|
||||
.map_err(anyhow::Error::from)?,
|
||||
&repo.find_commit(updated_head)?.tree()?,
|
||||
&repo.find_commit(old_head)?.tree()?,
|
||||
)?;
|
||||
|
||||
// Assign the new hunks to the branch we're working on.
|
||||
|
Loading…
Reference in New Issue
Block a user