Refactor get_diffs method to accept variable number of arguments and fix get_diffs calls.

This commit is contained in:
Paul Gauthier 2023-05-15 14:18:57 -07:00
parent d59c821019
commit b0a5c5b03d
2 changed files with 3 additions and 10 deletions

View file

@ -461,14 +461,11 @@ class Coder:
return commit_message return commit_message
def get_diffs(self, *final_args): def get_diffs(self, *args):
args = ["HEAD"]
if self.pretty: if self.pretty:
args += ["--color"] args = ["--color"] + list(args)
args += final_args
diffs = self.repo.git.diff(*args) diffs = self.repo.git.diff(*args)
return diffs return diffs
def commit(self, history=None, prefix=None, ask=False, message=None, which="chat_files"): 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: if not current_branch_commit_count:
continue continue
these_diffs = self.get_diffs("--", relative_fname) these_diffs = self.get_diffs("HEAD", "--", relative_fname)
if these_diffs: if these_diffs:
diffs += these_diffs + "\n" diffs += these_diffs + "\n"

View file

@ -131,10 +131,6 @@ class Commands:
commits = f"{self.coder.last_aider_commit_hash}~1" commits = f"{self.coder.last_aider_commit_hash}~1"
diff = self.coder.get_diffs(commits, self.coder.last_aider_commit_hash) 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 # don't use io.tool() because we don't want to log or further colorize
print(diff) print(diff)