Implemented cloning specific branches

main
Michal 2 years ago
parent 45cf3189ef
commit b455b6747b
No known key found for this signature in database
GPG Key ID: A6A1A4DCB22279B9

@ -16,7 +16,7 @@ on_gen = false
[repositories]
name = [
"1::amethyst",
"1::jade!",
"1::malachite@development!",
"2::notop-git",
"3::appendage",
]

@ -60,6 +60,7 @@ pub struct ConfigRepositoriesExpanded {
pub struct Repo {
pub name: String,
pub url: String,
pub branch: Option<String>,
pub priority: usize,
}

@ -47,6 +47,11 @@ pub fn clone(verbose: bool) {
info!("Cloning ({} mode): {}", config.base.mode, r.name);
Command::new("git")
.args(&["clone", &r.url, &r.name])
.args(if r.branch.is_some() {
vec!["-b", r.branch.as_ref().unwrap()]
} else {
vec![]
})
.spawn()
.unwrap()
.wait()

@ -51,7 +51,23 @@ pub fn read_cfg(verbose: bool) -> Config {
// Parses all necessary values for expanding the repo to a Repo struct
let index = split_struct.indx;
let name = split_struct.name.replace('!', "");
let branch = if split_struct.name.contains('@') {
Some(
split_struct.name.split('@').collect::<Vec<&str>>()[1]
.to_string()
.replace('!', ""),
)
} else {
None
};
let name = if split_struct.name.contains('@') {
split_struct.name.split('@').collect::<Vec<&str>>()[0].to_string()
} else {
split_struct.name.to_string().replace('!', "")
};
let url = config.repositories.urls[index - 1].replace("%repo%", &name);
let priority = &split_struct.name.matches('!').count();
@ -59,6 +75,7 @@ pub fn read_cfg(verbose: bool) -> Config {
let repo = Repo {
name,
url,
branch,
priority: *priority,
};
log!(verbose, "Expanded repo: {:?}", repo);

Loading…
Cancel
Save