mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 14:55:00 +00:00
aider: Added check=True
parameter to subprocess.run()
calls in scripts/versionbump.py
to raise CalledProcessError
exception if any of the git commands fail.
# Context: USER: will those `subprocess` calls raise exceptions if the git commands error? ASSISTANT: Yes, by default, the `subprocess.run()` function will not raise an exception if the command returns a non-zero exit code. However, you can add the `check=True` parameter to the `subprocess.run()` calls to make them raise a `CalledProcessError` exception if the command returns a non-zero exit code. Here's the updated `scripts/versionbump.py` with the `check=True` parameter added: ```python scripts/versionbump.py <<<<<<< ORIGINAL subprocess.run(["git", "add", "aider/__init__.py"]) subprocess.run(["git", "commit", "-m", f"version bump to {new_version}"]) subprocess.run(["git", "tag", f"v{new_version}"]) subprocess.run(["git", "push", "origin"]) subprocess.run(["git", "push", "origin", f"v{new_version}"]) ======= subprocess.run(["git", "add", "aider/__init__.py"], check=True) subprocess.run(["git", "commit", "-m", f"version bump to {new_version}"], check=True) subprocess.run(["git", "tag", f"v{new_version}"], check=True) subprocess.run(["git", "push", "origin"], check=True) subprocess.run(["git", "push", "origin", f"v{new_version}"], check=True) >>>>>>> UPDATED ``` With these changes, if any of the git commands fail, the script will raise a `CalledProcessError` exception and terminate.
This commit is contained in:
parent
25ae54f6bf
commit
2181923859
1 changed files with 5 additions and 5 deletions
|
@ -25,11 +25,11 @@ def main():
|
||||||
with open("aider/__init__.py", "w") as f:
|
with open("aider/__init__.py", "w") as f:
|
||||||
f.write(updated_content)
|
f.write(updated_content)
|
||||||
|
|
||||||
subprocess.run(["git", "add", "aider/__init__.py"])
|
subprocess.run(["git", "add", "aider/__init__.py"], check=True)
|
||||||
subprocess.run(["git", "commit", "-m", f"version bump to {new_version}"])
|
subprocess.run(["git", "commit", "-m", f"version bump to {new_version}"], check=True)
|
||||||
subprocess.run(["git", "tag", f"v{new_version}"])
|
subprocess.run(["git", "tag", f"v{new_version}"], check=True)
|
||||||
subprocess.run(["git", "push", "origin"])
|
subprocess.run(["git", "push", "origin"], check=True)
|
||||||
subprocess.run(["git", "push", "origin", f"v{new_version}"])
|
subprocess.run(["git", "push", "origin", f"v{new_version}"], check=True)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue