Skip to content

Commit

Permalink
feat: Git global flag
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jul 13, 2019
1 parent 27edfc6 commit 1bd4ca8
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ struct Options {
no_ignore_dot: bool,
#[structopt(long, raw(overrides_with = r#""no-ignore-dot""#), raw(hidden = "true"))]
ignore_dot: bool,

#[structopt(long, raw(overrides_with = r#""ignore-global""#))]
/// Don't respect global ignore files.
no_ignore_global: bool,
#[structopt(
long,
raw(overrides_with = r#""no-ignore-global""#),
raw(hidden = "true")
)]
ignore_global: bool,
}

impl Options {
Expand Down Expand Up @@ -96,6 +106,16 @@ impl Options {
.or_else(|| self.ignore_files())
}

pub fn ignore_global(&self) -> Option<bool> {
match (self.no_ignore_global, self.ignore_global) {
(true, false) => Some(false),
(false, true) => Some(true),
(false, false) => None,
(_, _) => unreachable!("StructOpt should make this impossible"),
}
.or_else(|| self.ignore_files())
}

fn ignore_files(&self) -> Option<bool> {
match (self.no_ignore, self.ignore) {
(true, false) => Some(false),
Expand All @@ -121,7 +141,8 @@ fn run() -> Result<(), failure::Error> {
}
walk.threads(options.threads)
.hidden(options.ignore_hidden().unwrap_or(true))
.ignore(options.ignore_dot().unwrap_or(true));
.ignore(options.ignore_dot().unwrap_or(true))
.git_global(options.ignore_global().unwrap_or(true));
// TODO Add build_parallel for options.threads != 1
for entry in walk.build() {
let entry = entry?;
Expand Down

0 comments on commit 1bd4ca8

Please sign in to comment.