mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 14:55:00 +00:00
Refactor getting staged files to handle ValueError.
This commit is contained in:
parent
89542d2139
commit
f87ec8c38b
1 changed files with 7 additions and 8 deletions
|
@ -147,19 +147,18 @@ class GitRepo:
|
|||
try:
|
||||
commit = self.repo.head.commit
|
||||
except ValueError:
|
||||
return set()
|
||||
commit = None
|
||||
|
||||
files = []
|
||||
for blob in commit.tree.traverse():
|
||||
if blob.type == "blob": # blob is a file
|
||||
files.append(blob.path)
|
||||
if commit:
|
||||
for blob in commit.tree.traverse():
|
||||
if blob.type == "blob": # blob is a file
|
||||
files.append(blob.path)
|
||||
|
||||
# Add staged files
|
||||
index = self.repo.index
|
||||
try:
|
||||
staged_files = [item.a_path for item in index.diff("HEAD")]
|
||||
except git.exc.BadName:
|
||||
staged_files = [item.a_path for item in index.diff(None)]
|
||||
staged_files = [item.a_path for item in index.diff(None)]
|
||||
dump(staged_files)
|
||||
files.extend(staged_files)
|
||||
|
||||
# convert to appropriate os.sep, since git always normalizes to /
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue