From 143683c7fd386308c20a97e5b0aa8a808d038cd6 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 10 May 2023 12:47:34 -0700 Subject: [PATCH] Saving dirty files before chat --- aider/coder.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/aider/coder.py b/aider/coder.py index 9a4eb2aee..42190efaa 100755 --- a/aider/coder.py +++ b/aider/coder.py @@ -42,7 +42,6 @@ class Coder: self.console = Console(force_terminal=True, no_color=True) self.commands = Commands(self.console, self) - self.commands.add("diff", self.cmd_diff, "Display the diff of the last aider commit") self.main_model = main_model if main_model == "gpt-3.5-turbo": self.console.print( @@ -520,6 +519,19 @@ class Coder: self.repo.git.reset("--hard", "HEAD~1") self.console.print(f"[red]Undid the last commit: {last_commit.message.strip()}") + def cmd_diff(self, args): + "Display the diff of the last aider commit" + if not self.repo: + self.console.print("[red]No git repository found.") + return + + if not self.last_aider_commit_hash: + self.console.print("[red]No previous aider commit found.") + return + + diff = self.repo.git.diff(f"{self.last_aider_commit_hash}~1", self.last_aider_commit_hash) + self.console.print(Text(diff)) + def cmd_add(self, args): "Add matching files to the chat" @@ -544,19 +556,6 @@ class Coder: self.fnames.remove(matched_file) self.console.print(f"[red]Removed {relative_fname} from the chat") - def cmd_diff(self, args): - "Display the diff of the last aider commit" - if not self.repo: - self.console.print("[red]No git repository found.") - return - - if not self.last_aider_commit_hash: - self.console.print("[red]No previous aider commit found.") - return - - diff = self.repo.git.diff(f"{self.last_aider_commit_hash}~1", self.last_aider_commit_hash) - self.console.print(Text(diff)) - def cmd_ls(self, args): "List files and show their chat status"