-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Add @source not
support
#17255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add @source not
support
#17255
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
ff98e6d
copy `ignore` crate for easier modifications
RobinMalfait 18442be
manually apply patches to inlined `ignore` crate
RobinMalfait 22bd00f
run all CI tests when `[ci-all]` exists in PR description
RobinMalfait ba153be
big refactor, move `Scanner` to `scanner/mod.rs`
RobinMalfait 72b18cd
simplify `scanner` test setup
RobinMalfait cd6ccb2
add new Scanner tests
RobinMalfait 324569c
update public Rust API
RobinMalfait 335e9e1
update use statements due to big refactor
RobinMalfait 88a6048
rename `globs` to `sources`
RobinMalfait 602a801
add `negated` flag to `sources`
RobinMalfait 9798637
add missing `reference` property
RobinMalfait 9958612
update integration tests
RobinMalfait 878782e
use `normalizedSources` in the CLI
RobinMalfait a7bef4e
add `.gitignore` as a default ignored file
RobinMalfait 8d154d1
add `node_modules` as a default ignored folder
RobinMalfait 38ed37e
add `enableSourceNot` feature flag
RobinMalfait 0f73797
run prettier
RobinMalfait 97fc4bf
Simplify gitignore order change
philipp-spiess 94473d3
Rename GitHub CI var
philipp-spiess 7442baa
Explicitly mark test functions
philipp-spiess 2425aef
Handle source paths into ignored content dirs as "external"
philipp-spiess bb0610d
Revert "Explicitly mark test functions"
philipp-spiess 6952871
Explicitly mark test functions
philipp-spiess b6ab98f
Cleanup comment
philipp-spiess 5e7d035
Cleanup public source entry creation
philipp-spiess 9d4c2af
Cleanups and test utf8 special characters in paths
philipp-spiess File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This project is dual-licensed under the Unlicense and MIT licenses. | ||
|
||
You may use this code under the terms of either license. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
[package] | ||
name = "ignore" | ||
version = "0.4.23" #:version | ||
authors = ["Andrew Gallant <jamslam@gmail.com>"] | ||
description = """ | ||
A fast library for efficiently matching ignore files such as `.gitignore` | ||
against file paths. | ||
""" | ||
documentation = "https://docs.rs/ignore" | ||
homepage = "https://github.com/BurntSushi/ripgrep/tree/master/crates/ignore" | ||
repository = "https://github.com/BurntSushi/ripgrep/tree/master/crates/ignore" | ||
readme = "README.md" | ||
keywords = ["glob", "ignore", "gitignore", "pattern", "file"] | ||
license = "Unlicense OR MIT" | ||
edition = "2021" | ||
|
||
[lib] | ||
name = "ignore" | ||
bench = false | ||
|
||
[dependencies] | ||
crossbeam-deque = "0.8.3" | ||
globset = "0.4.16" | ||
log = "0.4.20" | ||
memchr = "2.6.3" | ||
same-file = "1.0.6" | ||
walkdir = "2.4.0" | ||
dunce = "1.0.5" | ||
|
||
[dependencies.regex-automata] | ||
version = "0.4.0" | ||
default-features = false | ||
features = ["std", "perf", "syntax", "meta", "nfa", "hybrid", "dfa-onepass"] | ||
|
||
[target.'cfg(windows)'.dependencies.winapi-util] | ||
version = "0.1.2" | ||
|
||
[dev-dependencies] | ||
bstr = { version = "1.6.2", default-features = false, features = ["std"] } | ||
crossbeam-channel = "0.5.8" | ||
|
||
[features] | ||
# DEPRECATED. It is a no-op. SIMD is done automatically through runtime | ||
# dispatch. | ||
simd-accel = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Andrew Gallant | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# ignore | ||
|
||
The ignore crate provides a fast recursive directory iterator that respects | ||
various filters such as globs, file types and `.gitignore` files. This crate | ||
also provides lower level direct access to gitignore and file type matchers. | ||
|
||
[](https://github.com/BurntSushi/ripgrep/actions) | ||
[](https://crates.io/crates/ignore) | ||
|
||
Dual-licensed under MIT or the [UNLICENSE](https://unlicense.org/). | ||
|
||
### Documentation | ||
|
||
[https://docs.rs/ignore](https://docs.rs/ignore) | ||
|
||
### Usage | ||
|
||
Add this to your `Cargo.toml`: | ||
|
||
```toml | ||
[dependencies] | ||
ignore = "0.4" | ||
``` | ||
|
||
### Example | ||
|
||
This example shows the most basic usage of this crate. This code will | ||
recursively traverse the current directory while automatically filtering out | ||
files and directories according to ignore globs found in files like | ||
`.ignore` and `.gitignore`: | ||
|
||
```rust,no_run | ||
use ignore::Walk; | ||
|
||
for result in Walk::new("./") { | ||
// Each item yielded by the iterator is either a directory entry or an | ||
// error, so either print the path or the error. | ||
match result { | ||
Ok(entry) => println!("{}", entry.path().display()), | ||
Err(err) => println!("ERROR: {}", err), | ||
} | ||
} | ||
``` | ||
|
||
### Example: advanced | ||
|
||
By default, the recursive directory iterator will ignore hidden files and | ||
directories. This can be disabled by building the iterator with `WalkBuilder`: | ||
|
||
```rust,no_run | ||
use ignore::WalkBuilder; | ||
|
||
for result in WalkBuilder::new("./").hidden(false).build() { | ||
println!("{:?}", result); | ||
} | ||
``` | ||
|
||
See the documentation for `WalkBuilder` for many other options. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
This is free and unencumbered software released into the public domain. | ||
|
||
Anyone is free to copy, modify, publish, use, compile, sell, or | ||
distribute this software, either in source code form or as a compiled | ||
binary, for any purpose, commercial or non-commercial, and by any | ||
means. | ||
|
||
In jurisdictions that recognize copyright laws, the author or authors | ||
of this software dedicate any and all copyright interest in the | ||
software to the public domain. We make this dedication for the benefit | ||
of the public at large and to the detriment of our heirs and | ||
successors. We intend this dedication to be an overt act of | ||
relinquishment in perpetuity of all present and future rights to this | ||
software under copyright law. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
For more information, please refer to <http://unlicense.org/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
use std::{env, io::Write, path::Path}; | ||
|
||
use {bstr::ByteVec, ignore::WalkBuilder, walkdir::WalkDir}; | ||
|
||
fn main() { | ||
let mut path = env::args().nth(1).unwrap(); | ||
let mut parallel = false; | ||
let mut simple = false; | ||
let (tx, rx) = crossbeam_channel::bounded::<DirEntry>(100); | ||
if path == "parallel" { | ||
path = env::args().nth(2).unwrap(); | ||
parallel = true; | ||
} else if path == "walkdir" { | ||
path = env::args().nth(2).unwrap(); | ||
simple = true; | ||
} | ||
|
||
let stdout_thread = std::thread::spawn(move || { | ||
let mut stdout = std::io::BufWriter::new(std::io::stdout()); | ||
for dent in rx { | ||
stdout.write(&*Vec::from_path_lossy(dent.path())).unwrap(); | ||
stdout.write(b"\n").unwrap(); | ||
} | ||
}); | ||
|
||
if parallel { | ||
let walker = WalkBuilder::new(path).threads(6).build_parallel(); | ||
walker.run(|| { | ||
let tx = tx.clone(); | ||
Box::new(move |result| { | ||
use ignore::WalkState::*; | ||
|
||
tx.send(DirEntry::Y(result.unwrap())).unwrap(); | ||
Continue | ||
}) | ||
}); | ||
} else if simple { | ||
let walker = WalkDir::new(path); | ||
for result in walker { | ||
tx.send(DirEntry::X(result.unwrap())).unwrap(); | ||
} | ||
} else { | ||
let walker = WalkBuilder::new(path).build(); | ||
for result in walker { | ||
tx.send(DirEntry::Y(result.unwrap())).unwrap(); | ||
} | ||
} | ||
drop(tx); | ||
stdout_thread.join().unwrap(); | ||
} | ||
|
||
enum DirEntry { | ||
X(walkdir::DirEntry), | ||
Y(ignore::DirEntry), | ||
} | ||
|
||
impl DirEntry { | ||
fn path(&self) -> &Path { | ||
match *self { | ||
DirEntry::X(ref x) => x.path(), | ||
DirEntry::Y(ref y) => y.path(), | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.