Change search default to not use standard filters, and provide options to set filters manually

pull/218/head
Chip Senkbeil 11 months ago
parent c250acdfb4
commit f4180f6245
No known key found for this signature in database
GPG Key ID: 35EF1F8EC72A4131

@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- `use_hidden`, `use_ignore_files`, `use_parent_ignore_files`,
`use_git_ignore`, `use_global_git_ignore`, and `use_git_exclude` as new
options for searching
### Changed
- Searching now disables all standard filters by default with re-introducing
the ability to set the filters by individual options
### Fixed
- Failing to start a search will no longer cause the search task to exit when

@ -345,6 +345,13 @@ impl SearchQueryExecutor {
.build()
.map_err(|x| io::Error::new(io::ErrorKind::Other, x))?,
)
.standard_filters(false)
.hidden(query.options.ignore_hidden)
.ignore(query.options.use_ignore_files)
.parents(query.options.use_parent_ignore_files)
.git_ignore(query.options.use_git_ignore_files)
.git_global(query.options.use_global_git_ignore_files)
.git_exclude(query.options.use_git_exclude_files)
.skip_stdout(true);
if query.options.upward {

@ -230,6 +230,35 @@ pub struct SearchQueryOptions {
/// include the remaining results even if less than pagination request.
#[serde(skip_serializing_if = "Option::is_none")]
pub pagination: Option<u64>,
/// If true, will skip searching hidden files.
#[serde(skip_serializing_if = "utils::is_false")]
pub ignore_hidden: bool,
/// If true, will read `.ignore` files that are used by `ripgrep` and `The Silver Searcher`
/// to determine which files and directories to not search.
#[serde(skip_serializing_if = "utils::is_false")]
pub use_ignore_files: bool,
/// If true, will read `.ignore` files from parent directories that are used by `ripgrep` and
/// `The Silver Searcher` to determine which files and directories to not search.
#[serde(skip_serializing_if = "utils::is_false")]
pub use_parent_ignore_files: bool,
/// If true, will read `.gitignore` files to determine which files and directories to not
/// search.
#[serde(skip_serializing_if = "utils::is_false")]
pub use_git_ignore_files: bool,
/// If true, will read global `.gitignore` files to determine which files and directories to
/// not search.
#[serde(skip_serializing_if = "utils::is_false")]
pub use_global_git_ignore_files: bool,
/// If true, will read `.git/info/exclude` files to determine which files and directories to
/// not search.
#[serde(skip_serializing_if = "utils::is_false")]
pub use_git_exclude_files: bool,
}
/// Represents a match for a search query
@ -929,6 +958,12 @@ mod tests {
limit: None,
max_depth: None,
pagination: None,
ignore_hidden: false,
use_ignore_files: false,
use_parent_ignore_files: false,
use_git_ignore_files: false,
use_global_git_ignore_files: false,
use_git_exclude_files: false,
};
let value = serde_json::to_value(options).unwrap();
@ -950,6 +985,12 @@ mod tests {
limit: Some(u64::MAX),
max_depth: Some(u64::MAX),
pagination: Some(u64::MAX),
ignore_hidden: true,
use_ignore_files: true,
use_parent_ignore_files: true,
use_git_ignore_files: true,
use_global_git_ignore_files: true,
use_git_exclude_files: true,
};
let value = serde_json::to_value(options).unwrap();
@ -970,6 +1011,12 @@ mod tests {
"limit": u64::MAX,
"max_depth": u64::MAX,
"pagination": u64::MAX,
"ignore_hidden": true,
"use_ignore_files": true,
"use_parent_ignore_files": true,
"use_git_ignore_files": true,
"use_global_git_ignore_files": true,
"use_git_exclude_files": true,
})
);
}
@ -990,6 +1037,12 @@ mod tests {
limit: None,
max_depth: None,
pagination: None,
ignore_hidden: false,
use_ignore_files: false,
use_parent_ignore_files: false,
use_git_ignore_files: false,
use_global_git_ignore_files: false,
use_git_exclude_files: false,
}
);
}
@ -1011,6 +1064,12 @@ mod tests {
"limit": u64::MAX,
"max_depth": u64::MAX,
"pagination": u64::MAX,
"ignore_hidden": true,
"use_ignore_files": true,
"use_parent_ignore_files": true,
"use_git_ignore_files": true,
"use_global_git_ignore_files": true,
"use_git_exclude_files": true,
});
let options: SearchQueryOptions = serde_json::from_value(value).unwrap();
@ -1029,6 +1088,12 @@ mod tests {
limit: Some(u64::MAX),
max_depth: Some(u64::MAX),
pagination: Some(u64::MAX),
ignore_hidden: true,
use_ignore_files: true,
use_parent_ignore_files: true,
use_git_ignore_files: true,
use_global_git_ignore_files: true,
use_git_exclude_files: true,
}
);
}
@ -1044,6 +1109,12 @@ mod tests {
limit: None,
max_depth: None,
pagination: None,
ignore_hidden: false,
use_ignore_files: false,
use_parent_ignore_files: false,
use_git_ignore_files: false,
use_global_git_ignore_files: false,
use_git_exclude_files: false,
};
// NOTE: We don't actually check the output here because it's an implementation detail
@ -1068,6 +1139,12 @@ mod tests {
limit: Some(u64::MAX),
max_depth: Some(u64::MAX),
pagination: Some(u64::MAX),
ignore_hidden: true,
use_ignore_files: true,
use_parent_ignore_files: true,
use_git_ignore_files: true,
use_global_git_ignore_files: true,
use_git_exclude_files: true,
};
// NOTE: We don't actually check the output here because it's an implementation detail
@ -1092,6 +1169,12 @@ mod tests {
limit: None,
max_depth: None,
pagination: None,
ignore_hidden: false,
use_ignore_files: false,
use_parent_ignore_files: false,
use_git_ignore_files: false,
use_global_git_ignore_files: false,
use_git_exclude_files: false,
})
.unwrap();
@ -1107,6 +1190,12 @@ mod tests {
limit: None,
max_depth: None,
pagination: None,
ignore_hidden: false,
use_ignore_files: false,
use_parent_ignore_files: false,
use_git_ignore_files: false,
use_global_git_ignore_files: false,
use_git_exclude_files: false,
}
);
}
@ -1130,6 +1219,12 @@ mod tests {
limit: Some(u64::MAX),
max_depth: Some(u64::MAX),
pagination: Some(u64::MAX),
ignore_hidden: true,
use_ignore_files: true,
use_parent_ignore_files: true,
use_git_ignore_files: true,
use_global_git_ignore_files: true,
use_git_exclude_files: true,
})
.unwrap();
@ -1149,6 +1244,12 @@ mod tests {
limit: Some(u64::MAX),
max_depth: Some(u64::MAX),
pagination: Some(u64::MAX),
ignore_hidden: true,
use_ignore_files: true,
use_parent_ignore_files: true,
use_git_ignore_files: true,
use_global_git_ignore_files: true,
use_git_exclude_files: true,
}
);
}

