diff --git a/src/cmd/clone.rs b/src/cmd/clone.rs index 43079e5..69f8d5e 100644 --- a/src/cmd/clone.rs +++ b/src/cmd/clone.rs @@ -37,8 +37,8 @@ pub struct Cmd { parallel: bool, /// Clones their submodules recursively. - #[clap(short, long)] - recursive: bool, + #[clap(short, long, alias = "recurse-submodules")] + recursive: Option>, /// Clones only the default branch. #[clap(long)] @@ -178,7 +178,7 @@ impl Cmd { url.clone(), &path, &CloneOptions { - recursive: self.recursive, + recursive: self.recursive.clone(), single_branch: self.single_branch, }, ) { diff --git a/src/git/mod.rs b/src/git/mod.rs index 95b916b..d6738c3 100644 --- a/src/git/mod.rs +++ b/src/git/mod.rs @@ -9,7 +9,7 @@ use anyhow::Result; #[derive(Debug, Default)] pub struct CloneOptions { - pub recursive: bool, + pub recursive: Option>, pub single_branch: bool, } diff --git a/src/git/strategy/cli.rs b/src/git/strategy/cli.rs index dbd8b79..7c92f4b 100644 --- a/src/git/strategy/cli.rs +++ b/src/git/strategy/cli.rs @@ -16,13 +16,20 @@ impl CloneRepository for Cli { { debug!("Cloning the repository using CLI strategy"); - let url = url.to_string(); - let mut args = vec!["clone", &url, path.as_ref().to_str().unwrap()]; - if options.recursive { - args.push("--recursive"); + let mut args = vec![ + "clone".to_string(), + url.to_string(), + path.as_ref().to_string_lossy().to_string(), + ]; + + if let Some(recursive) = options.recursive.as_ref() { + args.push(match recursive.as_deref() { + Some(path) => format!("--recurse-submodules={path}"), + _ => "--recurse-submodules".to_string(), + }); } if options.single_branch { - args.push("--single-branch") + args.push("--single-branch".to_string()); } let output = Command::new("git").args(args).output()?;