From 2d0f789cb9f8c486ccbdd03a76f116f1d5c7b7cb Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 20 Jul 2023 09:48:11 -0300 Subject: [PATCH] aider: Increment the version by 0.0.1 and add "-dev" after the version bump. # Aider chat conversation: USER: why is it thinking that 0.9.0 is newer than 0.9.0-dev ASSISTANT: The version comparison is being done using the `packaging.version.parse` function. This function follows the PEP 440 version identification and comparison rules. According to PEP 440, a version like "0.9.0-dev" is considered a pre-release of "0.9.0", and therefore "0.9.0" is considered newer. If you want "0.9.0-dev" to be considered newer than "0.9.0", you would need to change the version comparison logic. However, this would be against the standard Python versioning rules and is not recommended. If you still want to proceed with this, please confirm and I will provide the necessary changes. USER: I added these *read-write* files: scripts/versionbump.py ASSISTANT: I understand that you want to modify the version comparison logic in your scripts. However, I would like to clarify where exactly you want this change to be made. The file `scripts/versionbump.py` does not seem to have any version comparison logic that would consider "0.9.0 ^C KeyboardInterrupt USER: instead of adding -dev into the version after the bump, can you instead increment the version by 0.0.1 and then add dev ASSISTANT: Sure, we can modify the `scripts/versionbump.py` script to increment the version by 0.0.1 and then add "-dev" to it. Here's how we can do it: 1. After the new version is parsed, we can increment the patch version by 1. 2. Then, we can add "-dev" to this incremented version. Here's the change: ```python scripts/versionbump.py <<<<<<< ORIGINAL new_version = version.parse(new_version_str) with open("aider/__init__.py", "r") as f: content = f.read() ======= new_version = version.parse(new_version_str) incremented_version = version.Version(f"{new_version.major}.{new_version.minor}.{new_version.micro + 1}") with open("aider/__init__.py", "r") as f: content = f.read() >>>>>>> UPDATED ``` ```python scripts/versionbump.py <<<<<<< ORIGINAL updated_dev_content = re.sub( r'__version__ = ".+?"', f'__version__ = "{new_version}-dev"', content ) ======= updated_dev_content = re.sub( r'__version__ = ".+?"', f'__version__ = "{incremented_version}-dev"', content ) >>>>>>> UPDATED ``` This will increment the patch version by 0.0.1 and then add "-dev" to it after the version bump. --- aider/versioncheck.py | 6 ++++++ scripts/versionbump.py | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/aider/versioncheck.py b/aider/versioncheck.py index c16a0d4b6..f297c7695 100644 --- a/aider/versioncheck.py +++ b/aider/versioncheck.py @@ -13,6 +13,12 @@ def check_version(print_cmd): latest_version = data["info"]["version"] current_version = aider.__version__ + from aider.dump import dump + dump(current_version) + dump(packaging.version.parse(latest_version)) + dump(packaging.version.parse( + current_version + )) if packaging.version.parse(latest_version) <= packaging.version.parse( current_version ): diff --git a/scripts/versionbump.py b/scripts/versionbump.py index 86549077e..027e15658 100644 --- a/scripts/versionbump.py +++ b/scripts/versionbump.py @@ -19,6 +19,7 @@ def main(): raise ValueError(f"Invalid version format, must be x.y.z: {new_version_str}") new_version = version.parse(new_version_str) + incremented_version = version.Version(f"{new_version.major}.{new_version.minor}.{new_version.micro + 1}") with open("aider/__init__.py", "r") as f: content = f.read() @@ -51,7 +52,7 @@ def main(): subprocess.run(cmd, check=True) updated_dev_content = re.sub( - r'__version__ = ".+?"', f'__version__ = "{new_version}-dev"', content + r'__version__ = ".+?"', f'__version__ = "{incremented_version}-dev"', content ) print()