Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
node: Use `StagedRepository` to know what to do
Alexis Sellier committed 3 years ago
commit 9729a2355971d13b7d8a51a012918a65fcc8ad73
parent 3e05939d14f16a4ccc20840849d09903f684bb51
2 files changed +9 -4
modified radicle-node/src/worker.rs
@@ -389,7 +389,7 @@ impl Worker {

    fn _fetch<S>(
        &self,
-
        repo: &storage::git::Repository,
+
        repo: &fetch::StagedRepository,
        remote: NodeId,
        specs: S,
        stream: StreamId,
@@ -414,17 +414,16 @@ impl Worker {
            cmd.arg("--atomic");
        }

-
        let is_clone = repo.head().is_err();
        let namespace = self.nid.to_namespace();
        let mut fetchspecs = specs
            .into_refspecs()
            .into_iter()
            // Filter out our own refs, if we aren't cloning.
-
            .filter(|fs| is_clone || !fs.dst.starts_with(namespace.as_str()))
+
            .filter(|fs| repo.is_cloning() || !fs.dst.starts_with(namespace.as_str()))
            .map(|spec| spec.to_string())
            .collect::<Vec<_>>();

-
        if !is_clone {
+
        if !repo.is_cloning() {
            // Make sure we don't fetch our own refs via a glob pattern.
            fetchspecs.push(format!("^refs/namespaces/{}/*", self.nid));
        }
modified radicle-node/src/worker/fetch.rs
@@ -40,6 +40,12 @@ pub enum StagedRepository {
    Fetching(Repository),
}

+
impl StagedRepository {
+
    pub fn is_cloning(&self) -> bool {
+
        matches!(self, Self::Cloning(_))
+
    }
+
}
+

impl Deref for StagedRepository {
    type Target = Repository;