mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-20 12:24:59 +00:00
feat: add check_cog_pyproject function to run cog -r on pyproject.toml and abort if it has changed the file
This commit is contained in:
parent
5d14d93594
commit
211ab28253
1 changed files with 20 additions and 1 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue