From 428d6f73fc41d838b2b24ea655b3eed9909dcb46 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 11 May 2023 17:45:06 -0700 Subject: [PATCH] Refactored confirm_ask method to accept None as default and used it in all confirmations. --- aider/coder.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/aider/coder.py b/aider/coder.py index 277e2104d..c3b8801ed 100755 --- a/aider/coder.py +++ b/aider/coder.py @@ -30,7 +30,7 @@ openai.api_key = os.getenv("OPENAI_API_KEY") class Coder: abs_fnames = set() - def confirm_ask(self, question, default="y"): + def confirm_ask(self, question, default=None): return Confirm.ask(question, console=self.console, default=default) repo = None @@ -120,7 +120,7 @@ class Coder: self.console.print(f"[bright_black]Files not tracked in {repo.git_dir}:") for fn in new_files: self.console.print(f"[bright_black] {fn}") - if self.confirm_ask("[bright_black]Add them?"): + if self.confirm_ask("[bright_black]Add them?", default="y"): for relative_fname in new_files: repo.git.add(relative_fname) self.console.print(f"[bright_black]Added {relative_fname} to the git repo") @@ -308,7 +308,7 @@ class Coder: for rel_fname in mentioned_rel_fnames: self.console.print(f"[bright_black]{rel_fname}") - if self.confirm_ask("[bright_black]Add {path} to git?"): + if self.confirm_ask("[bright_black]Add {path} to git?", default="y"): if not ok: return @@ -404,16 +404,15 @@ class Coder: question = f"[bright_black]Allow creation of new file {path}?" # noqa: E501 else: question = f"[bright_black]Allow edits to {path} which was not previously provided?" # noqa: E501 - if not Confirm.ask(question, console=self.console, default="y"): + if not self.confirm_ask(question, default="y"): self.console.print(f"[red]Skipping edit to {path}") continue Path(full_path).touch() self.abs_fnames.add(full_path) - if self.repo and Confirm.ask( + if self.repo and self.confirm_ask( f"[bright_black]Add {path} to git?", - console=self.console, default="y", ): self.repo.git.add(full_path)