You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: crates/ty_project/src/glob/exclude.rs
+8-17Lines changed: 8 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -100,16 +100,16 @@ impl ExcludeFilterBuilder {
100
100
/// Matcher for gitignore like globs.
101
101
///
102
102
/// This code is our own vendored copy of the ignore's crate `Gitignore` type.
103
-
/// The main difference to `ignore`'s version is that it makes use
104
-
/// of the fact that all our globs are absolute. This simplifies the implementation a fair bit.
105
-
/// Making globs absolute is also because the globs can come from both the CLI and configuration files,
106
-
/// where the paths are anchored relative to the current working directory or the project root respectively.
107
103
///
108
-
/// Vendoring our own copy has the added benefit that we don't need to deal with ignore's `Error` type.
109
-
/// Instead, we can exclusively use [`globset::Error`].
104
+
/// The differences with the ignore's crate version are:
110
105
///
111
-
/// This implementation also removes supported for comments, because the patterns aren't read
112
-
/// from a `.gitignore` file. This removes the need to escape `#` for file names starting with `#`,
106
+
/// * All globs are anchored. `src` matches `./src` only and not `**/src` to be consistent with `include`.
107
+
/// * It makes use of the fact that all our globs are absolute. This simplifies the implementation a fair bit.
108
+
/// Making globs absolute is also motivated by the fact that the globs can come from both the CLI and configuration files,
109
+
/// where the paths are anchored relative to the current working directory or the project root respectively.
110
+
/// * It uses [`globset::Error`] over the ignore's crate `Error` type.
111
+
/// * Removes supported for commented lines, because the patterns aren't read
112
+
/// from a `.gitignore` file. This removes the need to escape `#` for file names starting with `#`,
113
113
///
114
114
/// You can find the original source on [GitHub](https://github.com/BurntSushi/ripgrep/blob/cbc598f245f3c157a872b69102653e2e349b6d92/crates/ignore/src/gitignore.rs#L81).
115
115
///
@@ -267,15 +267,6 @@ impl GitignoreBuilder {
267
267
268
268
letmut actual = pattern.to_string();
269
269
270
-
// If there is a literal slash, then this is a glob that must match the
271
-
// entire path name. Otherwise, we should let it match anywhere, so use
272
-
// a **/ prefix.
273
-
if !pattern.chars().any(|c| c == '/'){
274
-
// ... but only if we don't already have a **/ prefix.
275
-
if !pattern.starts_with("**/"){
276
-
actual = format!("**/{actual}");
277
-
}
278
-
}
279
270
// If the glob ends with `/**`, then we should only match everything
280
271
// inside a directory, but not the directory itself. Standard globs
281
272
// will match the directory. So we add `/*` to force the issue.
0 commit comments