|
|
@@ -71,6 +71,7 @@ fn main() {
|
|
|
|
|
|
let git = git_options(&options, &input_paths);
|
|
|
let writer = io::stdout();
|
|
|
+ let git_repos = git_repos(&options, &input_paths);
|
|
|
|
|
|
let console_width = options.view.width.actual_terminal_width();
|
|
|
let theme = options.theme.to_theme(stdout_istty);
|
|
|
@@ -81,6 +82,7 @@ fn main() {
|
|
|
theme,
|
|
|
console_width,
|
|
|
git,
|
|
|
+ git_repos,
|
|
|
};
|
|
|
|
|
|
info!("matching on exa.run");
|
|
|
@@ -148,6 +150,8 @@ pub struct Exa<'args> {
|
|
|
/// This has to last the lifetime of the program, because the user might
|
|
|
/// want to list several directories in the same repository.
|
|
|
pub git: Option<GitCache>,
|
|
|
+
|
|
|
+ pub git_repos: bool,
|
|
|
}
|
|
|
|
|
|
/// The “real” environment variables type.
|
|
|
@@ -170,6 +174,51 @@ fn git_options(options: &Options, args: &[&OsStr]) -> Option<GitCache> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+fn get_files_in_dir(paths: &mut Vec<PathBuf>, path: PathBuf) {
|
|
|
+ let temp_paths = if path.is_dir() {
|
|
|
+ path.read_dir()
|
|
|
+ .unwrap()
|
|
|
+ .map(|entry| entry.unwrap().path())
|
|
|
+ .collect::<Vec<PathBuf>>()
|
|
|
+ } else {
|
|
|
+ vec![path]
|
|
|
+ };
|
|
|
+ paths.extend(temp_paths);
|
|
|
+}
|
|
|
+
|
|
|
+fn git_repos(options: &Options, args: &[&OsStr]) -> bool {
|
|
|
+ let option_enabled = match options.view.mode {
|
|
|
+ Mode::Details(details::Options {
|
|
|
+ table: Some(ref table),
|
|
|
+ ..
|
|
|
+ })
|
|
|
+ | Mode::GridDetails(grid_details::Options {
|
|
|
+ details:
|
|
|
+ details::Options {
|
|
|
+ table: Some(ref table),
|
|
|
+ ..
|
|
|
+ },
|
|
|
+ ..
|
|
|
+ }) => table.columns.subdir_git_repos || table.columns.subdir_git_repos_no_stat,
|
|
|
+ _ => false,
|
|
|
+ };
|
|
|
+ if option_enabled {
|
|
|
+ let paths: Vec<PathBuf> = args.iter().map(PathBuf::from).collect::<Vec<PathBuf>>();
|
|
|
+ let mut files: Vec<PathBuf> = Vec::new();
|
|
|
+ for path in paths {
|
|
|
+ get_files_in_dir(&mut files, path);
|
|
|
+ }
|
|
|
+ let repos: Vec<bool> = files
|
|
|
+ .iter()
|
|
|
+ .map(git2::Repository::open)
|
|
|
+ .map(|repo| repo.is_ok())
|
|
|
+ .collect();
|
|
|
+ repos.contains(&true)
|
|
|
+ } else {
|
|
|
+ false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
impl<'args> Exa<'args> {
|
|
|
/// # Errors
|
|
|
///
|
|
|
@@ -355,6 +404,7 @@ impl<'args> Exa<'args> {
|
|
|
|
|
|
let git_ignoring = self.options.filter.git_ignore == GitIgnore::CheckAndIgnore;
|
|
|
let git = self.git.as_ref();
|
|
|
+ let git_repos = self.git_repos;
|
|
|
let r = details::Render {
|
|
|
dir,
|
|
|
files,
|
|
|
@@ -365,6 +415,7 @@ impl<'args> Exa<'args> {
|
|
|
filter,
|
|
|
git_ignoring,
|
|
|
git,
|
|
|
+ git_repos,
|
|
|
};
|
|
|
r.render(&mut self.writer)
|
|
|
}
|
|
|
@@ -377,6 +428,7 @@ impl<'args> Exa<'args> {
|
|
|
let filter = &self.options.filter;
|
|
|
let git_ignoring = self.options.filter.git_ignore == GitIgnore::CheckAndIgnore;
|
|
|
let git = self.git.as_ref();
|
|
|
+ let git_repos = self.git_repos;
|
|
|
|
|
|
let r = grid_details::Render {
|
|
|
dir,
|
|
|
@@ -390,6 +442,7 @@ impl<'args> Exa<'args> {
|
|
|
git_ignoring,
|
|
|
git,
|
|
|
console_width,
|
|
|
+ git_repos,
|
|
|
};
|
|
|
r.render(&mut self.writer)
|
|
|
}
|
|
|
@@ -400,6 +453,7 @@ impl<'args> Exa<'args> {
|
|
|
let recurse = self.options.dir_action.recurse_options();
|
|
|
let git_ignoring = self.options.filter.git_ignore == GitIgnore::CheckAndIgnore;
|
|
|
let git = self.git.as_ref();
|
|
|
+ let git_repos = self.git_repos;
|
|
|
|
|
|
let r = details::Render {
|
|
|
dir,
|
|
|
@@ -411,6 +465,7 @@ impl<'args> Exa<'args> {
|
|
|
filter,
|
|
|
git_ignoring,
|
|
|
git,
|
|
|
+ git_repos,
|
|
|
};
|
|
|
r.render(&mut self.writer)
|
|
|
}
|