chore: merge 0.0.6 #6

Merged
cafkafk merged 28 commits from dev into main 2023-07-02 10:35:50 +02:00
3 changed files with 66 additions and 29 deletions
Showing only changes of commit 3f05ae827a - Show all commits

View file

@ -217,6 +217,11 @@ impl GitRepo {
}
}
struct SeriesItem<'series> {
operation: &'series str,
closure: Box<dyn Fn(&GitRepo) -> (bool)>,
}
impl Config {
/* GIT RELATED */
/// Reads the configuration toml from a path.
@ -278,13 +283,25 @@ impl Config {
/// 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<F>(&self, f: F)
where
F: Fn(&GitRepo),
{
///
/// However, at 6:24, we're so ready! Let's go!
///
/// Fun fact: only the last element of a tuple must have a dynamically typed size
fn series_on_all(&self, closures: Vec<SeriesItem>) {
for (_, category) in self.categories.iter() {
for (_, repo) in category.repos.iter() {
f(repo);
for instruction in closures.iter() {
let f = &instruction.closure;
let op = instruction.operation;
let mut sp =
Spinner::new(Spinners::Dots10, format!("{}: {}", repo.name, op).into());
if f(repo) {
sp.stop_and_persist("", format!("{}: {}", repo.name, op).into());
} else {
sp.stop_and_persist("", format!("{}: {}", repo.name, op).into());
break;
}
}
}
}
}
@ -317,10 +334,29 @@ impl Config {
/// repositories, skips if fail.
pub fn quick(&self, msg: &String) {
debug!("exectuting quick");
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());
let series: Vec<SeriesItem> = vec![
SeriesItem {
operation: "pull",
closure: Box::new(move |repo: &GitRepo| repo.pull()),
},
SeriesItem {
operation: "add",
closure: Box::new(move |repo: &GitRepo| repo.add_all()),
},
SeriesItem {
operation: "commit",
closure: Box::new(move |repo: &GitRepo| repo.commit()),
}, // FIXME doesn't take msg
SeriesItem {
operation: "push",
closure: Box::new(move |repo: &GitRepo| repo.push()),
},
];
self.series_on_all(series);
// 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 */

View file

@ -13,6 +13,7 @@
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see https://www.gnu.org/gpl-3.0.html.
#![feature(unsized_tuple_coercion)]
extern crate log;
extern crate pretty_env_logger;

View file

@ -1,24 +1,14 @@
categories:
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/
url: git@github.com:cafkafk/li.git
flags:
- Clone
- Push
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/
@ -26,10 +16,20 @@ categories:
flags:
- Clone
- Push
qmk_firmware:
name: qmk_firmware
utils:
flags: []
repos:
li:
name: li
path: /home/ces/org/src/git/
url: git@github.com:cafkafk/qmk_firmware.git
url: git@github.com:cafkafk/li.git
flags:
- Clone
- Push
gg:
name: gg
path: /home/ces/.dots/
url: git@github.com:cafkafk/gg.git
flags:
- Clone
- Push