mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 00:35:00 +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,
|
self,
|
||||||
main_model,
|
main_model,
|
||||||
io,
|
io,
|
||||||
|
repo=None,
|
||||||
fnames=None,
|
fnames=None,
|
||||||
git_dname=None,
|
|
||||||
pretty=True,
|
pretty=True,
|
||||||
show_diffs=False,
|
show_diffs=False,
|
||||||
auto_commits=True,
|
auto_commits=True,
|
||||||
|
@ -205,7 +205,6 @@ class Coder:
|
||||||
stream=True,
|
stream=True,
|
||||||
use_git=True,
|
use_git=True,
|
||||||
voice_language=None,
|
voice_language=None,
|
||||||
aider_ignore_file=None,
|
|
||||||
cur_messages=None,
|
cur_messages=None,
|
||||||
done_messages=None,
|
done_messages=None,
|
||||||
max_chat_history_tokens=None,
|
max_chat_history_tokens=None,
|
||||||
|
@ -214,13 +213,9 @@ class Coder:
|
||||||
auto_test=False,
|
auto_test=False,
|
||||||
lint_cmds=None,
|
lint_cmds=None,
|
||||||
test_cmd=None,
|
test_cmd=None,
|
||||||
attribute_author=True,
|
|
||||||
attribute_committer=True,
|
|
||||||
attribute_commit_message=False,
|
|
||||||
aider_commit_hashes=None,
|
aider_commit_hashes=None,
|
||||||
map_mul_no_files=8,
|
map_mul_no_files=8,
|
||||||
verify_ssl=True,
|
verify_ssl=True,
|
||||||
commit_prompt=None,
|
|
||||||
):
|
):
|
||||||
if not fnames:
|
if not fnames:
|
||||||
fnames = []
|
fnames = []
|
||||||
|
@ -275,22 +270,20 @@ class Coder:
|
||||||
|
|
||||||
self.commands = Commands(self.io, self, voice_language, verify_ssl=verify_ssl)
|
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:
|
try:
|
||||||
self.repo = GitRepo(
|
self.repo = GitRepo(
|
||||||
self.io,
|
self.io,
|
||||||
fnames,
|
fnames,
|
||||||
git_dname,
|
".",
|
||||||
aider_ignore_file,
|
|
||||||
models=main_model.commit_message_models(),
|
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:
|
except FileNotFoundError:
|
||||||
self.repo = None
|
pass
|
||||||
|
|
||||||
|
if self.repo:
|
||||||
|
self.root = self.repo.root
|
||||||
|
|
||||||
for fname in fnames:
|
for fname in fnames:
|
||||||
fname = Path(fname)
|
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:
|
if args.show_model_warnings:
|
||||||
models.sanity_check_models(io, main_model)
|
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:
|
try:
|
||||||
coder = Coder.create(
|
coder = Coder.create(
|
||||||
main_model=main_model,
|
main_model=main_model,
|
||||||
edit_format=args.edit_format,
|
edit_format=args.edit_format,
|
||||||
io=io,
|
io=io,
|
||||||
##
|
repo=repo,
|
||||||
fnames=fnames,
|
fnames=fnames,
|
||||||
git_dname=git_dname,
|
|
||||||
pretty=args.pretty,
|
pretty=args.pretty,
|
||||||
show_diffs=args.show_diffs,
|
show_diffs=args.show_diffs,
|
||||||
auto_commits=args.auto_commits,
|
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,
|
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,
|
|
||||||
max_chat_history_tokens=args.max_chat_history_tokens,
|
max_chat_history_tokens=args.max_chat_history_tokens,
|
||||||
restore_chat_history=args.restore_chat_history,
|
restore_chat_history=args.restore_chat_history,
|
||||||
auto_lint=args.auto_lint,
|
auto_lint=args.auto_lint,
|
||||||
auto_test=args.auto_test,
|
auto_test=args.auto_test,
|
||||||
lint_cmds=lint_cmds,
|
lint_cmds=lint_cmds,
|
||||||
test_cmd=args.test_cmd,
|
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,
|
verify_ssl=args.verify_ssl,
|
||||||
commit_prompt=args.commit_prompt,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
except ValueError as err:
|
except ValueError as err:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue