Repository navigation
Tidy: Check Cargo.lock for packages with same version and different sources - #14715
Conversation
|
Heads up! This PR modifies the following files:
|
| norm_paths = [] | ||
| for path in paths: | ||
| norm_paths += [os.path.join(*path.split('/'))] | ||
| return norm_paths |
There was a problem hiding this comment.
This could just be
return [os.path.join(*path.split('/')) for path in paths]|
|
||
| highest = max(versions) | ||
| for version in versions: | ||
| highest = max(data["version"]) |
There was a problem hiding this comment.
Could you also add a similar comment here? That, it's for Packages with same names but different versions?
| yield (1, message) | ||
|
|
||
| # Packages with same version from different sources | ||
| if (len(set(data["version"])) < len(data["version"]) |
There was a problem hiding this comment.
Maybe we should have names for version and source, so that we don't have to address them as data["version"] and data["source"] everywhere.
| # Set recommended source | ||
| if r"registry+https://github.com/rust-lang/crates.io-index" in data["source"]: | ||
| req_source = r"registry+https://github.com/rust-lang/crates.io-index" | ||
| elif "github.com/servo/" in data["source"]: |
There was a problem hiding this comment.
Enlighten me. Do we have such a case in that list? This looks for an exact match of "github.com/servo/servo in the data["source"] list, no? Don't you think this should be something like,
elif any('github.com/servo/' in source for source in data["source"]):There was a problem hiding this comment.
Also, we probably need a test for this case.
|
Just a few comments. Overall, the PR looks good. Thanks for doing this :) |
|
I’m sorry, the way I filed the issue was misleading. It should have been:
… because the algorithm should be no more complicated than this. Then, the issue could have said:
I think the code should not care about what the version numbers or source are, except to include them in the error message. In other words, I think the packages_by_name = {}
for package in content.get("package", []):
source = package.get("source", "")
if source == "registry+https://github.com/rust-lang/crates.io-index":
source = "crates.io"
packages_by_name.setdefault(package["name"], []).append((package["version"], source))
for (name, packages) in packages_by_name.iteritems():
if name in exceptions or len(packages) <= 1:
continue
message = "duplicate versions for package " + name
packages.sort()
for version, source in packages:
message += "\n\tThe following packages depend on version {} from {}:" \
.format(version, source)
for name in find_reverse_dependencies(name, version, content):
message += "\n\t\t" + name
yield (1, message) |
|
Looks good to me! r=me with the fixup commits squashed |
675ca70 to
b760578
Compare
|
done! |
|
@bors-servo r+ |
|
📌 Commit b760578 has been approved by |
|
⌛ Testing commit b760578 with merge 37a5e29... |
Tidy: Check Cargo.lock for packages with same version and different sources <!-- Please describe your changes on the following line: --> r? @Wafflespeanut cc @SimonSapin --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #14695 <!-- Either: --> - [X] There are tests for these changes <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14715) <!-- Reviewable:end -->
|
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css, mac-rel-wpt1, mac-rel-wpt2, windows-gnu-dev, windows-msvc-dev |
r? @Wafflespeanut
cc @SimonSapin
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is