Skip to content

Commit

Permalink
Use wax for globbing (#5014)
Browse files Browse the repository at this point in the history
Co-authored-by: Greg Soltis <Greg Soltis>
  • Loading branch information
arlyon authored and Greg Soltis committed Jun 1, 2023
1 parent 7cf8398 commit ab91e72
Show file tree
Hide file tree
Showing 26 changed files with 574 additions and 2,914 deletions.
1 change: 0 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ pnpm-lock.yaml
/crates

# overrides for crates that are owned by turbo-oss
/crates/globwalk @vercel/turbo-oss
/crates/turborepo* @vercel/turbo-oss

# overrides for crates that are owned by web-tooling
Expand Down
126 changes: 79 additions & 47 deletions Cargo.lock

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

3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
resolver = "2"

members = [
"crates/globwalk",
"crates/globwatch",
"crates/pidlock",
"crates/node-file-trace",
"crates/turbo-tasks*",
"crates/turbopack*",
Expand Down
2 changes: 2 additions & 0 deletions cli/internal/ffi/bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ struct Buffer verify_signature(struct Buffer buffer);

struct Buffer get_package_file_hashes_from_git_index(struct Buffer buffer);

struct Buffer glob(struct Buffer buffer);

struct Buffer transitive_closure(struct Buffer buf);

struct Buffer subgraph(struct Buffer buf);
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ crate-type = ["staticlib"]

[dependencies]
directories = "4.0.1"
globwalk = { version = "0.1.0", path = "../globwalk" }
globwalk = { version = "0.1.0", path = "../turborepo-globwalk" }
prost = "0.11.6"
thiserror = { workspace = true }
turbopath = { workspace = true }
Expand Down
37 changes: 28 additions & 9 deletions crates/turborepo-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod lockfile;

use std::{collections::HashMap, mem::ManuallyDrop, path::PathBuf};

use globwalk::globwalk;
use globwalk::{globwalk, WalkError};
pub use lockfile::{patches, subgraph, transitive_closure};
use turbopath::{AbsoluteSystemPathBuf, AnchoredSystemPathBuf};

Expand Down Expand Up @@ -305,20 +305,39 @@ pub extern "C" fn glob(buffer: Buffer) -> Buffer {
false => globwalk::WalkType::All,
};

let response = globwalk(
let mut iter = match globwalk(
&AbsoluteSystemPathBuf::new(req.base_path).expect("absolute"),
&req.include_patterns,
&req.exclude_patterns,
walk_type,
)
.map(|res| res.map(|p| p.to_string_lossy().to_string()))
.collect();
) {
Ok(iter) => iter,
Err(err) => {
let resp = proto::GlobResp {
response: Some(proto::glob_resp::Response::Error(err.to_string())),
};
return resp.into();
}
};

let paths = match iter.collect::<Result<Vec<_>, WalkError>>() {
Ok(paths) => paths,
Err(err) => {
let resp = proto::GlobResp {
response: Some(proto::glob_resp::Response::Error(err.to_string())),
};
return resp.into();
}
};
// TODO: is to_string_lossy the right thing to do here? We could error...
let files: Vec<_> = paths
.into_iter()
.map(|path| path.to_string_lossy().to_string())
.collect();
proto::GlobResp {
response: Some(match response {
Ok(files) => proto::glob_resp::Response::Files(proto::GlobRespList { files }),
Err(e) => proto::glob_resp::Response::Error(e.to_string()),
}),
response: Some(proto::glob_resp::Response::Files(proto::GlobRespList {
files,
})),
}
.into()
}
25 changes: 0 additions & 25 deletions crates/turborepo-glob-match/Cargo.toml

This file was deleted.

21 changes: 0 additions & 21 deletions crates/turborepo-glob-match/LICENSE

This file was deleted.

Loading

0 comments on commit ab91e72

Please sign in to comment.