mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 08:14:59 +00:00
feat: Initialize GitRepo in main, pass it into Coder
This commit is contained in:
parent
2fe3701f22
commit
70fbe10643
2 changed files with 23 additions and 22 deletions
|
@ -191,8 +191,8 @@ class Coder:
|
|||
self,
|
||||
main_model,
|
||||
io,
|
||||
repo=None,
|
||||
fnames=None,
|
||||
git_dname=None,
|
||||
pretty=True,
|
||||
show_diffs=False,
|
||||
auto_commits=True,
|
||||
|
@ -205,7 +205,6 @@ class Coder:
|
|||
stream=True,
|
||||
use_git=True,
|
||||
voice_language=None,
|
||||
aider_ignore_file=None,
|
||||
cur_messages=None,
|
||||
done_messages=None,
|
||||
max_chat_history_tokens=None,
|
||||
|
@ -214,13 +213,9 @@ class Coder:
|
|||
auto_test=False,
|
||||
lint_cmds=None,
|
||||
test_cmd=None,
|
||||
attribute_author=True,
|
||||
attribute_committer=True,
|
||||
attribute_commit_message=False,
|
||||
aider_commit_hashes=None,
|
||||
map_mul_no_files=8,
|
||||
verify_ssl=True,
|
||||
commit_prompt=None,
|
||||
):
|
||||
if not fnames:
|
||||
fnames = []
|
||||
|
@ -275,22 +270,20 @@ class Coder:
|
|||
|
||||
self.commands = Commands(self.io, self, voice_language, verify_ssl=verify_ssl)
|
||||
|
||||
if use_git:
|
||||
self.repo = repo
|
||||
if use_git and self.repo is None:
|
||||
try:
|
||||
self.repo = GitRepo(
|
||||
self.io,
|
||||
fnames,
|
||||
git_dname,
|
||||
aider_ignore_file,
|
||||
".",
|
||||
models=main_model.commit_message_models(),
|
||||
attribute_author=attribute_author,
|
||||
attribute_committer=attribute_committer,
|
||||
attribute_commit_message=attribute_commit_message,
|
||||
commit_prompt=commit_prompt,
|
||||
)
|
||||
self.root = self.repo.root
|
||||
except FileNotFoundError:
|
||||
self.repo = None
|
||||
pass
|
||||
|
||||
if self.repo:
|
||||
self.root = self.repo.root
|
||||
|
||||
for fname in fnames:
|
||||
fname = Path(fname)
|
||||
|
|
|
@ -459,14 +459,27 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
|||
if args.show_model_warnings:
|
||||
models.sanity_check_models(io, main_model)
|
||||
|
||||
repo = None
|
||||
if args.git:
|
||||
repo = GitRepo(
|
||||
io,
|
||||
fnames,
|
||||
git_dname or ".",
|
||||
args.aiderignore,
|
||||
models=main_model.commit_message_models(),
|
||||
attribute_author=args.attribute_author,
|
||||
attribute_committer=args.attribute_committer,
|
||||
attribute_commit_message=args.attribute_commit_message,
|
||||
commit_prompt=args.commit_prompt,
|
||||
)
|
||||
|
||||
try:
|
||||
coder = Coder.create(
|
||||
main_model=main_model,
|
||||
edit_format=args.edit_format,
|
||||
io=io,
|
||||
##
|
||||
repo=repo,
|
||||
fnames=fnames,
|
||||
git_dname=git_dname,
|
||||
pretty=args.pretty,
|
||||
show_diffs=args.show_diffs,
|
||||
auto_commits=args.auto_commits,
|
||||
|
@ -479,18 +492,13 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
|||
stream=args.stream,
|
||||
use_git=args.git,
|
||||
voice_language=args.voice_language,
|
||||
aider_ignore_file=args.aiderignore,
|
||||
max_chat_history_tokens=args.max_chat_history_tokens,
|
||||
restore_chat_history=args.restore_chat_history,
|
||||
auto_lint=args.auto_lint,
|
||||
auto_test=args.auto_test,
|
||||
lint_cmds=lint_cmds,
|
||||
test_cmd=args.test_cmd,
|
||||
attribute_author=args.attribute_author,
|
||||
attribute_committer=args.attribute_committer,
|
||||
attribute_commit_message=args.attribute_commit_message,
|
||||
verify_ssl=args.verify_ssl,
|
||||
commit_prompt=args.commit_prompt,
|
||||
)
|
||||
|
||||
except ValueError as err:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue