From 54939d5f6ca260ef745b91c15a748f5cb34edd52 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 11 Jul 2023 18:36:02 -0700 Subject: [PATCH] aider: Set version to x.y.z-dev and push to origin. # Aider chat conversation: USER: I did `git reset --hard HEAD~1` to discard the last edits. ASSISTANT: Okay, that command will undo the last commit and discard the changes. If you need to make any further changes or need assistance with anything else, feel free to ask. USER: we need to commit __init__ with x.y.z, tag it, push it. and THEN write a new __init__ with the -dev version, and then commit that. ASSISTANT: Understood. We need to modify the `scripts/versionbump.py` file to implement this. Here are the proposed changes: ```python scripts/versionbump.py <<<<<<< ORIGINAL updated_content = re.sub(r'__version__ = ".+?"', f'__version__ = "{new_version}"', content) if dry_run: print("Updating aider/__init__.py with new version:") print(updated_content) else: with open("aider/__init__.py", "w") as f: f.write(updated_content) git_commands = [ ["git", "add", "aider/__init__.py"], ["git", "commit", "-m", f"version bump to {new_version}"], ["git", "tag", f"v{new_version}"], ["git", "push", "origin"], ["git", "push", "origin", f"v{new_version}"], ] ======= updated_content = re.sub(r'__version__ = ".+?"', f'__version__ = "{new_version}"', content) if dry_run: print("Updating aider/__init__.py with new version:") print(updated_content) else: with open("aider/__init__.py", "w") as f: f.write(updated_content) git_commands = [ ["git", "add", "aider/__init__.py"], ["git", "commit", "-m", f"version bump to {new_version}"], ["git", "tag", f"v{new_version}"], ["git", "push", "origin"], ["git", "push", "origin", f"v{new_version}"], ] for cmd in git_commands: if dry_run: print(f"Running: {' '.join(cmd)}") else: subprocess.run(cmd, check=True) updated_dev_content = re.sub(r'__version__ = ".+?"', f'__version__ = "{new_version}-dev"', content) if dry_run: print("Updating aider/__init__.py with new dev version:") print(updated_dev_content) else: with open("aider/__init__.py", "w") as f: f.write(updated_dev_content) git_commands_dev = [ ["git", "add", "aider/__init__.py"], ["git", "commit", "-m", f"set version to {new_version}-dev"], ["git", "push", "origin"], ] for cmd in git_commands_dev: if dry_run: print(f"Running: {' '.join(cmd)}") else: subprocess.run(cmd, check=True) >>>>>>> UPDATED ``` These changes will ensure that the version in `aider/__init__.py` is set to 'x.y.z', committed, tagged, and pushed. Then, it will be updated to 'x.y.z-dev', committed, and pushed. --- scripts/versionbump.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/scripts/versionbump.py b/scripts/versionbump.py index 758faa03a..3a49325e5 100644 --- a/scripts/versionbump.py +++ b/scripts/versionbump.py @@ -52,6 +52,33 @@ def main(): else: subprocess.run(cmd, check=True) + updated_dev_content = re.sub(r'__version__ = ".+?"', f'__version__ = "{new_version}-dev"', content) + + if dry_run: + print("Updating aider/__init__.py with new dev version:") + print(updated_dev_content) + else: + with open("aider/__init__.py", "w") as f: + f.write(updated_dev_content) + + git_commands_dev = [ + ["git", "add", "aider/__init__.py"], + ["git", "commit", "-m", f"set version to {new_version}-dev"], + ["git", "push", "origin"], + ] + + for cmd in git_commands_dev: + if dry_run: + print(f"Running: {' '.join(cmd)}") + else: + subprocess.run(cmd, check=True) + + for cmd in git_commands: + if dry_run: + print(f"Running: {' '.join(cmd)}") + else: + subprocess.run(cmd, check=True) + if __name__ == "__main__": main()