diff --git a/src/git.rs b/src/git.rs index 8322550..594ab53 100644 --- a/src/git.rs +++ b/src/git.rs @@ -236,6 +236,9 @@ impl Config { /// Runs associated function on all repos in config /// /// TODO: need to be made over a generic repo type + /// + /// NOTE: currently unused + /// fn on_all(&self, f: F) where F: Fn(&GitRepo), @@ -262,6 +265,29 @@ impl Config { } } } + /// Runs associated function on all repos in config + /// + /// TODO: need to be made over a generic repo type + /// + /// NOTE: currently unused + /// + /// # Current Problem + /// + /// The goal of this function is that it should run some function on all + /// repos but stop executing further functions on any repo that fails, + /// without blocking the repos that don't have an issue. + /// + /// This is actually somewhat hairy to do, at least at 6:16 am :S + fn series_on_all(&self, f: F) + where + F: Fn(&GitRepo), + { + for (_, category) in self.categories.iter() { + for (_, repo) in category.repos.iter() { + f(repo); + } + } + } /// Tries to pull all repositories, skips if fail. pub fn pull_all(&self) { debug!("exectuting pull_all"); @@ -291,17 +317,10 @@ impl Config { /// repositories, skips if fail. pub fn quick(&self, msg: &String) { debug!("exectuting quick"); - self.on_all(|repo| { - let mut sp = Spinner::new(Spinners::Dots10, format!("{}: pull", repo.name).into()); - repo.pull(); - sp = Spinner::new(Spinners::Dots10, format!("{}: add_all", repo.name).into()); - repo.add_all(); - sp = Spinner::new(Spinners::Dots10, format!("{}: commit", repo.name).into()); - repo.commit_with_msg(msg); - sp = Spinner::new(Spinners::Dots10, format!("{}: push", repo.name).into()); - repo.push(); - sp.stop_and_persist("✔", format!("{}: quick", repo.name).into()); - }); + self.on_all_spinner("pull", |repo| repo.pull()); + self.on_all_spinner("add", |repo| repo.add_all()); + self.on_all_spinner("commit", |repo| repo.commit_with_msg(msg)); + self.on_all_spinner("push", |repo| repo.push()); } /* LINK RELATED */ diff --git a/src/test/test.yaml b/src/test/test.yaml index b8dd2eb..4284adc 100644 --- a/src/test/test.yaml +++ b/src/test/test.yaml @@ -1,24 +1,14 @@ categories: - config: - flags: [] - repos: - qmk_firmware: - name: qmk_firmware - path: /home/ces/org/src/git/ - url: git@github.com:cafkafk/qmk_firmware.git - flags: - - Clone - - Push - starship: - name: starship - path: /home/ces/org/src/git/ - url: https://github.com/starship/starship.git - flags: - - Clone - - Push utils: flags: [] repos: + gg: + name: gg + path: /home/ces/.dots/ + url: git@github.com:cafkafk/gg.git + flags: + - Clone + - Push li: name: li path: /home/ces/org/src/git/ @@ -26,10 +16,20 @@ categories: flags: - Clone - Push - gg: - name: gg - path: /home/ces/.dots/ - url: git@github.com:cafkafk/gg.git + config: + flags: [] + repos: + starship: + name: starship + path: /home/ces/org/src/git/ + url: https://github.com/starship/starship.git + flags: + - Clone + - Push + qmk_firmware: + name: qmk_firmware + path: /home/ces/org/src/git/ + url: git@github.com:cafkafk/qmk_firmware.git flags: - Clone - Push