Skip to content

Commit

Permalink
feat: VCS ignore flag
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jul 13, 2019
1 parent 6bbf839 commit 73054cc
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ struct Options {
raw(hidden = "true")
)]
ignore_parent: bool,

#[structopt(long, raw(overrides_with = r#""ignore-vcs""#))]
/// Don't respect ignore files in vcs directories.
no_ignore_vcs: bool,
#[structopt(long, raw(overrides_with = r#""no-ignore-vcs""#), raw(hidden = "true"))]
ignore_vcs: bool,
}

impl Options {
Expand Down Expand Up @@ -123,6 +129,7 @@ impl Options {
(false, false) => None,
(_, _) => unreachable!("StructOpt should make this impossible"),
}
.or_else(|| self.ignore_vcs())
.or_else(|| self.ignore_files())
}

Expand All @@ -136,6 +143,16 @@ impl Options {
.or_else(|| self.ignore_files())
}

pub fn ignore_vcs(&self) -> Option<bool> {
match (self.no_ignore_vcs, self.ignore_vcs) {
(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 Down Expand Up @@ -163,6 +180,8 @@ fn run() -> Result<(), failure::Error> {
.hidden(options.ignore_hidden().unwrap_or(true))
.ignore(options.ignore_dot().unwrap_or(true))
.git_global(options.ignore_global().unwrap_or(true))
.git_ignore(options.ignore_vcs().unwrap_or(true))
.git_exclude(options.ignore_vcs().unwrap_or(true))
.parents(options.ignore_parent().unwrap_or(true));
// TODO Add build_parallel for options.threads != 1
for entry in walk.build() {
Expand Down

0 comments on commit 73054cc

Please sign in to comment.