mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-23 22:04:59 +00:00
aider: Refactored aider/coder.py
to check if there are any commits on the current branch before running the git diff
command.
# Context: USER: can we check if there are any commits on the current branch? rather than any commits in the entire repo? ASSISTANT: Sure, we can check if there are any commits on the current branch by comparing the current branch's commit count to zero. Here's the change: ```python aider/coder.py <<<<<<< ORIGINAL if len(repo.heads) > 0: these_diffs = repo.git.diff("HEAD", "--color", "--", relative_fname) else: these_diffs = "" ======= current_branch_commit_count = len(list(repo.iter_commits(repo.active_branch))) if current_branch_commit_count > 0: these_diffs = repo.git.diff("HEAD", "--color", "--", relative_fname) else: these_diffs = "" >>>>>>> UPDATED ``` This will check if there are any commits on the current branch before running the `git diff` command.
This commit is contained in:
parent
0cd5f5b812
commit
a66cbe216e
1 changed files with 2 additions and 1 deletions
|
@ -465,7 +465,8 @@ class Coder:
|
|||
for fname in file_list:
|
||||
relative_fname = os.path.relpath(fname, repo.working_tree_dir)
|
||||
if self.pretty:
|
||||
if len(repo.heads) > 0:
|
||||
current_branch_commit_count = len(list(repo.iter_commits(repo.active_branch)))
|
||||
if current_branch_commit_count > 0:
|
||||
these_diffs = repo.git.diff("HEAD", "--color", "--", relative_fname)
|
||||
else:
|
||||
these_diffs = ""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue