MCPcopy Create free account
hub / github.com/AI45Lab/Code / glob

Method glob

core/src/workspace/local.rs:170–193  ·  view source on GitHub ↗
(&self, request: WorkspaceGlobRequest)

Source from the content-addressed store, hash-verified

168#[async_trait]
169impl WorkspaceSearch for LocalWorkspaceBackend {
170 async fn glob(&self, request: WorkspaceGlobRequest) -> Result<WorkspaceGlobResult> {
171 validate_relative_pattern(&request.pattern, "glob pattern")?;
172 let base = self.local_path_for_read(&request.base)?;
173 let full_pattern = base.join(&request.pattern);
174 let full_pattern = full_pattern.to_string_lossy().replace('\\', "/");
175
176 let entries = glob::glob(&full_pattern)
177 .map_err(|e| anyhow!("Invalid glob pattern '{}': {}", request.pattern, e))?;
178
179 let mut matches = Vec::new();
180 for entry in entries {
181 match entry {
182 Ok(path) => {
183 if let Ok(relative) = path.strip_prefix(&self.root) {
184 matches.push(pathbuf_to_workspace_path(relative));
185 }
186 }
187 Err(e) => tracing::warn!("Glob entry error: {}", e),
188 }
189 }
190
191 matches.sort_by(|a, b| a.as_str().cmp(b.as_str()));
192 Ok(WorkspaceGlobResult { matches })
193 }
194
195 async fn grep(&self, request: WorkspaceGrepRequest) -> Result<WorkspaceGrepResult> {
196 if let Some(ref glob) = request.glob {

Callers 1

Calls 4

local_path_for_readMethod · 0.80
as_strMethod · 0.45

Tested by

no test coverage detected