cli: don't override existing seeding scope in `rad clone`

This commit is contained in:
Defelo 2026-02-23 17:37:43 +01:00 committed by Fintan Halpenny
parent b04f487b3a
commit e9245b630d
2 changed files with 14 additions and 3 deletions

View File

@ -10,6 +10,7 @@ use radicle::git::raw;
use radicle::identity::doc; use radicle::identity::doc;
use radicle::identity::doc::RepoId; use radicle::identity::doc::RepoId;
use radicle::node; use radicle::node;
use radicle::node::policy;
use radicle::node::policy::Scope; use radicle::node::policy::Scope;
use radicle::node::{Handle as _, Node}; use radicle::node::{Handle as _, Node};
use radicle::prelude::*; use radicle::prelude::*;
@ -121,6 +122,8 @@ enum CloneError {
NoSeeds(RepoId), NoSeeds(RepoId),
#[error("fetch: {0}")] #[error("fetch: {0}")]
Fetch(#[from] sync::FetchError), Fetch(#[from] sync::FetchError),
#[error("policy store: {0}")]
PolicyStore(#[from] policy::store::Error),
} }
struct Checkout { struct Checkout {
@ -203,12 +206,21 @@ impl Checkout {
fn clone( fn clone(
id: RepoId, id: RepoId,
directory: Option<PathBuf>, directory: Option<PathBuf>,
scope: Scope, scope: Option<Scope>,
settings: SyncSettings, settings: SyncSettings,
node: &mut Node, node: &mut Node,
profile: &Profile, profile: &Profile,
bare: bool, bare: bool,
) -> Result<CloneResult, CloneError> { ) -> Result<CloneResult, CloneError> {
let scope = match scope {
Some(scope) => scope,
None => profile
.policies()?
.seed_policy(&id)?
.scope()
.unwrap_or(Scope::Followed),
};
// Seed repository. // Seed repository.
if node.seed(id, scope)? { if node.seed(id, scope)? {
term::success!( term::success!(

View File

@ -62,10 +62,9 @@ pub struct Args {
/// Follow scope /// Follow scope
#[arg( #[arg(
long, long,
default_value_t = Scope::Followed,
value_parser = terminal::args::ScopeParser value_parser = terminal::args::ScopeParser
)] )]
pub(super) scope: Scope, pub(super) scope: Option<Scope>,
#[clap(flatten)] #[clap(flatten)]
pub(super) sync: SyncArgs, pub(super) sync: SyncArgs,