Skip to content

Commit

Permalink
fix fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisDavison committed Jun 6, 2024
1 parent 3819778 commit eee14e7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ description = "Wrapper around my common git commands"
shellexpand = "3.1.0"
anyhow = "1.0"
structopt = "0.3.26"
rayon = "1.10.0"
23 changes: 14 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use anyhow::{anyhow, Result};
use std::fs::read_dir;
use std::path::{Path, PathBuf};
use structopt::StructOpt;
use rayon::prelude::*;

use shellexpand::tilde;

Expand All @@ -23,8 +24,8 @@ enum OptCommand {
#[structopt(alias = "p")]
Push,
// /// Fetch commits and tags
// #[structopt(alias = "f")]
// Fetch,
#[structopt(alias = "f")]
Fetch,
/// Show short status
#[structopt(alias = "s")]
Stat,
Expand Down Expand Up @@ -91,7 +92,7 @@ fn main() {

let cmd = match opts.command {
OptCommand::Push => git::push,
// OptCommand::Fetch => git::fetch,
OptCommand::Fetch => git::fetch,
OptCommand::Stat => git::stat,
OptCommand::List => git::list,
OptCommand::Unclean => git::needs_attention,
Expand All @@ -108,17 +109,21 @@ fn main() {
.collect::<Vec<String>>(),
);
let mut outs = Vec::new();
for repo in all_repos {
match cmd(&repo, json) {
Ok(Some(out)) => {
let out: Vec<_> = all_repos.par_iter().map(|repo| {
cmd(&repo, json)
}).collect();
for output in out {
match output {
Ok(Some(thing)) => {
let thing = thing.replace(&common, "");
if json {
outs.push(out.replace(&common, ""));
outs.push(thing);
} else {
println!("{}", out.replace(&common, ""))
println!("{}", thing)
}
}
Ok(_) => (),
Err(e) => eprintln!("ERR Repo {}: {}", repo.display(), e),
Err(e) => eprintln!("ERR: {}", e),
}
}
if json {
Expand Down

0 comments on commit eee14e7

Please sign in to comment.