use std::path::{Path, PathBuf};
use crate::opts::FetchOpts;
use crate::opts::StorageOpts;
#[derive(Clone, Debug, Default)]
pub struct CloneOpts {
pub url: String,
pub dst: PathBuf,
pub fetch_opts: FetchOpts,
pub storage_opts: StorageOpts,
pub is_vfs: bool,
pub is_remote: bool,
}
impl CloneOpts {
pub fn new(url: impl AsRef<str>, dst: impl AsRef<Path>) -> CloneOpts {
CloneOpts {
url: url.as_ref().to_string(),
dst: dst.as_ref().to_path_buf(),
fetch_opts: FetchOpts::new(),
storage_opts: StorageOpts::from_path(dst.as_ref(), true),
is_vfs: false,
is_remote: false,
}
}
pub fn from_branch(
url: impl AsRef<str>,
dst: impl AsRef<Path>,
branch: impl AsRef<str>,
) -> CloneOpts {
CloneOpts {
fetch_opts: FetchOpts::from_branch(branch.as_ref()),
storage_opts: StorageOpts::from_path(dst.as_ref(), true),
is_vfs: false,
is_remote: false,
..CloneOpts::new(url, dst)
}
}
}