-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Support glob syntax in workspace members #3979
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
src/cargo/core/workspace.rs
Outdated
} | ||
|
||
for path in expanded_list { | ||
let manifest_path = path.join("Cargo.toml"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this error if there's a path without Cargo.toml
matched by the glob? I would say that it's OK to bail in this case, but that just skipping that path would be probably more useful: I often have various assorted folders alongside the workspace packages.
In any case, I think a test case for this would be useful :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call out. I will get on it.
Also mind updating the workspace documentation to mention that globs may be used? |
@alexcrichton sure, i can update the docs too! |
Thanks @hjr3! I'm looking forward to this one (we currently have a big setup with a script to autogenerate the workspace members). |
Apologies for taking so long to update this PR. I have updated the docs. Is it ok to reuse the I also added the test to shows what happens with a workspace path does not have a |
Looks good to me, but the tests seem to be failing? The new |
@alexcrichton ok i fixed |
src/cargo/core/workspace.rs
Outdated
@@ -527,6 +544,18 @@ impl<'cfg> Workspace<'cfg> { | |||
} | |||
} | |||
|
|||
fn expand_member_path(path: &Path) -> CargoResult<Vec<PathBuf>> { | |||
let path = path.to_str().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could the None
case be handled here instead of unwrap
? (returning an empty Vec
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
src/cargo/core/workspace.rs
Outdated
@@ -527,6 +544,18 @@ impl<'cfg> Workspace<'cfg> { | |||
} | |||
} | |||
|
|||
fn expand_member_path(path: &Path) -> CargoResult<Vec<PathBuf>> { | |||
let path = path.to_str().unwrap(); | |||
let res = glob(path).map_err(|e| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this use .chain_error
instead of .map_err
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may be missing something here, but I don't see how .chain_error
can be used with Result<glob::Paths, glob::PatternError>
.
src/cargo/core/workspace.rs
Outdated
human(format!("could not parse pattern `{}`: {}", &path, e)) | ||
})?; | ||
res.map(|p| { | ||
p.or_else(|e| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above, could this use chain_error
?
Nah this seems like a reasonable interpretation to me I think, thanks! |
@hjr3 mind updating to using |
@bors: r+ |
📌 Commit f00c223 has been approved by |
@alexcrichton thanks, i was just about to push this same patch. it took me some time to figure out how to get the |
Support glob syntax in workspace members Fixes #3911
Oh sorry about that! I was just going through old Cargo PRs and figured this could use a bit of a boost :) |
☀️ Test successful - status-appveyor, status-travis |
How to use?
gives an error |
@Astlaan What is the error? Could you please open a new issue instead of leaving a comment here, as this PR was closed 7 years ago. If it is a usage issue, https://users.rust-lang.org/ may be a better place to ask this type of question. |
Sorry, this is what I wrote:
But apparently with fails with an error like:
It's it possible to have it not fail and simply add as members folders that do have a Cargo.toml? |
@Astlaan you can use See #11405 for tracking the workspace globbing issue |
Fixes #3911