mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-23 13:54:59 +00:00
fix: Handle empty commit history in cmd_diff
This commit is contained in:
parent
9d0b3d17bc
commit
8769f31640
3 changed files with 6 additions and 4 deletions
|
@ -477,8 +477,8 @@ class Commands:
|
||||||
return
|
return
|
||||||
|
|
||||||
if len(self.coder.commit_before_message) < 2:
|
if len(self.coder.commit_before_message) < 2:
|
||||||
return
|
commit_before_message = current_head + "^"
|
||||||
|
else:
|
||||||
commit_before_message = self.coder.commit_before_message[-2]
|
commit_before_message = self.coder.commit_before_message[-2]
|
||||||
|
|
||||||
if not commit_before_message or commit_before_message == current_head:
|
if not commit_before_message or commit_before_message == current_head:
|
||||||
|
|
|
@ -227,6 +227,8 @@ class GitRepo:
|
||||||
args = []
|
args = []
|
||||||
if pretty:
|
if pretty:
|
||||||
args += ["--color"]
|
args += ["--color"]
|
||||||
|
else:
|
||||||
|
args += ["--color=never"]
|
||||||
|
|
||||||
args += [from_commit, to_commit]
|
args += [from_commit, to_commit]
|
||||||
diffs = self.repo.git.diff(*args)
|
diffs = self.repo.git.diff(*args)
|
||||||
|
|
|
@ -818,7 +818,7 @@ class TestCommands(TestCase):
|
||||||
|
|
||||||
# Mock repo.get_commit_message to return a canned commit message
|
# Mock repo.get_commit_message to return a canned commit message
|
||||||
with mock.patch.object(
|
with mock.patch.object(
|
||||||
repo, "get_commit_message", return_value="Canned commit message"
|
coder.repo, "get_commit_message", return_value="Canned commit message"
|
||||||
):
|
):
|
||||||
# Run cmd_commit
|
# Run cmd_commit
|
||||||
commands.cmd_commit()
|
commands.cmd_commit()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue