Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: Don't fork if we already have a fork
Alexis Sellier committed 3 years ago
commit 68aca5dd65b08a41c96b1841bf106f14108fdf70
parent 207030d2e15547a95e6142a2f4746312b153e61d
1 file changed +8 -8
modified radicle-cli/src/commands/clone.rs
@@ -195,16 +195,16 @@ pub fn clone<G: Signer>(
                }
            }
        }
+
        // TODO: Warn if no seeds were found, and we might be checking out stale data.
    }
-
    // TODO: Warn if no seeds were found, and we might be checking out stale data.
-
    // If we don't have the project locally, even after attempting to fetch,
-
    // there's nothing we can do.
-
    if !storage.contains(&id)? {
+
    let Ok(repository) = storage.repository(id) else {
+
        // If we don't have the project locally, even after attempting to fetch,
+
        // there's nothing we can do.
        return Err(CloneError::NotFound(id));
-
    }
+
    };

-
    // Create a local fork of the project, under our own id.
-
    {
+
    // Create a local fork of the project, under our own id, unless we have one already.
+
    if repository.remote(signer.public_key()).is_err() {
        let mut spinner = term::spinner(format!(
            "Forking under {}..",
            term::format::tertiary(term::format::node(&me))
@@ -223,7 +223,7 @@ pub fn clone<G: Signer>(
        }
    }

-
    let doc = storage.repository(id)?.identity_of(&me)?;
+
    let doc = repository.identity_of(&me)?;
    let proj = doc.project()?;
    let path = Path::new(proj.name());