case insensitive extension matching (fixes #43)

This commit is contained in:
phiresky 2020-05-19 11:14:43 +02:00
parent 2924c8e007
commit 63a9618357
4 changed files with 13 additions and 8 deletions

View File

@ -1,7 +1,8 @@
# 0.9.6 (2020-05-18)
- Fix windows builds
- Move to Github Actions instead of Travis
- Fix windows builds
- Case insensitive file extension matching
- Move to Github Actions instead of Travis
# 0.9.5 (2020-04-08)

2
Cargo.lock generated
View File

@ -1008,7 +1008,7 @@ dependencies = [
[[package]]
name = "ripgrep_all"
version = "0.9.13-alpha.0"
version = "0.9.6-alpha.0"
dependencies = [
"bincode",
"bzip2",

View File

@ -1,4 +1,5 @@
use failure::Fallible;
use log::*;
use rga::adapters::spawning::map_exe_error;
use rga::adapters::*;
use rga::args::*;
@ -75,8 +76,8 @@ fn main() -> Result<(), exitfailure::ExitFailure> {
let extensions = adapters
.iter()
.flat_map(|a| &a.metadata().fast_matchers)
.filter_map(|m| match m {
FastMatcher::FileExtension(ext) => Some(ext as &str),
.flat_map(|m| match m {
FastMatcher::FileExtension(ext) => vec![ext.clone(), ext.to_ascii_uppercase()],
})
.collect::<Vec<_>>()
.join(",");
@ -94,10 +95,13 @@ fn main() -> Result<(), exitfailure::ExitFailure> {
"--smart-case",
];
let exe = std::env::current_exe().expect("Could not get executable location");
let preproc_exe = exe.with_file_name("rga-preproc");
let mut child = Command::new("rg")
.args(rg_args)
.arg("--pre")
.arg("rga-preproc")
.arg(preproc_exe)
.arg("--pre-glob")
.arg(pre_glob)
.args(passthrough_args)
@ -108,7 +112,7 @@ fn main() -> Result<(), exitfailure::ExitFailure> {
Ok(())
}
/// add the directory that contains `rga` to PATH, so ripgrep can find rga-preproc and rga-preproc can find pandoc etc (if we are on Windows where we include dependent binaries)
/// add the directory that contains `rga` to PATH, so rga-preproc can find pandoc etc (if we are on Windows where we include dependent binaries)
fn add_exe_to_path() -> Fallible<()> {
use std::env;
let mut exe = env::current_exe().expect("Could not get executable location");

View File

@ -42,7 +42,7 @@ pub struct FileMeta {
}
pub fn extension_to_regex(extension: &str) -> Regex {
Regex::new(&format!("\\.{}$", &regex::escape(extension))).expect("we know this regex compiles")
Regex::new(&format!("(?i)\\.{}$", &regex::escape(extension))).expect("we know this regex compiles")
}
pub fn adapter_matcher<T: AsRef<str>>(