aider: Set version to x.y.z-dev and push to origin.

# Aider chat conversation:

USER: I did `git reset --hard HEAD~1` to discard the last edits.

ASSISTANT: Okay, that command will undo the last commit and discard the changes. If you need to make any further changes or need assistance with anything else, feel free to ask.

USER: we need to commit __init__ with x.y.z, tag it, push it. and THEN write a new __init__ with the -dev version, and then commit that.

ASSISTANT: Understood. We need to modify the `scripts/versionbump.py` file to implement this.

Here are the proposed changes:

```python
scripts/versionbump.py
<<<<<<< ORIGINAL
    updated_content = re.sub(r'__version__ = ".+?"', f'__version__ = "{new_version}"', content)

    if dry_run:
        print("Updating aider/__init__.py with new version:")
        print(updated_content)
    else:
        with open("aider/__init__.py", "w") as f:
            f.write(updated_content)

    git_commands = [
        ["git", "add", "aider/__init__.py"],
        ["git", "commit", "-m", f"version bump to {new_version}"],
        ["git", "tag", f"v{new_version}"],
        ["git", "push", "origin"],
        ["git", "push", "origin", f"v{new_version}"],
    ]
=======
    updated_content = re.sub(r'__version__ = ".+?"', f'__version__ = "{new_version}"', content)

    if dry_run:
        print("Updating aider/__init__.py with new version:")
        print(updated_content)
    else:
        with open("aider/__init__.py", "w") as f:
            f.write(updated_content)

    git_commands = [
        ["git", "add", "aider/__init__.py"],
        ["git", "commit", "-m", f"version bump to {new_version}"],
        ["git", "tag", f"v{new_version}"],
        ["git", "push", "origin"],
        ["git", "push", "origin", f"v{new_version}"],
    ]

    for cmd in git_commands:
        if dry_run:
            print(f"Running: {' '.join(cmd)}")
        else:
            subprocess.run(cmd, check=True)

    updated_dev_content = re.sub(r'__version__ = ".+?"', f'__version__ = "{new_version}-dev"', content)

    if dry_run:
        print("Updating aider/__init__.py with new dev version:")
        print(updated_dev_content)
    else:
        with open("aider/__init__.py", "w") as f:
            f.write(updated_dev_content)

    git_commands_dev = [
        ["git", "add", "aider/__init__.py"],
        ["git", "commit", "-m", f"set version to {new_version}-dev"],
        ["git", "push", "origin"],
    ]

    for cmd in git_commands_dev:
        if dry_run:
            print(f"Running: {' '.join(cmd)}")
        else:
            subprocess.run(cmd, check=True)
>>>>>>> UPDATED
```

These changes will ensure that the version in `aider/__init__.py` is set to 'x.y.z', committed, tagged, and pushed. Then, it will be updated to 'x.y.z-dev', committed, and pushed.
This commit is contained in:
Paul Gauthier 2023-07-11 18:36:02 -07:00
parent 967cb1bd8d
commit 54939d5f6c

View file

@ -52,6 +52,33 @@ def main():
else:
subprocess.run(cmd, check=True)
updated_dev_content = re.sub(r'__version__ = ".+?"', f'__version__ = "{new_version}-dev"', content)
if dry_run:
print("Updating aider/__init__.py with new dev version:")
print(updated_dev_content)
else:
with open("aider/__init__.py", "w") as f:
f.write(updated_dev_content)
git_commands_dev = [
["git", "add", "aider/__init__.py"],
["git", "commit", "-m", f"set version to {new_version}-dev"],
["git", "push", "origin"],
]
for cmd in git_commands_dev:
if dry_run:
print(f"Running: {' '.join(cmd)}")
else:
subprocess.run(cmd, check=True)
for cmd in git_commands:
if dry_run:
print(f"Running: {' '.join(cmd)}")
else:
subprocess.run(cmd, check=True)
if __name__ == "__main__":
main()