import subprocess


def determine_version():
    result = subprocess.run(["hatch", "version"], capture_output=True)
    return result.stdout.decode().strip()


def get_changes(version):
    changes = []

    with open("../../CHANGES.md", "r") as fp:

        while line := fp.readline():
            if line.startswith(f"## {version}"):
                break

        changes.append(line)

        while line := fp.readline():
            if line.startswith("##"):
                break

            changes.append(line)

    return "".join(changes)
