refactor: split cmd_undo and cmd_commit into raw and exception-handling methods

This commit is contained in:
Paul Gauthier (aider) 2024-09-04 08:43:00 -07:00
parent bb9cb629e4
commit 8609594c0e

View file

@ -231,7 +231,12 @@ class Commands:
def cmd_commit(self, args=None): def cmd_commit(self, args=None):
"Commit edits to the repo made outside the chat (commit message optional)" "Commit edits to the repo made outside the chat (commit message optional)"
try:
self.cmd_commit_raw(args)
except ANY_GIT_ERROR as err:
self.io.tool_error(f"Unable to complete commit: {err}")
def cmd_commit_raw(self, args=None):
if not self.coder.repo: if not self.coder.repo:
self.io.tool_error("No git repository found.") self.io.tool_error("No git repository found.")
return return
@ -423,6 +428,12 @@ class Commands:
def cmd_undo(self, args): def cmd_undo(self, args):
"Undo the last git commit if it was done by aider" "Undo the last git commit if it was done by aider"
try:
self.cmd_undo_raw(args)
except ANY_GIT_ERROR as err:
self.io.tool_error(f"Unable to complete undo: {err}")
def cmd_undo_raw(self, args):
if not self.coder.repo: if not self.coder.repo:
self.io.tool_error("No git repository found.") self.io.tool_error("No git repository found.")
return return