use std::path::PathBuf;
use crate::constants::{DEFAULT_BRANCH_NAME, DEFAULT_REMOTE_NAME};
#[derive(Clone, Debug)]
pub struct FetchOpts {
pub remote: String,
pub branch: String,
pub subtree_paths: Option<Vec<PathBuf>>,
pub depth: Option<i32>,
pub all: bool,
pub should_update_branch_head: bool,
pub missing_files: bool,
}
impl Default for FetchOpts {
fn default() -> Self {
Self::new()
}
}
impl FetchOpts {
pub fn new() -> FetchOpts {
FetchOpts {
remote: DEFAULT_REMOTE_NAME.to_string(),
branch: DEFAULT_BRANCH_NAME.to_string(),
subtree_paths: None,
depth: None,
all: false,
should_update_branch_head: true,
missing_files: false,
}
}
pub fn from_branch(branch: impl AsRef<str>) -> FetchOpts {
FetchOpts {
branch: branch.as_ref().to_string(),
..FetchOpts::new()
}
}
}