diff --git a/scripts/versionbump.py b/scripts/versionbump.py index e7584f3e4..e81b10d95 100755 --- a/scripts/versionbump.py +++ b/scripts/versionbump.py @@ -5,10 +5,28 @@ import datetime import re import subprocess import sys - +import tempfile +import filecmp from packaging import version +def check_cog_pyproject(): + with tempfile.NamedTemporaryFile(mode='w+', delete=False) as temp_file: + with open('pyproject.toml', 'r') as original_file: + temp_file.write(original_file.read()) + + result = subprocess.run(["cog", "-r", "pyproject.toml"], capture_output=True, text=True) + + if result.returncode != 0: + print("Error: cog -r pyproject.toml failed with the following output:") + print(result.stderr) + sys.exit(1) + + if not filecmp.cmp('pyproject.toml', temp_file.name): + print("Error: cog -r pyproject.toml has changed the file. Please run cog -r pyproject.toml and commit the changes.") + sys.exit(1) + + def main(): parser = argparse.ArgumentParser(description="Bump version") parser.add_argument("new_version", help="New version in x.y.z format") @@ -56,6 +74,7 @@ def main(): check_branch() check_working_directory_clean() check_main_branch_up_to_date() + check_cog_pyproject() new_version_str = args.new_version if not re.match(r"^\d+\.\d+\.\d+$", new_version_str):