Skip to content

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 26 commits into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
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 Mar 17, 2025
18442be
manually apply patches to inlined `ignore` crate
RobinMalfait Mar 17, 2025
22bd00f
run all CI tests when `[ci-all]` exists in PR description
RobinMalfait Mar 21, 2025
ba153be
big refactor, move `Scanner` to `scanner/mod.rs`
RobinMalfait Mar 21, 2025
72b18cd
simplify `scanner` test setup
RobinMalfait Mar 21, 2025
cd6ccb2
add new Scanner tests
RobinMalfait Mar 21, 2025
324569c
update public Rust API
RobinMalfait Mar 21, 2025
335e9e1
update use statements due to big refactor
RobinMalfait Mar 21, 2025
88a6048
rename `globs` to `sources`
RobinMalfait Mar 21, 2025
602a801
add `negated` flag to `sources`
RobinMalfait Mar 21, 2025
9798637
add missing `reference` property
RobinMalfait Mar 21, 2025
9958612
update integration tests
RobinMalfait Mar 21, 2025
878782e
use `normalizedSources` in the CLI
RobinMalfait Mar 21, 2025
a7bef4e
add `.gitignore` as a default ignored file
RobinMalfait Mar 21, 2025
8d154d1
add `node_modules` as a default ignored folder
RobinMalfait Mar 21, 2025
38ed37e
add `enableSourceNot` feature flag
RobinMalfait Mar 21, 2025
0f73797
run prettier
RobinMalfait Mar 21, 2025
97fc4bf
Simplify gitignore order change
philipp-spiess Mar 25, 2025
94473d3
Rename GitHub CI var
philipp-spiess Mar 25, 2025
7442baa
Explicitly mark test functions
philipp-spiess Mar 25, 2025
2425aef
Handle source paths into ignored content dirs as "external"
philipp-spiess Mar 25, 2025
bb0610d
Revert "Explicitly mark test functions"
philipp-spiess Mar 25, 2025
6952871
Explicitly mark test functions
philipp-spiess Mar 25, 2025
b6ab98f
Cleanup comment
philipp-spiess Mar 25, 2025
5e7d035
Cleanup public source entry creation
philipp-spiess Mar 25, 2025
9d4c2af
Cleanups and test utf8 special characters in paths
philipp-spiess Mar 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ jobs:
os: macos-14

# Exclude windows and macos from being built on feature branches
on-main-branch:
- ${{ github.ref == 'refs/heads/main' }}
run-all:
- ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.body, '[ci-all]') }}
exclude:
- on-main-branch: false
- run-all: false
runner:
name: Windows
- on-main-branch: false
- run-all: false
runner:
name: macOS

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ jobs:
- workers

# Exclude windows and macos from being built on feature branches
on-main-branch:
- ${{ github.ref == 'refs/heads/main' }}
run-all:
- ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.body, '[ci-all]') }}
exclude:
- on-main-branch: false
- run-all: false
runner:
name: Windows
- on-main-branch: false
- run-all: false
runner:
name: macOS

Expand Down
25 changes: 21 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/ignore/COPYING
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.
45 changes: 45 additions & 0 deletions crates/ignore/Cargo.toml
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 <[email protected]>"]
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 = []
21 changes: 21 additions & 0 deletions crates/ignore/LICENSE-MIT
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.
58 changes: 58 additions & 0 deletions crates/ignore/README.md
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.

[![Build status](https://github.com/BurntSushi/ripgrep/workflows/ci/badge.svg)](https://github.com/BurntSushi/ripgrep/actions)
[![](https://img.shields.io/crates/v/ignore.svg)](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.
24 changes: 24 additions & 0 deletions crates/ignore/UNLICENSE
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/>
64 changes: 64 additions & 0 deletions crates/ignore/examples/walk.rs
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(),
}
}
}
Loading