cli: Don't override existing seeding scope in `rad seed`
This commit is contained in:
parent
281f92e9ff
commit
52e5581228
|
|
@ -0,0 +1,38 @@
|
|||
By default `rad seed` should add a seeding policy with the `followed` scope:
|
||||
|
||||
```
|
||||
$ rad seed --no-fetch rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji
|
||||
✓ Seeding policy updated for rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji with scope 'followed'
|
||||
$ rad seed
|
||||
╭──────────────────────────────────────────────────────────────╮
|
||||
│ Repository Name Policy Scope │
|
||||
├──────────────────────────────────────────────────────────────┤
|
||||
│ rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji allow followed │
|
||||
╰──────────────────────────────────────────────────────────────╯
|
||||
```
|
||||
|
||||
The policy can be updated by explicitly specifying a different scope:
|
||||
|
||||
```
|
||||
$ rad seed --no-fetch rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji --scope all
|
||||
✓ Seeding policy updated for rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji with scope 'all'
|
||||
$ rad seed
|
||||
╭───────────────────────────────────────────────────────────╮
|
||||
│ Repository Name Policy Scope │
|
||||
├───────────────────────────────────────────────────────────┤
|
||||
│ rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji allow all │
|
||||
╰───────────────────────────────────────────────────────────╯
|
||||
```
|
||||
|
||||
Running `rad seed` again without an explicit scope parameter should not change the existing policy:
|
||||
|
||||
```
|
||||
$ rad seed --no-fetch rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji
|
||||
✓ Seeding policy exists for rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji with scope 'all'
|
||||
$ rad seed
|
||||
╭───────────────────────────────────────────────────────────╮
|
||||
│ Repository Name Policy Scope │
|
||||
├───────────────────────────────────────────────────────────┤
|
||||
│ rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji allow all │
|
||||
╰───────────────────────────────────────────────────────────╯
|
||||
```
|
||||
|
|
@ -41,10 +41,19 @@ pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
|
|||
|
||||
pub fn update(
|
||||
rid: RepoId,
|
||||
scope: Scope,
|
||||
scope: Option<Scope>,
|
||||
node: &mut Node,
|
||||
profile: &Profile,
|
||||
) -> Result<(), anyhow::Error> {
|
||||
let scope = match scope {
|
||||
Some(scope) => scope,
|
||||
None => profile
|
||||
.policies()?
|
||||
.seed_policy(&rid)?
|
||||
.scope()
|
||||
.unwrap_or(Scope::Followed),
|
||||
};
|
||||
|
||||
let updated = profile.seed(rid, scope, node)?;
|
||||
let outcome = if updated { "updated" } else { "exists" };
|
||||
|
||||
|
|
|
|||
|
|
@ -47,12 +47,8 @@ pub struct Args {
|
|||
timeout: u64,
|
||||
|
||||
/// Peer follow scope for this repository
|
||||
#[arg(
|
||||
long,
|
||||
default_value_t = Scope::Followed,
|
||||
value_parser = terminal::args::ScopeParser
|
||||
)]
|
||||
pub(super) scope: Scope,
|
||||
#[arg(long, value_parser = terminal::args::ScopeParser)]
|
||||
pub(super) scope: Option<Scope>,
|
||||
|
||||
/// Verbose output
|
||||
#[arg(long, short)]
|
||||
|
|
@ -65,7 +61,7 @@ pub(super) enum Operation {
|
|||
rids: NonEmpty<RepoId>,
|
||||
should_fetch: bool,
|
||||
settings: SyncSettings,
|
||||
scope: Scope,
|
||||
scope: Option<Scope>,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,11 @@ fn rad_seed_and_follow() {
|
|||
Environment::alice(["rad-seed-and-follow"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rad_seed_scope() {
|
||||
Environment::alice(["rad-seed-scope"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rad_seed_many() {
|
||||
let mut environment = Environment::new();
|
||||
|
|
|
|||
Loading…
Reference in New Issue