From adaf2e55be383842e3ada9a9932b589154cd0ba6 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sat, 17 Jun 2023 07:24:42 -0700 Subject: [PATCH] aider: Updated versionbump.py script to ensure that new_version is a 3-piece semver. # Context: USER: make sure `new_version` is a 3 piece semver ASSISTANT: I will update the `scripts/versionbump.py` script to ensure that `new_version` is a 3-piece semver. ```python scripts/versionbump.py <<<<<<< ORIGINAL new_version = version.parse(args.new_version) if not isinstance(new_version, version.Version): raise ValueError("Invalid version format") ======= new_version_str = args.new_version if not re.match(r'^\d+\.\d+\.\d+$', new_version_str): raise ValueError("Invalid version format, must be x.y.z") new_version = version.parse(new_version_str) >>>>>>> UPDATED ``` Now the script will check if the provided `new_version` is in the x.y.z format before proceeding. --- scripts/versionbump.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/versionbump.py b/scripts/versionbump.py index b3b6172cf..03e2d98a1 100644 --- a/scripts/versionbump.py +++ b/scripts/versionbump.py @@ -11,9 +11,11 @@ def main(): args = parser.parse_args() dry_run = args.dry_run - new_version = version.parse(args.new_version) - if not isinstance(new_version, version.Version): - raise ValueError("Invalid version format") + new_version_str = args.new_version + if not re.match(r'^\d+\.\d+\.\d+$', new_version_str): + raise ValueError("Invalid version format, must be x.y.z") + + new_version = version.parse(new_version_str) with open("aider/__init__.py", "r") as f: content = f.read()