@ -2114,6 +2114,12 @@ mod tests {
limit: Some(u64::MAX),
max_depth: Some(u64::MAX),
pagination: Some(u64::MAX),
ignore_hidden: true,
use_ignore_files: true,
use_parent_ignore_files: true,
use_git_ignore_files: true,
use_global_git_ignore_files: true,
use_git_exclude_files: true,
},
},
};
@ -2145,6 +2151,12 @@ mod tests {
"limit": u64::MAX,
"max_depth": u64::MAX,
"pagination": u64::MAX,
"ignore_hidden": true,
"use_ignore_files": true,
"use_parent_ignore_files": true,
"use_git_ignore_files": true,
"use_global_git_ignore_files": true,
"use_git_exclude_files": true,
},
},
})
@ -2205,6 +2217,12 @@ mod tests {
"limit": u64::MAX,
"max_depth": u64::MAX,
"pagination": u64::MAX,
"ignore_hidden": true,
"use_ignore_files": true,
"use_parent_ignore_files": true,
"use_git_ignore_files": true,
"use_global_git_ignore_files": true,
"use_git_exclude_files": true,
},
},
});
@ -2230,6 +2248,12 @@ mod tests {
limit: Some(u64::MAX),
max_depth: Some(u64::MAX),
pagination: Some(u64::MAX),
ignore_hidden: true,
use_ignore_files: true,
use_parent_ignore_files: true,
use_git_ignore_files: true,
use_global_git_ignore_files: true,
use_git_exclude_files: true,
},
},
}
@ -2274,6 +2298,12 @@ mod tests {
limit: Some(u64::MAX),
max_depth: Some(u64::MAX),
pagination: Some(u64::MAX),
ignore_hidden: true,
use_ignore_files: true,
use_parent_ignore_files: true,
use_git_ignore_files: true,
use_global_git_ignore_files: true,
use_git_exclude_files: true,
},
},
};
@ -2339,6 +2369,12 @@ mod tests {
limit: Some(u64::MAX),
max_depth: Some(u64::MAX),
pagination: Some(u64::MAX),
ignore_hidden: true,
use_ignore_files: true,
use_parent_ignore_files: true,
use_git_ignore_files: true,
use_global_git_ignore_files: true,
use_git_exclude_files: true,
},
},
})
@ -2365,6 +2401,12 @@ mod tests {
limit: Some(u64::MAX),
max_depth: Some(u64::MAX),
pagination: Some(u64::MAX),
ignore_hidden: true,
use_ignore_files: true,
use_parent_ignore_files: true,
use_git_ignore_files: true,
use_global_git_ignore_files: true,
use_git_exclude_files: true,
},
},
}

@ -55,6 +55,35 @@ pub struct CliSearchQueryOptions {
/// include the remaining results even if less than pagination request
#[clap(long)]
pub pagination: Option<u64>,
/// If true, will skip searching hidden files.
#[clap(long)]
pub ignore_hidden: bool,
/// If true, will read `.ignore` files that are used by `ripgrep` and `The Silver Searcher`
/// to determine which files and directories to not search.
#[clap(long)]
pub use_ignore_files: bool,
/// If true, will read `.ignore` files from parent directories that are used by `ripgrep` and
/// `The Silver Searcher` to determine which files and directories to not search.
#[clap(long)]
pub use_parent_ignore_files: bool,
/// If true, will read `.gitignore` files to determine which files and directories to not
/// search.
#[clap(long)]
pub use_git_ignore_files: bool,
/// If true, will read global `.gitignore` files to determine which files and directories to
/// not search.
#[clap(long)]
pub use_global_git_ignore_files: bool,
/// If true, will read `.git/info/exclude` files to determine which files and directories to
/// not search.
#[clap(long)]
pub use_git_exclude_files: bool,
}
impl From<CliSearchQueryOptions> for SearchQueryOptions {
@ -68,6 +97,12 @@ impl From<CliSearchQueryOptions> for SearchQueryOptions {
limit: x.limit,
max_depth: x.max_depth,
pagination: x.pagination,
ignore_hidden: x.ignore_hidden,
use_ignore_files: x.use_ignore_files,
use_parent_ignore_files: x.use_parent_ignore_files,
use_git_ignore_files: x.use_git_ignore_files,
use_global_git_ignore_files: x.use_global_git_ignore_files,
use_git_exclude_files: x.use_git_exclude_files,
}
}
}

Loading…
Cancel
Save