chore: merge 0.0.6 #6

Merged
cafkafk merged 28 commits from dev into main 2023-07-02 10:35:50 +02:00
Showing only changes of commit 6cebe88131 - Show all commits

View file

@ -210,6 +210,17 @@ impl Config {
) )
}) })
} }
/// Runs associated function on all repos in config
fn on_all<F>(&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. /// Tries to pull all repositories, skips if fail.
pub fn pull_all(&self) { pub fn pull_all(&self) {
debug!("exectuting pull_all"); debug!("exectuting pull_all");
@ -222,51 +233,41 @@ impl Config {
/// Tries to clone all repositories, skips if fail. /// Tries to clone all repositories, skips if fail.
pub fn clone_all(&self) { pub fn clone_all(&self) {
debug!("exectuting clone_all"); debug!("exectuting clone_all");
for category in self.categories.iter() { self.on_all(|repo| {
for repo in category.repos.iter() { repo.clone();
repo.clone(); });
}
}
} }
/// Tries to add all work in all repositories, skips if fail. /// Tries to add all work in all repositories, skips if fail.
pub fn add_all(&self) { pub fn add_all(&self) {
debug!("exectuting clone_all"); debug!("exectuting clone_all");
for category in self.categories.iter() { self.on_all(|repo| {
for repo in category.repos.iter() { repo.add_all();
repo.add_all(); });
}
}
} }
/// Tries to commit all repositories one at a time, skips if fail. /// Tries to commit all repositories one at a time, skips if fail.
pub fn commit_all(&self) { pub fn commit_all(&self) {
debug!("exectuting clone_all"); debug!("exectuting clone_all");
for category in self.categories.iter() { self.on_all(|repo| {
for repo in category.repos.iter() { repo.commit();
repo.commit(); });
}
}
} }
/// Tries to commit all repositories with msg, skips if fail. /// Tries to commit all repositories with msg, skips if fail.
pub fn commit_all_msg(&self, msg: &String) { pub fn commit_all_msg(&self, msg: &String) {
debug!("exectuting clone_all"); debug!("exectuting clone_all");
for category in self.categories.iter() { self.on_all(|repo| {
for repo in category.repos.iter() { repo.commit_with_msg(msg);
repo.commit_with_msg(msg); });
}
}
} }
/// Tries to pull, add all, commit with msg "quick commit", and push all /// Tries to pull, add all, commit with msg "quick commit", and push all
/// repositories, skips if fail. /// repositories, skips if fail.
pub fn quick(&self, msg: &String) { pub fn quick(&self, msg: &String) {
debug!("exectuting quick"); debug!("exectuting quick");
for category in self.categories.iter() { self.on_all(|repo| {
for repo in category.repos.iter() { repo.pull();
repo.pull(); repo.add_all();
repo.add_all(); repo.commit_with_msg(msg);
repo.commit_with_msg(msg); repo.push();
repo.push(); });
}
}
} }
/* LINK RELATED */ /* LINK RELATED */