chore: merge 0.0.6 #6
3 changed files with 66 additions and 29 deletions
54
src/git.rs
54
src/git.rs
|
@ -217,6 +217,11 @@ impl GitRepo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct SeriesItem<'series> {
|
||||||
|
operation: &'series str,
|
||||||
|
closure: Box<dyn Fn(&GitRepo) -> (bool)>,
|
||||||
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
/* GIT RELATED */
|
/* GIT RELATED */
|
||||||
/// Reads the configuration toml from a path.
|
/// Reads the configuration toml from a path.
|
||||||
|
@ -278,13 +283,25 @@ impl Config {
|
||||||
/// without blocking the repos that don't have an issue.
|
/// without blocking the repos that don't have an issue.
|
||||||
///
|
///
|
||||||
/// This is actually somewhat hairy to do, at least at 6:16 am :S
|
/// This is actually somewhat hairy to do, at least at 6:16 am :S
|
||||||
fn series_on_all<F>(&self, f: F)
|
///
|
||||||
where
|
/// However, at 6:24, we're so ready! Let's go!
|
||||||
F: Fn(&GitRepo),
|
///
|
||||||
{
|
/// 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 (_, category) in self.categories.iter() {
|
||||||
for (_, repo) in category.repos.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.
|
/// repositories, skips if fail.
|
||||||
pub fn quick(&self, msg: &String) {
|
pub fn quick(&self, msg: &String) {
|
||||||
debug!("exectuting quick");
|
debug!("exectuting quick");
|
||||||
self.on_all_spinner("pull", |repo| repo.pull());
|
let series: Vec<SeriesItem> = vec![
|
||||||
self.on_all_spinner("add", |repo| repo.add_all());
|
SeriesItem {
|
||||||
self.on_all_spinner("commit", |repo| repo.commit_with_msg(msg));
|
operation: "pull",
|
||||||
self.on_all_spinner("push", |repo| repo.push());
|
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 */
|
/* LINK RELATED */
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// 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.
|
// along with this program. If not, see https://www.gnu.org/gpl-3.0.html.
|
||||||
|
#![feature(unsized_tuple_coercion)]
|
||||||
|
|
||||||
extern crate log;
|
extern crate log;
|
||||||
extern crate pretty_env_logger;
|
extern crate pretty_env_logger;
|
||||||
|
|
|
@ -1,24 +1,14 @@
|
||||||
categories:
|
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:
|
config:
|
||||||
flags: []
|
flags: []
|
||||||
repos:
|
repos:
|
||||||
|
qmk_firmware:
|
||||||
|
name: qmk_firmware
|
||||||
|
path: /home/ces/org/src/git/
|
||||||
|
url: git@github.com:cafkafk/qmk_firmware.git
|
||||||
|
flags:
|
||||||
|
- Clone
|
||||||
|
- Push
|
||||||
starship:
|
starship:
|
||||||
name: starship
|
name: starship
|
||||||
path: /home/ces/org/src/git/
|
path: /home/ces/org/src/git/
|
||||||
|
@ -26,10 +16,20 @@ categories:
|
||||||
flags:
|
flags:
|
||||||
- Clone
|
- Clone
|
||||||
- Push
|
- Push
|
||||||
qmk_firmware:
|
utils:
|
||||||
name: qmk_firmware
|
flags: []
|
||||||
|
repos:
|
||||||
|
li:
|
||||||
|
name: li
|
||||||
path: /home/ces/org/src/git/
|
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:
|
flags:
|
||||||
- Clone
|
- Clone
|
||||||
- Push
|
- Push
|
||||||
|
|
Loading…
Reference in a new issue