-
Notifications
You must be signed in to change notification settings - Fork 28
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: don't allow the root package dependencies to be overwritten in the map #47
fix: don't allow the root package dependencies to be overwritten in the map #47
Conversation
main.go
Outdated
m[from] = to | ||
} else if entryExists && m[from] != to { | ||
VLog("trying to overwrite rewrite map entry %s poiting to %s with %s", from, m[from], to) |
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.
Fix typo: "poiting".
…he map The rewrite map is built recursively scanning the root package dependencies. If two packages in the tree imported the same dependency with different hash the last one to be processed would overwrite the first one. Include a flag in `buildRewriteMapping` to signal when the root package dependencies are being process and allow them to overwrite the map (adding an overwrite flag in `addRewriteForDep`) but don't allow the inverse (transitive dependencies overwriting direct ones). This change has as a side effect that in a scenario where transitive dependencies with different versions were overwriting each other that won't be allowed now, changing in fact the rewrite map, but that would happen only in the already problematic scenario of dependencies with mismatched versions.
Actually, I'm not sure if this is the right fix.
So, this is a fix but, after thinking about this, I think the better fix is to change the traversal order to breadth first (and ban all overwriting). This catches the case where the root package overrides a dependency version but doesn't apply the same logic recursively. How about:
|
Do you mind merging this anyway while we discuss this other solution in the original issue? (The other |
Fair enough. This fixes the immediate issue. |
Fixes #44.
Tested locally, it feels that it should have a test but I don't see any testing framework here (it would be nice to have it to easily create dependencies trees and test different scenarios, I'll open an issue about it.)