"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "crates/ignore/src/dir.rs" between
ripgrep-12.1.1.tar.gz and ripgrep-13.0.0.tar.gz

About: ripgrep is a command line search tool ("rg") that tries to combine the usability of "ag" (an "ack" clone) with the raw speed of GNU "grep" (written in "Rust").

dir.rs  (ripgrep-12.1.1):dir.rs  (ripgrep-13.0.0)
skipping to change at line 23 skipping to change at line 23
// with non-obvious failure modes. Alas, such things haven't been documented // with non-obvious failure modes. Alas, such things haven't been documented
// well. // well.
use std::collections::HashMap; use std::collections::HashMap;
use std::ffi::{OsStr, OsString}; use std::ffi::{OsStr, OsString};
use std::fs::{File, FileType}; use std::fs::{File, FileType};
use std::io::{self, BufRead}; use std::io::{self, BufRead};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};
use gitignore::{self, Gitignore, GitignoreBuilder}; use crate::gitignore::{self, Gitignore, GitignoreBuilder};
use overrides::{self, Override}; use crate::overrides::{self, Override};
use pathutil::{is_hidden, strip_prefix}; use crate::pathutil::{is_hidden, strip_prefix};
use types::{self, Types}; use crate::types::{self, Types};
use walk::DirEntry; use crate::walk::DirEntry;
use {Error, Match, PartialErrorBuilder}; use crate::{Error, Match, PartialErrorBuilder};
/// IgnoreMatch represents information about where a match came from when using /// IgnoreMatch represents information about where a match came from when using
/// the `Ignore` matcher. /// the `Ignore` matcher.
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct IgnoreMatch<'a>(IgnoreMatchInner<'a>); pub struct IgnoreMatch<'a>(IgnoreMatchInner<'a>);
/// IgnoreMatchInner describes precisely where the match information came from. /// IgnoreMatchInner describes precisely where the match information came from.
/// This is private to allow expansion to more matchers in the future. /// This is private to allow expansion to more matchers in the future.
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
enum IgnoreMatchInner<'a> { enum IgnoreMatchInner<'a> {
skipping to change at line 498 skipping to change at line 498
m_custom_ignore m_custom_ignore
.or(m_ignore) .or(m_ignore)
.or(m_gi) .or(m_gi)
.or(m_gi_exclude) .or(m_gi_exclude)
.or(m_global) .or(m_global)
.or(m_explicit) .or(m_explicit)
} }
/// Returns an iterator over parent ignore matchers, including this one. /// Returns an iterator over parent ignore matchers, including this one.
pub fn parents(&self) -> Parents { pub fn parents(&self) -> Parents<'_> {
Parents(Some(self)) Parents(Some(self))
} }
/// Returns the first absolute path of the first absolute parent, if /// Returns the first absolute path of the first absolute parent, if
/// one exists. /// one exists.
fn absolute_base(&self) -> Option<&Path> { fn absolute_base(&self) -> Option<&Path> {
self.0.absolute_base.as_ref().map(|p| &***p) self.0.absolute_base.as_ref().map(|p| &***p)
} }
} }
skipping to change at line 584 skipping to change at line 584
pub fn build(&self) -> Ignore { pub fn build(&self) -> Ignore {
let git_global_matcher = if !self.opts.git_global { let git_global_matcher = if !self.opts.git_global {
Gitignore::empty() Gitignore::empty()
} else { } else {
let mut builder = GitignoreBuilder::new(""); let mut builder = GitignoreBuilder::new("");
builder builder
.case_insensitive(self.opts.ignore_case_insensitive) .case_insensitive(self.opts.ignore_case_insensitive)
.unwrap(); .unwrap();
let (gi, err) = builder.build_global(); let (gi, err) = builder.build_global();
if let Some(err) = err { if let Some(err) = err {
debug!("{}", err); log::debug!("{}", err);
} }
gi gi
}; };
Ignore(Arc::new(IgnoreInner { Ignore(Arc::new(IgnoreInner {
compiled: Arc::new(RwLock::new(HashMap::new())), compiled: Arc::new(RwLock::new(HashMap::new())),
dir: self.dir.clone(), dir: self.dir.clone(),
overrides: self.overrides.clone(), overrides: self.overrides.clone(),
types: self.types.clone(), types: self.types.clone(),
parent: None, parent: None,
skipping to change at line 843 skipping to change at line 843
}; };
Ok(commondir_abs) Ok(commondir_abs)
} }
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::fs::{self, File}; use std::fs::{self, File};
use std::io::Write; use std::io::Write;
use std::path::Path; use std::path::Path;
use dir::IgnoreBuilder; use crate::dir::IgnoreBuilder;
use gitignore::Gitignore; use crate::gitignore::Gitignore;
use tests::TempDir; use crate::tests::TempDir;
use Error; use crate::Error;
fn wfile<P: AsRef<Path>>(path: P, contents: &str) { fn wfile<P: AsRef<Path>>(path: P, contents: &str) {
let mut file = File::create(path).unwrap(); let mut file = File::create(path).unwrap();
file.write_all(contents.as_bytes()).unwrap(); file.write_all(contents.as_bytes()).unwrap();
} }
fn mkdirp<P: AsRef<Path>>(path: P) { fn mkdirp<P: AsRef<Path>>(path: P) {
fs::create_dir_all(path).unwrap(); fs::create_dir_all(path).unwrap();
} }
 End of changes. 4 change blocks. 
12 lines changed or deleted 12 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)