From 644b22ca2c0b6fc29624ce9ac8ad77d3d1a8a5fb Mon Sep 17 00:00:00 2001 From: Stefanie Jane Date: Sat, 24 Aug 2024 23:49:19 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20version=20regex=20in=20upd?= =?UTF-8?q?ate=5Fversion=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modify regex pattern to match version at start of line Update the regular expression in update_version function to ensure it only matches the version field at the beginning of a line in Cargo.toml. This prevents unintended matches in other parts of the file. - Add '^' to the start of the regex pattern - This change improves the reliability of version updates --- scripts/release.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release.py b/scripts/release.py index a2dda22..52c7ddc 100755 --- a/scripts/release.py +++ b/scripts/release.py @@ -179,7 +179,7 @@ def update_version(new_version: str) -> None: """Update the version in Cargo.toml.""" with open("Cargo.toml", "r") as f: content = f.read() - updated_content = re.sub(r'(version\s*=\s*)"(\d+\.\d+\.\d+)"', f'\\1"{new_version}"', content) + updated_content = re.sub(r'^(version\s*=\s*)"(\d+\.\d+\.\d+)"', f'\\1"{new_version}"', content) with open("Cargo.toml", "w") as f: f.write(updated_content) print_success(f"Updated version in Cargo.toml to {new_version}")