Skip to content

Commit

Permalink
Merge pull request #503 from mulkieran/ignore-path-dependencies
Browse files Browse the repository at this point in the history
Do not report path dependencies by default
  • Loading branch information
mulkieran authored Feb 26, 2024
2 parents 5f32d3e + 9c9b85e commit 471c3f5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
17 changes: 9 additions & 8 deletions dependency_management/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,13 @@ def build_koji_repo_dict(crates, release):
return koji_repo_dict


def build_cargo_metadata(manifest_path):
def build_cargo_metadata(manifest_path, *, skip_path=False):
"""
Build a dict mapping crate to version spec from Cargo.toml.
:param manifest_path: the path to the Cargo manifest file
:type manifest_path: str or NoneType
:param bool skip_path: if True, skip path dependencies
:returns: a dict mapping crate name to version specification
:rtype: str * SimpleSpec
"""
Expand All @@ -180,10 +181,10 @@ def build_cargo_metadata(manifest_path):
package = packages[0]
dependencies = package["dependencies"]

result = {}
for item in dependencies:
# cargo-metadata insert spaces into "req" value; SimpleSpec constructor
# rejects specifications that contain spaces.
result[item["name"]] = SimpleSpec(item["req"].replace(" ", ""))

return result
# cargo-metadata insert spaces into "req" value; SimpleSpec constructor
# rejects specifications that contain spaces.
return {
item["name"]: SimpleSpec(item["req"].replace(" ", ""))
for item in dependencies
if not skip_path or not "path" in item
}
13 changes: 12 additions & 1 deletion dependency_management/compare_fedora_versions
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,15 @@ def main():
help=help_text,
)

help_text = "Do not ignore path dependencies"
parser.add_argument(
"--deny-path",
action="store_true",
dest="deny_path",
default=False,
help=help_text,
)

help_text = "Allow partial version expressions in Cargo.toml (example 0.14)"
parser.add_argument(
"--allow-partial-versions",
Expand Down Expand Up @@ -196,7 +205,9 @@ def main():
)

# Read the dependency versions specified in Cargo.toml
explicit_dependencies = build_cargo_metadata(args.manifest_path)
explicit_dependencies = build_cargo_metadata(
args.manifest_path, skip_path=not args.deny_path
)

# Build koji dict
try:
Expand Down

0 comments on commit 471c3f5

Please sign in to comment.