mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-23 22:04:59 +00:00
Added a try-except block to handle GitCommandError and added a check to skip if current_branch_commit_count is None.
This commit is contained in:
parent
a66cbe216e
commit
0213c4344a
1 changed files with 11 additions and 6 deletions
|
@ -464,17 +464,22 @@ class Coder:
|
|||
relative_dirty_files = []
|
||||
for fname in file_list:
|
||||
relative_fname = os.path.relpath(fname, repo.working_tree_dir)
|
||||
relative_dirty_files.append(relative_fname)
|
||||
|
||||
try:
|
||||
current_branch_commit_count = len(list(repo.iter_commits(repo.active_branch)))
|
||||
except git.exc.GitCommandError:
|
||||
current_branch_commit_count = None
|
||||
|
||||
if not current_branch_commit_count:
|
||||
continue
|
||||
|
||||
if self.pretty:
|
||||
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 = ""
|
||||
these_diffs = repo.git.diff("HEAD", "--color", "--", relative_fname)
|
||||
else:
|
||||
these_diffs = repo.git.diff("HEAD", relative_fname)
|
||||
|
||||
if these_diffs:
|
||||
relative_dirty_files.append(relative_fname)
|
||||
diffs += these_diffs + "\n"
|
||||
|
||||
return relative_dirty_files, diffs
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue