Replace remaining usages of glob crate with globset

This commit is contained in:
Max Brunsfeld 2023-05-19 09:36:46 -07:00
parent 459cc9c959
commit 847d1e73a3
7 changed files with 8 additions and 14 deletions

4
Cargo.lock generated
View file

@ -2038,7 +2038,6 @@ dependencies = [
"futures 0.3.28", "futures 0.3.28",
"fuzzy", "fuzzy",
"git", "git",
"glob",
"gpui", "gpui",
"indoc", "indoc",
"itertools", "itertools",
@ -3442,7 +3441,7 @@ dependencies = [
"futures 0.3.28", "futures 0.3.28",
"fuzzy", "fuzzy",
"git", "git",
"glob", "globset",
"gpui", "gpui",
"indoc", "indoc",
"lazy_static", "lazy_static",
@ -6111,7 +6110,6 @@ dependencies = [
"collections", "collections",
"fs", "fs",
"futures 0.3.28", "futures 0.3.28",
"glob",
"gpui", "gpui",
"json_comments", "json_comments",
"lazy_static", "lazy_static",

View file

@ -78,7 +78,6 @@ ctor = { version = "0.1" }
env_logger = { version = "0.9" } env_logger = { version = "0.9" }
futures = { version = "0.3" } futures = { version = "0.3" }
globset = { version = "0.4" } globset = { version = "0.4" }
glob = { version = "0.3.1" }
lazy_static = { version = "1.4.0" } lazy_static = { version = "1.4.0" }
log = { version = "0.4.16", features = ["kv_unstable_serde"] } log = { version = "0.4.16", features = ["kv_unstable_serde"] }
ordered-float = { version = "2.1.1" } ordered-float = { version = "2.1.1" }

View file

@ -335,10 +335,9 @@ async fn configure_disabled_globs(
.get::<AllLanguageSettings>(None) .get::<AllLanguageSettings>(None)
.copilot .copilot
.disabled_globs .disabled_globs
.clone()
.iter() .iter()
.map(|glob| glob.as_str().to_string()) .map(|glob| glob.glob().to_string())
.collect::<Vec<_>>() .collect()
}); });
if let Some(path_to_disable) = &path_to_disable { if let Some(path_to_disable) = &path_to_disable {

View file

@ -49,7 +49,6 @@ workspace = { path = "../workspace" }
aho-corasick = "0.7" aho-corasick = "0.7"
anyhow.workspace = true anyhow.workspace = true
futures.workspace = true futures.workspace = true
glob.workspace = true
indoc = "1.0.4" indoc = "1.0.4"
itertools = "0.10" itertools = "0.10"
lazy_static.workspace = true lazy_static.workspace = true
@ -82,7 +81,6 @@ workspace = { path = "../workspace", features = ["test-support"] }
ctor.workspace = true ctor.workspace = true
env_logger.workspace = true env_logger.workspace = true
glob.workspace = true
rand.workspace = true rand.workspace = true
unindent.workspace = true unindent.workspace = true
tree-sitter = "0.20" tree-sitter = "0.20"

View file

@ -41,7 +41,7 @@ anyhow.workspace = true
async-broadcast = "0.4" async-broadcast = "0.4"
async-trait.workspace = true async-trait.workspace = true
futures.workspace = true futures.workspace = true
glob.workspace = true globset.workspace = true
lazy_static.workspace = true lazy_static.workspace = true
log.workspace = true log.workspace = true
parking_lot.workspace = true parking_lot.workspace = true

View file

@ -1,5 +1,6 @@
use anyhow::Result; use anyhow::Result;
use collections::HashMap; use collections::HashMap;
use globset::GlobMatcher;
use gpui::AppContext; use gpui::AppContext;
use schemars::{ use schemars::{
schema::{InstanceType, ObjectValidation, Schema, SchemaObject}, schema::{InstanceType, ObjectValidation, Schema, SchemaObject},
@ -45,7 +46,7 @@ pub struct LanguageSettings {
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default)]
pub struct CopilotSettings { pub struct CopilotSettings {
pub feature_enabled: bool, pub feature_enabled: bool,
pub disabled_globs: Vec<glob::Pattern>, pub disabled_globs: Vec<GlobMatcher>,
} }
#[derive(Clone, Serialize, Deserialize, JsonSchema)] #[derive(Clone, Serialize, Deserialize, JsonSchema)]
@ -151,7 +152,7 @@ impl AllLanguageSettings {
.copilot .copilot
.disabled_globs .disabled_globs
.iter() .iter()
.any(|glob| glob.matches_path(path)) .any(|glob| glob.is_match(path))
} }
pub fn copilot_enabled(&self, language_name: Option<&str>, path: Option<&Path>) -> bool { pub fn copilot_enabled(&self, language_name: Option<&str>, path: Option<&Path>) -> bool {
@ -236,7 +237,7 @@ impl settings::Setting for AllLanguageSettings {
feature_enabled: copilot_enabled, feature_enabled: copilot_enabled,
disabled_globs: copilot_globs disabled_globs: copilot_globs
.iter() .iter()
.filter_map(|pattern| glob::Pattern::new(pattern).ok()) .filter_map(|g| Some(globset::Glob::new(g).ok()?.compile_matcher()))
.collect(), .collect(),
}, },
defaults, defaults,

View file

@ -22,7 +22,6 @@ util = { path = "../util" }
anyhow.workspace = true anyhow.workspace = true
futures.workspace = true futures.workspace = true
glob.workspace = true
json_comments = "0.2" json_comments = "0.2"
lazy_static.workspace = true lazy_static.workspace = true
postage.workspace = true postage.workspace = true