mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 22:34:59 +00:00
roughed in .aiderignore
This commit is contained in:
parent
f8e30ad7a0
commit
9725b236a3
3 changed files with 11 additions and 6 deletions
|
@ -100,6 +100,7 @@ class Coder:
|
|||
stream=True,
|
||||
use_git=True,
|
||||
voice_language=None,
|
||||
aider_ignore_file=None,
|
||||
):
|
||||
if not fnames:
|
||||
fnames = []
|
||||
|
@ -154,7 +155,7 @@ class Coder:
|
|||
|
||||
if use_git:
|
||||
try:
|
||||
self.repo = GitRepo(self.io, fnames, git_dname)
|
||||
self.repo = GitRepo(self.io, fnames, git_dname, aider_ignore_file)
|
||||
self.root = self.repo.root
|
||||
except FileNotFoundError:
|
||||
self.repo = None
|
||||
|
|
|
@ -305,10 +305,13 @@ def main(argv=None, input=None, output=None, force_git_root=None):
|
|||
default=True,
|
||||
help="Enable/disable adding .aider* to .gitignore (default: True)",
|
||||
)
|
||||
default_aiderignore_file = (
|
||||
os.path.join(git_root, ".aiderignore") if git_root else ".aiderignore"
|
||||
)
|
||||
git_group.add_argument(
|
||||
"--aiderignore",
|
||||
metavar="AIDERIGNORE",
|
||||
default=".aiderignore",
|
||||
default=default_aiderignore_file,
|
||||
help="Specify the aider ignore file (default: .aiderignore in git root)",
|
||||
)
|
||||
git_group.add_argument(
|
||||
|
@ -507,6 +510,7 @@ def main(argv=None, input=None, output=None, force_git_root=None):
|
|||
stream=args.stream,
|
||||
use_git=args.git,
|
||||
voice_language=args.voice_language,
|
||||
aider_ignore_file=args.aiderignore,
|
||||
)
|
||||
except ValueError as err:
|
||||
io.tool_error(str(err))
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import os
|
||||
import pathspec
|
||||
from pathlib import Path, PurePosixPath
|
||||
|
||||
import git
|
||||
import pathspec
|
||||
|
||||
from aider import models, prompts, utils
|
||||
from aider.sendchat import simple_send_with_retries
|
||||
|
@ -196,14 +196,14 @@ class GitRepo:
|
|||
for path in files
|
||||
)
|
||||
|
||||
return res
|
||||
return self.filter_ignored_files(res)
|
||||
|
||||
def filter_ignored_files(self, fnames):
|
||||
if not self.aider_ignore_file:
|
||||
return fnames
|
||||
|
||||
with open(self.aider_ignore_file, 'r') as f:
|
||||
ignore_spec = pathspec.PathSpec.from_lines('gitwildmatch', f)
|
||||
with open(self.aider_ignore_file, "r") as f:
|
||||
ignore_spec = pathspec.PathSpec.from_lines("gitwildmatch", f)
|
||||
|
||||
return [fname for fname in fnames if not ignore_spec.match_file(fname)]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue