mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-20 04:14:59 +00:00
refac
This commit is contained in:
parent
02c9a30c45
commit
f1350f169f
5 changed files with 167 additions and 154 deletions
|
@ -1,18 +1,21 @@
|
|||
import argparse
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
from packaging import version
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Bump version")
|
||||
parser.add_argument("new_version", help="New version in x.y.z format")
|
||||
parser.add_argument("--dry-run", action="store_true", help="Print each step without actually executing them")
|
||||
parser.add_argument(
|
||||
"--dry-run", action="store_true", help="Print each step without actually executing them"
|
||||
)
|
||||
args = parser.parse_args()
|
||||
dry_run = args.dry_run
|
||||
|
||||
new_version_str = args.new_version
|
||||
if not re.match(r'^\d+\.\d+\.\d+$', new_version_str):
|
||||
if not re.match(r"^\d+\.\d+\.\d+$", new_version_str):
|
||||
raise ValueError(f"Invalid version format, must be x.y.z: {new_version_str}")
|
||||
|
||||
new_version = version.parse(new_version_str)
|
||||
|
@ -22,7 +25,9 @@ def main():
|
|||
|
||||
current_version = re.search(r'__version__ = "(.+?)"', content).group(1)
|
||||
if new_version <= version.parse(current_version):
|
||||
raise ValueError(f"New version {new_version} must be greater than the current version {current_version}")
|
||||
raise ValueError(
|
||||
f"New version {new_version} must be greater than the current version {current_version}"
|
||||
)
|
||||
|
||||
updated_content = re.sub(r'__version__ = ".+?"', f'__version__ = "{new_version}"', content)
|
||||
|
||||
|
@ -47,5 +52,6 @@ def main():
|
|||
else:
|
||||
subprocess.run(cmd, check=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue