Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command to merge changelogs from multiple sub-projects into one #144

Open
NiklasRosenstein opened this issue Mar 19, 2024 · 0 comments

Comments

@NiklasRosenstein
Copy link
Owner

from pathlib import Path
from tomli import loads
from tomli_w import dumps

dirs = [
    "databind/.changelog",
    "databind.core/.changelog",
    "databind.json/.changelog",
]

output = ".changelog"

releases = {x.name for d in dirs for x in Path(d).iterdir()}

for release in releases:
    files = [Path(d) / release for d in dirs]
    payloads = [(f.parent.parent.name, loads(f.read_text())) for f in files if f.is_file()]

    release_dates = {x[1].get("release-date") for x in payloads}
    if len(release_dates) != 1:
        release_date = min(filter(None, release_dates))
        print(f"warning: mismatching release-date values in {release}: {release_dates}; using {release_date}")
    else:
        release_date = release_dates.pop()

    entries = [{**e, "component": x[0]} for x in payloads for e in x[1].get("entries", [])]

    dest = Path(output) / release
    result = {"entries": entries}
    if release_date is not None:
        result["release-date"] = release_date
    dest.write_text(dumps(result))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant