Added optional 2nd : delimiter for specifying clone depth

main
Michal 2 years ago
parent 8887abab97
commit 8f046dc2cb

@ -27,10 +27,10 @@ on_gen = false
[repositories] [repositories]
repos = [ repos = [
"foo:repo1", "foo:repo1:2",
"foo:repo2/testing", "foo:repo2/testing",
"bar:baz!", "bar:baz!",
"bar:qux/testing!", "bar:qux/testing!:1",
] ]
[repositories.urls] [repositories.urls]
@ -86,10 +86,10 @@ facilitate many packages without having to type each url out a million times.
```toml ```toml
[repositories] [repositories]
repos = [ repos = [
"foo:repo1", "foo:repo1:2",
"foo:repo2/testing", "foo:repo2/testing",
"bar:baz!", "bar:baz!",
"bar:qux/testing!", "bar:qux/testing!:1",
] ]
[repositories.urls] [repositories.urls]
@ -108,6 +108,7 @@ The way this works is simple:
I'm glad you asked! I'm glad you asked!
- If you want to clone a specific branch, simply use the `/` delimiter. To clone repository `foo` on branch `bar`, use `id:foo/bar`. - If you want to clone a specific branch, simply use the `/` delimiter. To clone repository `foo` on branch `bar`, use `id:foo/bar`.
- If you want a specific package to build first, use instances of `!` to set priority. This is explained later in the [Repository Mode](REPOSITORY_MODE.md) page - If you want a specific package to build first, use instances of `!` to set priority. This is explained later in the [Repository Mode](REPOSITORY_MODE.md) page
- If you want to clone the repository with a specific depth, for example, in the case of a large git repository like `nixpkgs`, you can add a 2nd `:` delimiter and the integer after that will be used as the depth
That's literally it! That's literally it!

@ -12,9 +12,11 @@ repos = [
"crs:malachite/development!", "crs:malachite/development!",
"aur:notop-git", "aur:notop-git",
"nms:appendage", "nms:appendage",
"nix:nixpkgs/nixos-unstable:ass",
] ]
[repositories.urls] [repositories.urls]
crs = "https://github.com/crystal-linux/{}" crs = "https://github.com/crystal-linux/{}"
aur = "https://aur.archlinux.org/{}" aur = "https://aur.archlinux.org/{}"
nms = "https://github.com/not-my-segfault/{}" nms = "https://github.com/not-my-segfault/{}"
nix = "https://github.com/nixos/{}"

@ -43,9 +43,26 @@ pub fn parse_cfg(verbose: bool) -> Config {
log!(verbose, "Parsing repo: {:?}", x); log!(verbose, "Parsing repo: {:?}", x);
// Splits the repo name and index inta a SplitRepo struct // Splits the repo name and index inta a SplitRepo struct
let split: Vec<&str> = x.split(':').collect(); let split: Vec<&str> = x.split(':').collect();
let split_struct = SplitRepo { let split_struct = if split.len() > 2 {
SplitRepo {
id: split[0].parse().unwrap(), id: split[0].parse().unwrap(),
name: split[1].parse().unwrap(), name: split[1].parse().unwrap(),
depth: Some(split[2].parse().unwrap_or_else(|e| {
crash!(
AppExitCode::ConfigParseError,
"Depth must be an integer: {}",
e
);
// This is unreachable, but rustc complains about it otherwise
std::process::exit(1);
})),
}
} else {
SplitRepo {
id: split[0].parse().unwrap(),
name: split[1].parse().unwrap(),
depth: None,
}
}; };
log!(verbose, "Split repo: {:?}", split_struct); log!(verbose, "Split repo: {:?}", split_struct);
@ -91,6 +108,7 @@ pub fn parse_cfg(verbose: bool) -> Config {
name, name,
url, url,
branch, branch,
depth: split_struct.depth,
priority: *priority, priority: *priority,
}; };
log!(verbose, "Expanded repo: {:?}", repo); log!(verbose, "Expanded repo: {:?}", repo);

@ -68,6 +68,7 @@ pub struct Repo {
pub name: String, pub name: String,
pub url: String, pub url: String,
pub branch: Option<String>, pub branch: Option<String>,
pub depth: Option<usize>,
pub priority: usize, pub priority: usize,
} }
@ -75,6 +76,7 @@ pub struct Repo {
pub struct SplitRepo { pub struct SplitRepo {
pub id: String, pub id: String,
pub name: String, pub name: String,
pub depth: Option<usize>,
} }
//// Build operation structs //// Build operation structs

@ -47,8 +47,23 @@ pub fn clone(verbose: bool) {
// Clone all diff repos // Clone all diff repos
for r in repo_diff { for r in repo_diff {
let depth = if r.depth.is_some() {
format!("{}", r.depth.as_ref().unwrap())
} else {
"".to_string()
};
log!(verbose, "Depth: {:?}", r.depth);
log!(verbose, "Cloning {}", r.name); log!(verbose, "Cloning {}", r.name);
if r.depth.is_some() {
info!(
"Cloning ({} mode): {} - Depth: {}",
config.base.mode,
r.name,
r.depth.unwrap()
);
} else {
info!("Cloning ({} mode): {}", config.base.mode, r.name); info!("Cloning ({} mode): {}", config.base.mode, r.name);
}
Command::new("git") Command::new("git")
.args(&["clone", &r.url, &r.name]) .args(&["clone", &r.url, &r.name])
// If a branch is specified, clone that specific branch // If a branch is specified, clone that specific branch
@ -57,6 +72,11 @@ pub fn clone(verbose: bool) {
} else { } else {
vec![] vec![]
}) })
.args(if depth.is_empty() {
vec![]
} else {
vec!["--depth", &depth]
})
.spawn() .spawn()
.unwrap() .unwrap()
.wait() .wait()

@ -159,7 +159,7 @@ pub fn info(verbose: bool) {
} }
} }
// Thanks memory management // Because spinoff requires &'static str, we need to Box these in the heap and then leak them to be able to format the spinner
let symbol = Box::new(format!("{}", "✔".bold().green())); let symbol = Box::new(format!("{}", "✔".bold().green()));
let done = Box::new(format!("{}", "Done!".bold())); let done = Box::new(format!("{}", "Done!".bold()));

Loading…
Cancel
Save