mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-10 14:45:00 +00:00
Aider should fully ignore files in aiderignore #479
This commit is contained in:
parent
5e60417e5d
commit
a9fe4532c7
5 changed files with 83 additions and 14 deletions
|
@ -156,6 +156,22 @@ class Coder:
|
|||
|
||||
self.commands = Commands(self.io, self, voice_language)
|
||||
|
||||
if use_git:
|
||||
try:
|
||||
self.repo = GitRepo(
|
||||
self.io, fnames, git_dname, aider_ignore_file, client=self.client
|
||||
)
|
||||
self.root = self.repo.root
|
||||
except FileNotFoundError:
|
||||
self.repo = None
|
||||
|
||||
if self.repo:
|
||||
filtered_fnames = self.repo.filter_ignored_files(fnames)
|
||||
for fname in fnames:
|
||||
if fname not in filtered_fnames:
|
||||
self.io.tool_error(f"Skipping {fname} that matches aiderignore spec.")
|
||||
fnames = filtered_fnames
|
||||
|
||||
for fname in fnames:
|
||||
fname = Path(fname)
|
||||
if not fname.exists():
|
||||
|
@ -167,16 +183,6 @@ class Coder:
|
|||
raise ValueError(f"{fname} is not a file")
|
||||
|
||||
self.abs_fnames.add(str(fname.resolve()))
|
||||
|
||||
if use_git:
|
||||
try:
|
||||
self.repo = GitRepo(
|
||||
self.io, fnames, git_dname, aider_ignore_file, client=self.client
|
||||
)
|
||||
self.root = self.repo.root
|
||||
except FileNotFoundError:
|
||||
self.repo = None
|
||||
|
||||
if self.repo:
|
||||
rel_repo_dir = self.repo.get_rel_repo_dir()
|
||||
num_files = len(self.repo.get_tracked_files())
|
||||
|
|
|
@ -342,6 +342,10 @@ class Commands:
|
|||
else:
|
||||
fname = Path(self.coder.root) / word
|
||||
|
||||
if self.coder.repo and not self.coder.repo.filter_ignored_files([fname]):
|
||||
self.io.tool_error(f"Skipping {fname} that matches aiderignore spec.")
|
||||
continue
|
||||
|
||||
if fname.exists() and fname.is_file():
|
||||
all_matched_files.add(str(fname))
|
||||
continue
|
||||
|
|
|
@ -41,6 +41,8 @@ class GitRepo:
|
|||
repo_paths.append(repo_path)
|
||||
except git.exc.InvalidGitRepositoryError:
|
||||
pass
|
||||
except git.exc.NoSuchPathError:
|
||||
pass
|
||||
|
||||
num_repos = len(set(repo_paths))
|
||||
|
||||
|
@ -194,10 +196,7 @@ class GitRepo:
|
|||
files.extend(staged_files)
|
||||
|
||||
# convert to appropriate os.sep, since git always normalizes to /
|
||||
res = set(
|
||||
self.normalize_path(path)
|
||||
for path in files
|
||||
)
|
||||
res = set(self.normalize_path(path) for path in files)
|
||||
|
||||
return self.filter_ignored_files(res)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue