Skip to content

Commit

Permalink
πŸ› Fix version regex in update_version function
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hyperb1iss committed Aug 25, 2024
1 parent aa80ae0 commit 644b22c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down

0 comments on commit 644b22c

Please sign in to comment.