Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
helper: Check for missing canonical head
Merged did:key:z6MksFqX...wzpT opened 2 years ago

Without the canonical head in the working copy, the next check will fail with a cryptic error.

1 file changed +10 -0 93ff59ae 0f0f9ff9
modified radicle-remote-helper/src/push.rs
@@ -96,6 +96,9 @@ pub enum Error {
    /// Patch is empty.
    #[error("patch commits are already included in the base branch")]
    EmptyPatch,
+
    /// Missing canonical head.
+
    #[error("the canonical head is missing from your working copy; please pull before pushing")]
+
    MissingCanonicalHead(git::Oid),
    /// COB store error.
    #[error(transparent)]
    Cob(#[from] radicle::cob::store::Error),
@@ -257,6 +260,13 @@ pub fn run(
                            && delegates.contains(&Did::from(nid))
                            && 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 = head.peel_to_commit()?.id();
                            // Rollback is allowed and head is an ancestor of the canonical head.