Skip to content

Commit 0693ce5

Browse files
committed
copy ignore crate for easier modifications
1 parent 5a0d233 commit 0693ce5

19 files changed

+6961
-7
lines changed

Cargo.lock

Lines changed: 20 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,3 @@ members = ["crates/*"]
55
[profile.release]
66
lto = true
77

8-
[patch.crates-io]
9-
ignore = { path = "./target/patch/ignore-0.4.23" }

crates/ignore/COPYING

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This project is dual-licensed under the Unlicense and MIT licenses.
2+
3+
You may use this code under the terms of either license.

crates/ignore/Cargo.toml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
[package]
2+
name = "ignore"
3+
version = "0.4.23" #:version
4+
authors = ["Andrew Gallant <jamslam@gmail.com>"]
5+
description = """
6+
A fast library for efficiently matching ignore files such as `.gitignore`
7+
against file paths.
8+
"""
9+
documentation = "https://docs.rs/ignore"
10+
homepage = "https://github.com/BurntSushi/ripgrep/tree/master/crates/ignore"
11+
repository = "https://github.com/BurntSushi/ripgrep/tree/master/crates/ignore"
12+
readme = "README.md"
13+
keywords = ["glob", "ignore", "gitignore", "pattern", "file"]
14+
license = "Unlicense OR MIT"
15+
edition = "2021"
16+
17+
[lib]
18+
name = "ignore"
19+
bench = false
20+
21+
[dependencies]
22+
crossbeam-deque = "0.8.3"
23+
globset = "0.4.15"
24+
log = "0.4.20"
25+
memchr = "2.6.3"
26+
same-file = "1.0.6"
27+
walkdir = "2.4.0"
28+
29+
[dependencies.regex-automata]
30+
version = "0.4.0"
31+
default-features = false
32+
features = ["std", "perf", "syntax", "meta", "nfa", "hybrid", "dfa-onepass"]
33+
34+
[target.'cfg(windows)'.dependencies.winapi-util]
35+
version = "0.1.2"
36+
37+
[dev-dependencies]
38+
bstr = { version = "1.6.2", default-features = false, features = ["std"] }
39+
crossbeam-channel = "0.5.8"
40+
41+
[features]
42+
# DEPRECATED. It is a no-op. SIMD is done automatically through runtime
43+
# dispatch.
44+
simd-accel = []

crates/ignore/LICENSE-MIT

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Andrew Gallant
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

crates/ignore/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
ignore
2+
======
3+
The ignore crate provides a fast recursive directory iterator that respects
4+
various filters such as globs, file types and `.gitignore` files. This crate
5+
also provides lower level direct access to gitignore and file type matchers.
6+
7+
[![Build status](https://github.com/BurntSushi/ripgrep/workflows/ci/badge.svg)](https://github.com/BurntSushi/ripgrep/actions)
8+
[![](https://img.shields.io/crates/v/ignore.svg)](https://crates.io/crates/ignore)
9+
10+
Dual-licensed under MIT or the [UNLICENSE](https://unlicense.org/).
11+
12+
### Documentation
13+
14+
[https://docs.rs/ignore](https://docs.rs/ignore)
15+
16+
### Usage
17+
18+
Add this to your `Cargo.toml`:
19+
20+
```toml
21+
[dependencies]
22+
ignore = "0.4"
23+
```
24+
25+
### Example
26+
27+
This example shows the most basic usage of this crate. This code will
28+
recursively traverse the current directory while automatically filtering out
29+
files and directories according to ignore globs found in files like
30+
`.ignore` and `.gitignore`:
31+
32+
33+
```rust,no_run
34+
use ignore::Walk;
35+
36+
for result in Walk::new("./") {
37+
// Each item yielded by the iterator is either a directory entry or an
38+
// error, so either print the path or the error.
39+
match result {
40+
Ok(entry) => println!("{}", entry.path().display()),
41+
Err(err) => println!("ERROR: {}", err),
42+
}
43+
}
44+
```
45+
46+
### Example: advanced
47+
48+
By default, the recursive directory iterator will ignore hidden files and
49+
directories. This can be disabled by building the iterator with `WalkBuilder`:
50+
51+
```rust,no_run
52+
use ignore::WalkBuilder;
53+
54+
for result in WalkBuilder::new("./").hidden(false).build() {
55+
println!("{:?}", result);
56+
}
57+
```
58+
59+
See the documentation for `WalkBuilder` for many other options.

crates/ignore/UNLICENSE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
This is free and unencumbered software released into the public domain.
2+
3+
Anyone is free to copy, modify, publish, use, compile, sell, or
4+
distribute this software, either in source code form or as a compiled
5+
binary, for any purpose, commercial or non-commercial, and by any
6+
means.
7+
8+
In jurisdictions that recognize copyright laws, the author or authors
9+
of this software dedicate any and all copyright interest in the
10+
software to the public domain. We make this dedication for the benefit
11+
of the public at large and to the detriment of our heirs and
12+
successors. We intend this dedication to be an overt act of
13+
relinquishment in perpetuity of all present and future rights to this
14+
software under copyright law.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.
23+
24+
For more information, please refer to <http://unlicense.org/>

crates/ignore/examples/walk.rs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
use std::{env, io::Write, path::Path};
2+
3+
use {bstr::ByteVec, ignore::WalkBuilder, walkdir::WalkDir};
4+
5+
fn main() {
6+
let mut path = env::args().nth(1).unwrap();
7+
let mut parallel = false;
8+
let mut simple = false;
9+
let (tx, rx) = crossbeam_channel::bounded::<DirEntry>(100);
10+
if path == "parallel" {
11+
path = env::args().nth(2).unwrap();
12+
parallel = true;
13+
} else if path == "walkdir" {
14+
path = env::args().nth(2).unwrap();
15+
simple = true;
16+
}
17+
18+
let stdout_thread = std::thread::spawn(move || {
19+
let mut stdout = std::io::BufWriter::new(std::io::stdout());
20+
for dent in rx {
21+
stdout.write(&*Vec::from_path_lossy(dent.path())).unwrap();
22+
stdout.write(b"\n").unwrap();
23+
}
24+
});
25+
26+
if parallel {
27+
let walker = WalkBuilder::new(path).threads(6).build_parallel();
28+
walker.run(|| {
29+
let tx = tx.clone();
30+
Box::new(move |result| {
31+
use ignore::WalkState::*;
32+
33+
tx.send(DirEntry::Y(result.unwrap())).unwrap();
34+
Continue
35+
})
36+
});
37+
} else if simple {
38+
let walker = WalkDir::new(path);
39+
for result in walker {
40+
tx.send(DirEntry::X(result.unwrap())).unwrap();
41+
}
42+
} else {
43+
let walker = WalkBuilder::new(path).build();
44+
for result in walker {
45+
tx.send(DirEntry::Y(result.unwrap())).unwrap();
46+
}
47+
}
48+
drop(tx);
49+
stdout_thread.join().unwrap();
50+
}
51+
52+
enum DirEntry {
53+
X(walkdir::DirEntry),
54+
Y(ignore::DirEntry),
55+
}
56+
57+
impl DirEntry {
58+
fn path(&self) -> &Path {
59+
match *self {
60+
DirEntry::X(ref x) => x.path(),
61+
DirEntry::Y(ref y) => y.path(),
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)