mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 23:05: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:
|
try:
|
||||||
commit = self.repo.head.commit
|
commit = self.repo.head.commit
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return set()
|
commit = None
|
||||||
|
|
||||||
files = []
|
files = []
|
||||||
for blob in commit.tree.traverse():
|
if commit:
|
||||||
if blob.type == "blob": # blob is a file
|
for blob in commit.tree.traverse():
|
||||||
files.append(blob.path)
|
if blob.type == "blob": # blob is a file
|
||||||
|
files.append(blob.path)
|
||||||
|
|
||||||
# Add staged files
|
# Add staged files
|
||||||
index = self.repo.index
|
index = self.repo.index
|
||||||
try:
|
staged_files = [item.a_path for item in index.diff(None)]
|
||||||
staged_files = [item.a_path for item in index.diff("HEAD")]
|
dump(staged_files)
|
||||||
except git.exc.BadName:
|
|
||||||
staged_files = [item.a_path for item in index.diff(None)]
|
|
||||||
files.extend(staged_files)
|
files.extend(staged_files)
|
||||||
|
|
||||||
# convert to appropriate os.sep, since git always normalizes to /
|
# convert to appropriate os.sep, since git always normalizes to /
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue