Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: `rad ls` shouldn't show unseeded by default
cloudhead committed 2 years ago
commit 5e3990d411f6ceef2a058ee30b6eaca7df9b445c
parent 59f506dbb5591d3fe68e638038495730c455d72a
3 files changed +59 -1
added radicle-cli/examples/rad-unseed.md
@@ -0,0 +1,35 @@
+
Let's say we have a local repository we've initialized:
+

+
```
+
$ rad ls
+
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────╮
+
│ Name        RID                                 Visibility   Head      Description                        │
+
├───────────────────────────────────────────────────────────────────────────────────────────────────────────┤
+
│ heartwood   rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji   public       f2de534   Radicle Heartwood Protocol & Stack │
+
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯
+
```
+

+
We could stop seeding it if didn't want other nodes to fetch it from us:
+

+
```
+
$ rad seed --delete rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji
+
✓ Seeding policy for rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji removed
+
```
+

+
Now, if we run `rad ls`, we see it's gone:
+

+
```
+
$ rad ls
+
Nothing to show.
+
```
+

+
However, with the `--all` flag, we can see it still, but as local-only:
+

+
```
+
$ rad ls --all
+
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────╮
+
│ Name        RID                                 Visibility   Head      Description                        │
+
├───────────────────────────────────────────────────────────────────────────────────────────────────────────┤
+
│ heartwood   rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji   local        f2de534   Radicle Heartwood Protocol & Stack │
+
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯
+
```
modified radicle-cli/src/commands/ls.rs
@@ -82,6 +82,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
    let profile = ctx.profile()?;
    let storage = &profile.storage;
    let repos = storage.repositories()?;
+
    let policy = profile.policies()?;
    let mut table = term::Table::new(term::TableOptions::bordered());
    let mut rows = Vec::new();

@@ -105,13 +106,22 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
        if refs.is_none() && !options.all {
            continue;
        }
+
        let seeded = policy.is_repo_seeded(&rid)?;
+

+
        if !seeded && !options.all {
+
            continue;
+
        }
        let proj = doc.project()?;
        let head = term::format::oid(head).into();

        rows.push([
            term::format::bold(proj.name().to_owned()),
            term::format::tertiary(rid.urn()),
-
            term::format::visibility(&doc.visibility).into(),
+
            if seeded {
+
                term::format::visibility(&doc.visibility).into()
+
            } else {
+
                term::format::tertiary("local").into()
+
            },
            term::format::secondary(head),
            term::format::italic(proj.description().to_owned()),
        ]);
modified radicle-cli/tests/commands.rs
@@ -729,6 +729,19 @@ fn rad_seed_and_follow() {
}

#[test]
+
fn rad_unseed() {
+
    let mut environment = Environment::new();
+
    let mut alice = environment.node(Config::test(Alias::new("alice")));
+
    let working = tempfile::tempdir().unwrap();
+

+
    // Setup a test project.
+
    alice.project("heartwood", "Radicle Heartwood Protocol & Stack");
+
    let alice = alice.spawn();
+

+
    test("examples/rad-unseed.md", working, Some(&alice.home), []).unwrap();
+
}
+

+
#[test]
fn rad_clone() {
    let mut environment = Environment::new();
    let mut alice = environment.node(Config::test(Alias::new("alice")));