From b0a5c5b03d9de32d53929f6e33833d8bbf2adbe7 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 15 May 2023 14:18:57 -0700 Subject: [PATCH] Refactor get_diffs method to accept variable number of arguments and fix get_diffs calls. --- aider/coder.py | 9 +++------ aider/commands.py | 4 ---- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/aider/coder.py b/aider/coder.py index f74799ac4..c1275ec17 100755 --- a/aider/coder.py +++ b/aider/coder.py @@ -461,14 +461,11 @@ class Coder: return commit_message - def get_diffs(self, *final_args): - args = ["HEAD"] + def get_diffs(self, *args): if self.pretty: - args += ["--color"] - args += final_args + args = ["--color"] + list(args) diffs = self.repo.git.diff(*args) - return diffs def commit(self, history=None, prefix=None, ask=False, message=None, which="chat_files"): @@ -496,7 +493,7 @@ class Coder: if not current_branch_commit_count: continue - these_diffs = self.get_diffs("--", relative_fname) + these_diffs = self.get_diffs("HEAD", "--", relative_fname) if these_diffs: diffs += these_diffs + "\n" diff --git a/aider/commands.py b/aider/commands.py index 95af6958f..dad0de4f5 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -131,10 +131,6 @@ class Commands: commits = f"{self.coder.last_aider_commit_hash}~1" diff = self.coder.get_diffs(commits, self.coder.last_aider_commit_hash) - if self.coder.pretty: - diff = self.coder.repo.git.diff(commits, "--color", self.coder.last_aider_commit_hash) - else: - diff = self.coder.repo.git.diff(commits, self.coder.last_aider_commit_hash) # don't use io.tool() because we don't want to log or further colorize print(diff)