Scan the git index using entries, which does not rely on a prior commit

This commit is contained in:
Paul Gauthier 2023-07-24 14:00:35 -03:00
parent 96f15c4533
commit 745b3c320b

View file

@ -1007,16 +1007,18 @@ class Coder:
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
staged_files = [item.a_path for item in index.diff("HEAD")]
staged_files = [path for path, _ in index.entries.keys()]
files.extend(staged_files)
# convert to appropriate os.sep, since git always normalizes to /