Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upTidy: Check Cargo.lock for packages with same version and different sources #14715
Conversation
highfive
commented
Dec 24, 2016
|
Heads up! This PR modifies the following files:
|
| norm_paths = [] | ||
| for path in paths: | ||
| norm_paths += [os.path.join(*path.split('/'))] | ||
| return norm_paths |
This comment has been minimized.
This comment has been minimized.
wafflespeanut
Dec 25, 2016
Member
This could just be
return [os.path.join(*path.split('/')) for path in paths]| continue | ||
|
|
||
| highest = max(versions) | ||
| for version in versions: | ||
| highest = max(data["version"]) |
This comment has been minimized.
This comment has been minimized.
wafflespeanut
Dec 25, 2016
•
Member
Could you also add a similar comment here? That, it's for Packages with same names but different versions?
| @@ -360,6 +351,43 @@ def find_reverse_dependencies(dependency, version, content): | |||
| """.format(**substitutions).strip() | |||
| yield (1, message) | |||
|
|
|||
| # Packages with same version from different sources | |||
| if (len(set(data["version"])) < len(data["version"]) | |||
This comment has been minimized.
This comment has been minimized.
wafflespeanut
Dec 25, 2016
Member
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"]: |
This comment has been minimized.
This comment has been minimized.
wafflespeanut
Dec 25, 2016
•
Member
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"]):
This comment has been minimized.
This comment has been minimized.
|
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 |
|
done! |
|
@bors-servo r+ |
|
|
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 -->
|
|
UK992 commentedDec 24, 2016
•
edited by larsbergstrom
r? @wafflespeanut
cc @SimonSapin
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is