helper: Check for missing canonical head
Without the canonical head in the working copy, the next check will fail with a cryptic error.
This commit is contained in:
parent
93ff59ae25
commit
0f0f9ff9b4
|
|
@ -96,6 +96,9 @@ pub enum Error {
|
||||||
/// Patch is empty.
|
/// Patch is empty.
|
||||||
#[error("patch commits are already included in the base branch")]
|
#[error("patch commits are already included in the base branch")]
|
||||||
EmptyPatch,
|
EmptyPatch,
|
||||||
|
/// Missing canonical head.
|
||||||
|
#[error("the canonical head is missing from your working copy; please pull before pushing")]
|
||||||
|
MissingCanonicalHead(git::Oid),
|
||||||
/// COB store error.
|
/// COB store error.
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Cob(#[from] radicle::cob::store::Error),
|
Cob(#[from] radicle::cob::store::Error),
|
||||||
|
|
@ -257,6 +260,13 @@ pub fn run(
|
||||||
&& delegates.contains(&Did::from(nid))
|
&& delegates.contains(&Did::from(nid))
|
||||||
&& delegates.len() > 1
|
&& delegates.len() > 1
|
||||||
{
|
{
|
||||||
|
if let Err(e) = working.find_commit(**canonical_oid) {
|
||||||
|
return if git::ext::is_not_found_err(&e) {
|
||||||
|
Err(Error::MissingCanonicalHead(*canonical_oid))
|
||||||
|
} else {
|
||||||
|
Err(e.into())
|
||||||
|
};
|
||||||
|
}
|
||||||
let head = working.find_reference(src.as_str())?;
|
let head = working.find_reference(src.as_str())?;
|
||||||
let head = head.peel_to_commit()?.id();
|
let head = head.peel_to_commit()?.id();
|
||||||
// Rollback is allowed and head is an ancestor of the canonical head.
|
// Rollback is allowed and head is an ancestor of the canonical head.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue