From 98a4bf55cf76519e7f54b207f3a7919305ea4815 Mon Sep 17 00:00:00 2001 From: Michal Date: Sat, 23 Jul 2022 03:30:40 +0100 Subject: [PATCH] Cleanup --- src/operations/clone.rs | 1 + src/workspace/read.rs | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/operations/clone.rs b/src/operations/clone.rs index 74e442f..d45a20d 100644 --- a/src/operations/clone.rs +++ b/src/operations/clone.rs @@ -47,6 +47,7 @@ pub fn clone(verbose: bool) { info!("Cloning ({} mode): {}", config.base.mode, r.name); Command::new("git") .args(&["clone", &r.url, &r.name]) + // If a branch is specified, clone that specific branch .args(if r.branch.is_some() { vec!["-b", r.branch.as_ref().unwrap()] } else { diff --git a/src/workspace/read.rs b/src/workspace/read.rs index e3059e9..aac2a2c 100755 --- a/src/workspace/read.rs +++ b/src/workspace/read.rs @@ -52,23 +52,30 @@ pub fn read_cfg(verbose: bool) -> Config { // Parses all necessary values for expanding the repo to a Repo struct let index = split_struct.indx; + // If a branch is defined, parse it let branch = if split_struct.name.contains('@') { + log!(verbose, "Branch defined: {}", split_struct.name); Some( split_struct.name.split('@').collect::>()[1] .to_string() .replace('!', ""), ) } else { + log!(verbose, "No branch defined"); None }; + // Strip branch and priority info from the name, if present let name = if split_struct.name.contains('@') { split_struct.name.split('@').collect::>()[0].to_string() } else { split_struct.name.to_string().replace('!', "") }; + // Substitutes the name into the url let url = config.repositories.urls[index - 1].replace("%repo%", &name); + + // Counts instances of ! in the name, and totals a priority accordingly let priority = &split_struct.name.matches('!').count(); // Creates and pushes Repo struct to expanded_repos