Merge pull request #147 from DarkKirb/improve-diff-code

Improve commit diffing code
This commit is contained in:
Charlotte 🦝 Delenk 2023-01-13 22:16:27 +01:00 committed by GitHub
commit adf6c3f698
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,11 +14,21 @@ new_derivation = json.load(open(new_drv))
packages = {} packages = {}
def get_name(drv):
if "pname" in drv["env"]:
return drv["env"]["pname"]
name = drv["env"]["name"]
if "version" in drvData["env"]:
return name.removesuffix("-" + drvData["env"]["version"])
return name
for drv in old_derivation: for drv in old_derivation:
drvData = old_derivation[drv] drvData = old_derivation[drv]
if not "pname" in drvData["env"] and not "name" in drvData["env"]: if not "pname" in drvData["env"] and not "name" in drvData["env"]:
continue continue
used_name = drvData["env"]["pname"] if "pname" in drvData["env"] else drvData["env"]["name"] used_name = get_name(drvData)
if not "version" in drvData["env"]: if not "version" in drvData["env"]:
continue continue
version = drvData["env"]["version"] version = drvData["env"]["version"]
@ -31,7 +41,7 @@ for drv in new_derivation:
drvData = new_derivation[drv] drvData = new_derivation[drv]
if not "pname" in drvData["env"] and not "name" in drvData["env"]: if not "pname" in drvData["env"] and not "name" in drvData["env"]:
continue continue
used_name = drvData["env"]["pname"] if "pname" in drvData["env"] else drvData["env"]["name"] used_name = get_name(drvData)
if not "version" in drvData["env"]: if not "version" in drvData["env"]:
continue continue
version = drvData["env"]["version"] version = drvData["env"]["version"]
@ -43,13 +53,32 @@ for drv in new_derivation:
else: else:
packages[used_name] = {"new": {version}} packages[used_name] = {"new": {version}}
for package in packages: pkg_names = sorted(packages)
print("New packages")
for package in pkg_names:
if "new" in packages[package] and "old" not in packages[package]:
print(package + ": " + ", ".join(sorted(packages[package]["new"])))
print()
print("Old packages")
for package in pkg_names:
if "old" in packages[package] and "new" not in packages[package]:
print(package + ": " + ", ".join(sorted(packages[package]["old"])))
print()
print("Updated packages")
for package in pkg_names:
if "old" in packages[package] and "new" in packages[package]: if "old" in packages[package] and "new" in packages[package]:
if packages[package]["old"] != packages[package]["new"]: if packages[package]["old"] == packages[package]["new"]:
print( continue
f"{package}: {sorted(packages[package]['old'])} -> {sorted(packages[package]['new'])}" common_versions = packages[package]["old"].intersection(
) packages[package]["new"])
elif "old" in packages[package]: removed_versions = packages[package]["old"].difference(common_versions)
print(f"{package}: {sorted(packages[package]['old'])} -> removed") added_versions = packages[package]["new"].difference(common_versions)
elif "new" in packages[package]: common_versions_string = ", ".join(sorted(common_versions))
print(f"{package}: added -> {sorted(packages[package]['new'])}") removed_versions_string = ", ".join(sorted(removed_versions))
added_versions_string = ", ".join(sorted(added_versions))
print(
f"{package}: [{removed_versions_string}] -> [{added_versions_string}] (common: {common_versions_string})"
)