From 8609594c0e28a06e6665c886b071101c8dfb9268 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Wed, 4 Sep 2024 08:43:00 -0700 Subject: [PATCH] refactor: split cmd_undo and cmd_commit into raw and exception-handling methods --- aider/commands.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/aider/commands.py b/aider/commands.py index 953c038b6..3041ae4f8 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -231,7 +231,12 @@ class Commands: def cmd_commit(self, args=None): "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: self.io.tool_error("No git repository found.") return @@ -423,6 +428,12 @@ class Commands: def cmd_undo(self, args): "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: self.io.tool_error("No git repository found.") return