Skip to content

Commit

Permalink
feat(home): add thin option (#159)
Browse files Browse the repository at this point in the history
This can allow user to specify `--depth 1` option when cloning. Useful
for cloning some temporary repos.
  • Loading branch information
fioncat authored Dec 19, 2024
1 parent a66b094 commit db1db4c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/cmd/home.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ pub struct HomeArgs {
#[clap(short, long)]
pub open: bool,

/// If the repo does not exist and needs to be cloned, use `depth=1`.
#[clap(short, long)]
pub thin: bool,

/// Append these labels to the database.
#[clap(short, long)]
pub labels: Option<String>,
Expand Down Expand Up @@ -120,7 +124,12 @@ impl HomeArgs {
fn clone(&self, repo: &Repo, path: &Path) -> Result<()> {
let url = repo.clone_url();
let path = format!("{}", path.display());
Cmd::git(&["clone", url.as_str(), path.as_str()])
let mut args = vec!["clone"];
if self.thin {
args.extend(&["--depth", "1"]);
}
args.extend(&[url.as_str(), path.as_str()]);
Cmd::git(&args)
.with_display(format!("Clone {}", repo.name_with_remote()))
.execute()?;

Expand Down

0 comments on commit db1db4c

Please sign in to comment.