parent
f5b44cb521
commit
fe1ed12d54
3 changed files with 45 additions and 11 deletions
39
compare.py
Normal file
39
compare.py
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import typing as t
|
||||
from tempfile import NamedTemporaryFile
|
||||
|
||||
import click
|
||||
|
||||
|
||||
@click.command(
|
||||
context_settings={"show_default": True, "help_option_names": ["-h", "--help"]}
|
||||
)
|
||||
@click.argument("v1_json", required=True, type=click.File())
|
||||
@click.argument("v2_depsolve_result_json", required=True, type=click.File())
|
||||
def main(v1_json: t.IO[str], v2_depsolve_result_json: t.IO[str]) -> None:
|
||||
with v1_json, v2_depsolve_result_json:
|
||||
v1 = json.load(v1_json)
|
||||
v2 = json.load(v2_depsolve_result_json)
|
||||
|
||||
v1_affected_packages = set(v1["affected_packages"])
|
||||
v1_orphans = set(v1["orphans"])
|
||||
v1_affected_packages -= v1_orphans
|
||||
v2_affected_packages = set(v2["affected_pkg_to_orphans"])
|
||||
with (
|
||||
NamedTemporaryFile("w", suffix=".v1") as v1_temp,
|
||||
NamedTemporaryFile("w", suffix=".v2") as v2_temp,
|
||||
):
|
||||
for i in sorted(v1_affected_packages):
|
||||
v1_temp.write(i + "\n")
|
||||
for i in sorted(v2_affected_packages):
|
||||
v2_temp.write(i + "\n")
|
||||
v1_temp.flush()
|
||||
v2_temp.flush()
|
||||
subprocess.run(["diff", "--color=auto", "-u", v1_temp.name, v2_temp.name])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -276,8 +276,10 @@ class DepSolveResult:
|
|||
# Map orphaned components to affected components
|
||||
# Will allow creating the `packages that depend on orphan foo are...` reports
|
||||
orphan_to_affected_pkgs: OrphanToAffectedPkgsDict
|
||||
# Map orphaned components to affected components
|
||||
# Will allow creating the `packages that depend on orphan foo are...` reports
|
||||
# Map affected packages to a set of the orphaned package(s) on which they depend.
|
||||
# Will be used for individual by-maintainer reports where we want to know
|
||||
# which orphaned packages the maintainer of package foo would need to pick
|
||||
# up to unbreak foo.
|
||||
affected_pkg_to_orphans: dict[str, set[str]]
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
# State: Search the code for TODO(!!!) comments for the major things left to implement.
|
||||
# This is a draft that mostly focusses on dependency resolution but other parts are missing.
|
||||
|
||||
import dataclasses
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
|
|
@ -53,15 +54,7 @@ def main(branch: str, repo: str, package_list: t.IO[str] | None, koji_tag: str)
|
|||
depsolve_result = depsolve.depsolve(branch, repo, orphans)
|
||||
# TODO(!!!): Generate text and JSON reports instead of just printing the data
|
||||
print(
|
||||
json.dumps(
|
||||
depsolve_result.affected_pkg_to_orphans, indent=2, default=json_default
|
||||
)
|
||||
)
|
||||
print("\n\n\n")
|
||||
print(
|
||||
json.dumps(
|
||||
depsolve_result.orphan_to_affected_pkgs, indent=2, default=json_default
|
||||
)
|
||||
json.dumps(dataclasses.asdict(depsolve_result), indent=2, default=json_default)
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue