mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-09-20 00:27:17 +03:00
don't fail if a ref can't be peeled (#3129)
Sometimes, symbolic refs are used as tracking branches, like `refs/remotes/origin/HEAD`, and after some changes are dangling, pointing to a ref which doesn't exist anymore (maybe it was renamed from `master` to `main`). Now, this isn't fatal anymore, but will be logged instead.
This commit is contained in:
parent
b70a2eef6f
commit
5ea4bb3c58
@ -64,6 +64,8 @@ impl FromStr for Refname {
|
||||
return Err(Error::NotRemote(value.to_string()));
|
||||
};
|
||||
|
||||
// TODO(ST): use `gix` (which respects refspecs and settings) to do this transformation
|
||||
// Alternatively, `git2` also has support for respecting refspecs.
|
||||
let value = value.strip_prefix("refs/remotes/").unwrap();
|
||||
|
||||
if let Some((remote, branch)) = value.split_once('/') {
|
||||
|
@ -111,7 +111,17 @@ pub fn get_branch_data(
|
||||
}
|
||||
|
||||
pub fn branch_to_remote_branch(branch: &git::Branch) -> Result<Option<RemoteBranch>> {
|
||||
let commit = branch.peel_to_commit()?;
|
||||
let commit = match branch.peel_to_commit() {
|
||||
Ok(c) => c,
|
||||
Err(err) => {
|
||||
tracing::warn!(
|
||||
?err,
|
||||
"ignoring branch {:?} as peeling failed",
|
||||
branch.name()
|
||||
);
|
||||
return Ok(None);
|
||||
}
|
||||
};
|
||||
branch
|
||||
.target()
|
||||
.map(|sha| {
|
||||
|
Loading…
Reference in New Issue
Block a user