mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 06:44:59 +00:00
Accept either a git dname or a list of fnames
This commit is contained in:
parent
256dd7bbd9
commit
64c50bab48
3 changed files with 109 additions and 27 deletions
|
@ -12,10 +12,12 @@ from .dump import dump # noqa: F401
|
|||
class GitRepo:
|
||||
repo = None
|
||||
|
||||
def __init__(self, io, fnames):
|
||||
def __init__(self, io, fnames, git_dname):
|
||||
self.io = io
|
||||
|
||||
if fnames:
|
||||
if git_dname:
|
||||
check_fnames = [git_dname]
|
||||
elif fnames:
|
||||
check_fnames = fnames
|
||||
else:
|
||||
check_fnames = ["."]
|
||||
|
@ -25,6 +27,9 @@ class GitRepo:
|
|||
fname = Path(fname)
|
||||
fname = fname.resolve()
|
||||
|
||||
if not fname.exists() and fname.parent.exists():
|
||||
fname = fname.parent
|
||||
|
||||
try:
|
||||
repo_path = git.Repo(fname, search_parent_directories=True).working_dir
|
||||
repo_path = utils.safe_abs_path(repo_path)
|
||||
|
@ -49,6 +54,8 @@ class GitRepo:
|
|||
for fname in fnames:
|
||||
if Path(fname).resolve() in cur_files:
|
||||
continue
|
||||
if not Path(fname).exists():
|
||||
continue
|
||||
self.io.tool_output(f"Adding {fname} to git")
|
||||
self.repo.git.add(fname)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue