cli: `rad ls` shouldn't show unseeded by default
Unseeded repos should not show up in `rad ls`, by default. Only with `--all`. We also use a special visibility of "local" for those projects.
This commit is contained in:
parent
59f506dbb5
commit
5e3990d411
|
|
@ -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 │
|
||||
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
```
|
||||
|
|
@ -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()),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -728,6 +728,19 @@ fn rad_seed_and_follow() {
|
|||
.unwrap();
|
||||
}
|
||||
|
||||
#[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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue