Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
fetch/transport/ls_refs: Post-filter of references
Fintan Halpenny committed 2 months ago
commit be83c20cebc9e57fd1e67d93a3f94ce7686886ab
parent 980ed5618602567dd13b0b522180e0fe889f701c
1 file changed +15 -0
modified crates/radicle-fetch/src/transport/ls_refs.rs
@@ -67,5 +67,20 @@ where
        false, /* trace packetlines */
    )?;

+
    // According to [1], in the section on `ls-refs`, we must still filter on
+
    // this side, since `ref-prefix` is simply an optimization.
+
    //
+
    // [1]: https://mirrors.edge.kernel.org/pub/software/scm/git/docs/gitprotocol-v2.html
+
    let refs = refs
+
        .into_iter()
+
        .filter(|r| {
+
            let (refname, _, _) = r.unpack();
+
            config
+
                .prefixes
+
                .iter()
+
                .any(|prefix| refname.starts_with(prefix))
+
        })
+
        .collect();
+

    Ok(refs)
}