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
fix: allow for workplace descriptors without a protocol #4755
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
crates/turborepo-lockfiles/fixtures/berry-protocol-collision.lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# This file is generated by running "yarn install" inside your project. | ||
# Manual changes might be lost - proceed with caution! | ||
|
||
__metadata: | ||
version: 6 | ||
|
||
"a@workspace:packages/a": | ||
version: 0.0.0-use.local | ||
resolution: "a@workspace:packages/a" | ||
dependencies: | ||
c: "*" | ||
languageName: unknown | ||
linkType: soft | ||
|
||
"b@workspace:packages/b": | ||
version: 0.0.0-use.local | ||
resolution: "b@workspace:packages/b" | ||
dependencies: | ||
c: "workspace:*" | ||
languageName: unknown | ||
linkType: soft | ||
|
||
"c@*, c@workspace:*, c@workspace:packages/c": | ||
version: 0.0.0-use.local | ||
resolution: "c@workspace:packages/c" | ||
languageName: unknown | ||
linkType: soft | ||
|
||
"prune-edge@workspace:.": | ||
version: 0.0.0-use.local | ||
resolution: "prune-edge@workspace:." | ||
languageName: unknown | ||
linkType: soft |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -266,11 +266,10 @@ impl<'a> BerryLockfile<'a> { | |||||
resolutions.insert(dependency, dep_locator.clone()); | ||||||
} | ||||||
|
||||||
if let Some(descriptors) = reverse_lookup.get(locator) { | ||||||
for descriptor in descriptors { | ||||||
resolutions.insert((*descriptor).clone(), locator.clone()); | ||||||
} | ||||||
} | ||||||
// Included workspaces will always have their locator listed as a descriptor. | ||||||
// All other descriptors should show up in the other workspace package | ||||||
// dependencies. | ||||||
resolutions.insert(Descriptor::from(locator.clone()), locator.clone()); | ||||||
} | ||||||
} | ||||||
|
||||||
|
@@ -779,4 +778,45 @@ mod test { | |||||
version: "4.4.1".into() | ||||||
})); | ||||||
} | ||||||
|
||||||
#[test] | ||||||
fn test_workspace_collission() { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
let data = LockfileData::from_bytes(include_bytes!( | ||||||
"../../fixtures/berry-protocol-collision.lock" | ||||||
)) | ||||||
.unwrap(); | ||||||
let lockfile = BerryLockfile::new(&data, None).unwrap(); | ||||||
let no_proto = Descriptor::try_from("c@*").unwrap(); | ||||||
let workspace_proto = Descriptor::try_from("c@workspace:*").unwrap(); | ||||||
let full_path = Descriptor::try_from("c@workspace:packages/c").unwrap(); | ||||||
let a_lockfile = lockfile | ||||||
.subgraph(&["packages/a".into(), "packages/c".into()], &[]) | ||||||
.unwrap(); | ||||||
let a_reverse_lookup = a_lockfile.locator_to_descriptors(); | ||||||
let a_c_descriptors = a_reverse_lookup | ||||||
.get(&Locator::try_from("c@workspace:packages/c").unwrap()) | ||||||
.unwrap(); | ||||||
|
||||||
assert_eq!( | ||||||
a_c_descriptors, | ||||||
&(vec![&no_proto, &full_path] | ||||||
.into_iter() | ||||||
.collect::<HashSet<_>>()) | ||||||
); | ||||||
|
||||||
let b_lockfile = lockfile | ||||||
.subgraph(&["packages/b".into(), "packages/c".into()], &[]) | ||||||
.unwrap(); | ||||||
let b_reverse_lookup = b_lockfile.locator_to_descriptors(); | ||||||
let b_c_descriptors = b_reverse_lookup | ||||||
.get(&Locator::try_from("c@workspace:packages/c").unwrap()) | ||||||
.unwrap(); | ||||||
|
||||||
assert_eq!( | ||||||
b_c_descriptors, | ||||||
&(vec![&workspace_proto, &full_path] | ||||||
.into_iter() | ||||||
.collect::<HashSet<_>>()) | ||||||
); | ||||||
} | ||||||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Am I understanding correctly that this whole line is the "descriptor" and the "locator" is the
packages/c
part?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.
Kinda:
c@*
,c@workspace:*
, andc@workspace:packages/c
are all descriptors and then they all get concat'd to be a key in the YAML lockfile.c@workspace:packages/c
is also a locator in this lockfile which appears in theresolution
field of the lockfile entry.