diff options
author | Nick Gerace <nickagerace@gmail.com> | 2021-02-14 23:54:25 -0500 |
---|---|---|
committer | Nick Gerace <nickagerace@gmail.com> | 2021-02-15 00:00:41 -0500 |
commit | 728208357158adcd5442b7e756578132d3b8e9c9 (patch) | |
tree | f6472129939a9962415f5e9437d105c4a237182d /src/driver.rs | |
parent | 22a247f62bd3c55b6046e990b2c8ba4d4441eee1 (diff) | |
download | gfold-728208357158adcd5442b7e756578132d3b8e9c9.zip |
Add display email feature
Add display email feature. Remove prettytable macros. Add shorthand
flag for all features without one. Log error during recursively opening
sub directories.
Diffstat (limited to 'src/driver.rs')
-rw-r--r-- | src/driver.rs | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/src/driver.rs b/src/driver.rs index f2d0869..b113921 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -3,7 +3,7 @@ use std::fs; use std::path::{Path, PathBuf}; use eyre::Result; -use log::debug; +use log::{debug, warn}; use crate::util; @@ -13,6 +13,7 @@ pub struct Config { pub include_non_repos: bool, pub no_color: bool, pub recursive: bool, + pub show_email: bool, pub skip_sort: bool, } @@ -60,19 +61,29 @@ impl Results { for entry in path_entries { let subpath = &entry?.path(); - // Ensure that the directory is not hidden. + // Ensure that our subpath is a directory and that it is not hidden. if subpath.is_dir() - && !util::get_short_name_for_directory(subpath, dir).starts_with(".") + && !util::get_short_name_for_directory(subpath, dir).starts_with('.') { - if git2::Repository::open(subpath).is_ok() { - repos.push(subpath.to_owned()); - } else { - if config.include_non_repos { - non_repos.push(subpath.to_owned()); - } - if config.recursive { - debug!("Recursive execution into directory: {:#?}", &subpath); - self.execute_in_directory(&config, &subpath)?; + match git2::Repository::open(subpath) { + Ok(_) => repos.push(subpath.to_owned()), + Err(e) => { + debug!( + "Tried to open {:#?} as git repository: {:#?}", + subpath, + e.message() + ); + if config.include_non_repos { + non_repos.push(subpath.to_owned()); + } + if config.recursive { + if let Err(e) = self.execute_in_directory(&config, &subpath) { + warn!( + "Encountered error during recursive walk into {:#?}: {:#?}", + &subpath, e + ); + } + } } } } @@ -92,6 +103,7 @@ impl Results { &dir, &config.enable_unpushed_check, &config.no_color, + &config.show_email, ) { self.0.push(table_wrapper); } |