mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-21 16:41:01 -05:00
feat: VCS ignore flag
This commit is contained in:
parent
6bbf8390ff
commit
73054cca9e
1 changed files with 19 additions and 0 deletions
19
src/main.rs
19
src/main.rs
|
@ -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 {
|
||||
|
@ -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())
|
||||
}
|
||||
|
||||
|
@ -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),
|
||||
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue