Repository navigation
Closed
Labels
A-machC-assignedThere is someone working on resolving the issueE-less-complexStraightforward. Recommended for a new contributor.L-pythonPython is required
Description
In servo-tidy.toml there is a [ignore] section that lists package names that are allowed to have duplicate versions in Cargo.lock. However, when we remove the duplicate versions, sometimes we forget to remove the packages from the list of allowed exceptions. We should make ./mach test-tidy report an error if there is a package listed under [ignore] which only has a single version present.
Code:
servo/python/tidy/servo_tidy/tidy.py
Lines 317 to 369 in 4d27ce0
| def check_lock(file_name, contents): | |
| def find_reverse_dependencies(name, content): | |
| for package in itertools.chain([content.get("root", {})], content["package"]): | |
| for dependency in package.get("dependencies", []): | |
| if dependency.startswith("{} ".format(name)): | |
| yield package["name"], dependency | |
| if not file_name.endswith(".lock"): | |
| raise StopIteration | |
| # Package names to be neglected (as named by cargo) | |
| exceptions = config["ignore"]["packages"] | |
| content = toml.loads(contents) | |
| packages_by_name = {} | |
| for package in content.get("package", []): | |
| if "replace" in package: | |
| continue | |
| source = package.get("source", "") | |
| if source == r"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 `{}`".format(name) | |
| packages.sort() | |
| packages_dependencies = list(find_reverse_dependencies(name, content)) | |
| for version, source in packages: | |
| short_source = source.split("#")[0].replace("git+", "") | |
| message += "\n\t\033[93mThe following packages depend on version {} from '{}':\033[0m" \ | |
| .format(version, short_source) | |
| for name, dependency in packages_dependencies: | |
| if version in dependency and short_source in dependency: | |
| message += "\n\t\t" + name | |
| yield (1, message) | |
| # Check to see if we are transitively using any blocked packages | |
| for package in content.get("package", []): | |
| package_name = package.get("name") | |
| package_version = package.get("version") | |
| for dependency in package.get("dependencies", []): | |
| dependency = dependency.split() | |
| dependency_name = dependency[0] | |
| whitelist = config['blocked-packages'].get(dependency_name) | |
| if whitelist is not None: | |
| if package_name not in whitelist: | |
| fmt = "Package {} {} depends on blocked package {}." | |
| message = fmt.format(package_name, package_version, dependency_name) | |
| yield (1, message) |
Test: add a new test similar to this one and run them with
./mach test-tidy --selfReacted by Bastien Orivel
Metadata
Metadata
Assignees
Labels
A-machC-assignedThere is someone working on resolving the issueE-less-complexStraightforward. Recommended for a new contributor.L-pythonPython is required
Activity
highfive commentedon Nov 20, 2017
Hi! If you have any questions regarding this issue, feel free to make a comment here, or ask it in the
#servochannel in IRC.If you intend to work on this issue, then add
@highfive: assign meto your comment, and I'll assign this to you. 😄m-novikov commentedon Nov 21, 2017
I will do this. @highfive : assign me
highfive commentedon Nov 21, 2017
Hey @m-novikov! Thanks for your interest in working on this issue. It's now assigned to you!
Report an errror if a package has duplicates allowed but there are no…
Report an errror if a package has duplicates allowed but there are no…
Report an errror if a package has duplicates allowed but there are no…
Report an errror if a package has duplicates allowed but there are no…
Auto merge of #19325 - m-novikov:tidy-ignore-without-duplicates, r=jdm