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,
|
stream=True,
|
||||||
use_git=True,
|
use_git=True,
|
||||||
voice_language=None,
|
voice_language=None,
|
||||||
|
aider_ignore_file=None,
|
||||||
):
|
):
|
||||||
if not fnames:
|
if not fnames:
|
||||||
fnames = []
|
fnames = []
|
||||||
|
@ -154,7 +155,7 @@ class Coder:
|
||||||
|
|
||||||
if use_git:
|
if use_git:
|
||||||
try:
|
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
|
self.root = self.repo.root
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
self.repo = None
|
self.repo = None
|
||||||
|
|
|
@ -305,10 +305,13 @@ def main(argv=None, input=None, output=None, force_git_root=None):
|
||||||
default=True,
|
default=True,
|
||||||
help="Enable/disable adding .aider* to .gitignore (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(
|
git_group.add_argument(
|
||||||
"--aiderignore",
|
"--aiderignore",
|
||||||
metavar="AIDERIGNORE",
|
metavar="AIDERIGNORE",
|
||||||
default=".aiderignore",
|
default=default_aiderignore_file,
|
||||||
help="Specify the aider ignore file (default: .aiderignore in git root)",
|
help="Specify the aider ignore file (default: .aiderignore in git root)",
|
||||||
)
|
)
|
||||||
git_group.add_argument(
|
git_group.add_argument(
|
||||||
|
@ -507,6 +510,7 @@ def main(argv=None, input=None, output=None, force_git_root=None):
|
||||||
stream=args.stream,
|
stream=args.stream,
|
||||||
use_git=args.git,
|
use_git=args.git,
|
||||||
voice_language=args.voice_language,
|
voice_language=args.voice_language,
|
||||||
|
aider_ignore_file=args.aiderignore,
|
||||||
)
|
)
|
||||||
except ValueError as err:
|
except ValueError as err:
|
||||||
io.tool_error(str(err))
|
io.tool_error(str(err))
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import os
|
import os
|
||||||
import pathspec
|
|
||||||
from pathlib import Path, PurePosixPath
|
from pathlib import Path, PurePosixPath
|
||||||
|
|
||||||
import git
|
import git
|
||||||
|
import pathspec
|
||||||
|
|
||||||
from aider import models, prompts, utils
|
from aider import models, prompts, utils
|
||||||
from aider.sendchat import simple_send_with_retries
|
from aider.sendchat import simple_send_with_retries
|
||||||
|
@ -196,14 +196,14 @@ class GitRepo:
|
||||||
for path in files
|
for path in files
|
||||||
)
|
)
|
||||||
|
|
||||||
return res
|
return self.filter_ignored_files(res)
|
||||||
|
|
||||||
def filter_ignored_files(self, fnames):
|
def filter_ignored_files(self, fnames):
|
||||||
if not self.aider_ignore_file:
|
if not self.aider_ignore_file:
|
||||||
return fnames
|
return fnames
|
||||||
|
|
||||||
with open(self.aider_ignore_file, 'r') as f:
|
with open(self.aider_ignore_file, "r") as f:
|
||||||
ignore_spec = pathspec.PathSpec.from_lines('gitwildmatch', f)
|
ignore_spec = pathspec.PathSpec.from_lines("gitwildmatch", f)
|
||||||
|
|
||||||
return [fname for fname in fnames if not ignore_spec.match_file(fname)]
|
return [fname for fname in fnames if not ignore_spec.match_file(fname)]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue