diff --git a/crates/radicle-cli/examples/rad-clone-scope.md b/crates/radicle-cli/examples/rad-clone-scope.md new file mode 100644 index 00000000..4a56e6f1 --- /dev/null +++ b/crates/radicle-cli/examples/rad-clone-scope.md @@ -0,0 +1,63 @@ +By default `rad clone` should add a seeding policy with the `followed` scope: + +``` +$ rad clone rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji +✓ Seeding policy updated for rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji with scope 'followed' +✓ Creating checkout in ./heartwood.. +✓ Repository successfully cloned under [..]/heartwood/ +╭────────────────────────────────────╮ +│ heartwood │ +│ Radicle Heartwood Protocol & Stack │ +│ 0 issues · 0 patches │ +╰────────────────────────────────────╯ +Run `cd ./heartwood` to go to the repository directory. +$ rad seed +╭───────────────────────────────────────────────────────────────────╮ +│ Repository Name Policy Scope │ +├───────────────────────────────────────────────────────────────────┤ +│ rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji heartwood allow followed │ +╰───────────────────────────────────────────────────────────────────╯ +$ rm -rf heartwood +``` + +Specifying a different scope explicitly should update the policy: + +``` +$ rad clone rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji --scope all +✓ Seeding policy updated for rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji with scope 'all' +✓ Creating checkout in ./heartwood.. +✓ Repository successfully cloned under [..]/heartwood/ +╭────────────────────────────────────╮ +│ heartwood │ +│ Radicle Heartwood Protocol & Stack │ +│ 0 issues · 0 patches │ +╰────────────────────────────────────╯ +Run `cd ./heartwood` to go to the repository directory. +$ rad seed +╭────────────────────────────────────────────────────────────────╮ +│ Repository Name Policy Scope │ +├────────────────────────────────────────────────────────────────┤ +│ rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji heartwood allow all │ +╰────────────────────────────────────────────────────────────────╯ +$ rm -rf heartwood +``` + +Running `rad clone` again without an explicit scope parameter should not change the existing policy: + +``` +$ rad clone rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji +✓ Creating checkout in ./heartwood.. +✓ Repository successfully cloned under [..]/heartwood/ +╭────────────────────────────────────╮ +│ heartwood │ +│ Radicle Heartwood Protocol & Stack │ +│ 0 issues · 0 patches │ +╰────────────────────────────────────╯ +Run `cd ./heartwood` to go to the repository directory. +$ rad seed +╭────────────────────────────────────────────────────────────────╮ +│ Repository Name Policy Scope │ +├────────────────────────────────────────────────────────────────┤ +│ rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji heartwood allow all │ +╰────────────────────────────────────────────────────────────────╯ +``` diff --git a/crates/radicle-cli/tests/commands/clone.rs b/crates/radicle-cli/tests/commands/clone.rs index e6b69695..59932b82 100644 --- a/crates/radicle-cli/tests/commands/clone.rs +++ b/crates/radicle-cli/tests/commands/clone.rs @@ -295,3 +295,23 @@ fn test_clone_without_seeds() { .rad("inspect", &[], working.join("heartwood").as_path()) .unwrap(); } + +#[test] +fn rad_clone_scope() { + let mut environment = Environment::new(); + let mut alice = environment.node("alice"); + let working = environment.tempdir().join("working"); + + let rid = alice.project("heartwood", "Radicle Heartwood Protocol & Stack"); + + let mut alice = alice.spawn(); + alice.handle.unseed(rid).unwrap(); + + test( + "examples/rad-clone-scope.md", + working, + Some(&alice.home), + [], + ) + .unwrap(); +}