Skip to content
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

Use wax for globbing #5014

Merged
merged 18 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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 @@ -20,6 +20,8 @@ struct Buffer recursive_copy(struct Buffer buffer);

struct Buffer verify_signature(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::{mem::ManuallyDrop, path::PathBuf};

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

Expand Down Expand Up @@ -222,20 +222,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