mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 22:34:59 +00:00
Merge branch 'main' into pattern
This commit is contained in:
commit
52a7c4b786
1 changed files with 26 additions and 1 deletions
|
@ -29,6 +29,7 @@ class Coder:
|
||||||
abs_fnames = None
|
abs_fnames = None
|
||||||
repo = None
|
repo = None
|
||||||
last_aider_commit_hash = None
|
last_aider_commit_hash = None
|
||||||
|
last_asked_for_commit_time = 0
|
||||||
|
|
||||||
def __init__(self, main_model, fnames, pretty, history_file, show_diffs, auto_commits, yes):
|
def __init__(self, main_model, fnames, pretty, history_file, show_diffs, auto_commits, yes):
|
||||||
self.abs_fnames = set()
|
self.abs_fnames = set()
|
||||||
|
@ -187,6 +188,17 @@ class Coder:
|
||||||
except EOFError:
|
except EOFError:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def should_commit(self, is_commit_command):
|
||||||
|
if not self.repo:
|
||||||
|
return
|
||||||
|
if not self.repo.is_dirty():
|
||||||
|
return
|
||||||
|
if is_commit_command:
|
||||||
|
return
|
||||||
|
if self.last_asked_for_commit_time >= self.get_last_modified():
|
||||||
|
return
|
||||||
|
return True
|
||||||
|
|
||||||
def run_loop(self):
|
def run_loop(self):
|
||||||
if self.pretty:
|
if self.pretty:
|
||||||
self.console.rule()
|
self.console.rule()
|
||||||
|
@ -199,7 +211,7 @@ class Coder:
|
||||||
|
|
||||||
is_commit_command = inp and inp.startswith("/commit")
|
is_commit_command = inp and inp.startswith("/commit")
|
||||||
|
|
||||||
if self.repo and self.repo.is_dirty() and not is_commit_command:
|
if self.should_commit(is_commit_command):
|
||||||
self.commit(ask=True, which="repo_files")
|
self.commit(ask=True, which="repo_files")
|
||||||
|
|
||||||
# files changed, move cur messages back behind the files messages
|
# files changed, move cur messages back behind the files messages
|
||||||
|
@ -508,6 +520,8 @@ class Coder:
|
||||||
"[bright_black]Commit before the chat proceeds? \[y/n/commit message]", # noqa: W605 E501
|
"[bright_black]Commit before the chat proceeds? \[y/n/commit message]", # noqa: W605 E501
|
||||||
default="y",
|
default="y",
|
||||||
).strip()
|
).strip()
|
||||||
|
self.last_asked_for_commit_time = self.get_last_modified()
|
||||||
|
|
||||||
self.console.print()
|
self.console.print()
|
||||||
|
|
||||||
if res.lower() in ["n", "no"]:
|
if res.lower() in ["n", "no"]:
|
||||||
|
@ -537,6 +551,17 @@ class Coder:
|
||||||
|
|
||||||
return sorted(set(files))
|
return sorted(set(files))
|
||||||
|
|
||||||
|
def get_all_abs_files(self):
|
||||||
|
files = self.get_all_relative_files()
|
||||||
|
files = [os.path.abspath(os.path.join(self.root, path)) for path in files]
|
||||||
|
return files
|
||||||
|
|
||||||
|
def get_last_modified(self):
|
||||||
|
files = self.get_all_abs_files()
|
||||||
|
if not files:
|
||||||
|
return 0
|
||||||
|
return max(Path(path).stat().st_mtime for path in files)
|
||||||
|
|
||||||
def confirm_ask(self, question, default=None):
|
def confirm_ask(self, question, default=None):
|
||||||
if self.yes:
|
if self.yes:
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue