-
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
Handle overlapping members
and exclude
keys
#4297
Conversation
r? @matklad (rust_highfive has picked a reviewer for you, use r? to override) |
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.
Hm, we support globs in members
, don't we? And looks like this is_excluded
function does not handle this at all?
src/cargo/core/workspace.rs
Outdated
}); | ||
let mut excludes = exclude.iter() | ||
.map(|p| root_path.join(p)) | ||
.filter(|p| manifest_path.starts_with(p)); |
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 think this'll look a tiny bit neater if we add .max_by_key(|p| p.as_os_str().len())
bit here, and then do match (explicit_member, exclude) { ... }
simultaneously.
The longest key takes precedence if there's more than one that matches. Closes rust-lang#4089
Excellent point about globs! I fixed using |
Let's add a test with globs! :) I think the scenario which does not work with old is_excluded is this: Workspace root includes a member foo via glob. Then, if we execute cargo build inside foo, cargo won't detect that it is a member of the workspace. |
manifest_path.starts_with(root_path.join(mem)) | ||
}) | ||
members.iter() | ||
.filter(|p| manifest_path.starts_with(root_path.join(p))) |
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 think that members can contain globs. That is, p
might be like foo/*
here, and so this starts_with
will fail.
I though wrong :) Nevertheless, I think this test will be interesting:
Looks like |
@alexcrichton, should I take over this one and fix #4089 along the migration to gitignore-matching everywhere? |
Also, another difference between I think whatever solution we take here better be aligned with the future of Here's my suggestion for
What do you think? |
Sorry yeah @behnam if you wouldn't mind taking this over, that'd be great! I'm quickly losing steam on this :( I'm also sorry that there's not really a great design here, it's all sort of ad-hoc. My main motivation for this was to remove these lines in the rust-lang/rust repo. Beyond that I've just been attempting to rationalize gitignore/glob pattern, but I get the feeling that it's just becoming more of a mess. |
No worries, @alexcrichton. I can get back to this when I get back from the trip next week. |
ping @behnam, was just curious if you had a chance to take a look at this again! If you're busy then of course no worries! |
☔ The latest upstream changes (presumably #4469) made this pull request unmergeable. Please resolve the merge conflicts. |
[core/workspace] Create WorkspaceRootConfig Create `WorkspaceRootConfig`, which knows its `root_dir` and lists of `members` and `excludes`, to answer queries on which paths are a member and which are not. ---- This is the first step of the fix, that's only a codemod to put together the relevant parts : `workspace.members`, `workspace.excludes`, and the `root_dir` (where `members` and `excludes` are relative to). There's no logic change in this PR to keep review easier. The added tests are commented out, because they fail with the current logic. The next step to get these steps to pass. Tracker: <#4089> Old PR: <#4297>
This never quite panned out, so closing. |
☔ The latest upstream changes (presumably #5907) made this pull request unmergeable. Please resolve the merge conflicts. |
The longest key takes precedence if there's more than one that matches.
Closes #4089