From a8acca9366d9f1c1a469613ebb9eb00797cec78c Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sun, 14 May 2023 10:06:16 -0700 Subject: [PATCH] aider: Added a `--dry-run` argument to the `main.py` file and passed it to the `Coder` class, setting the `self.dry_run` attribute in the `Coder` class. # Context: USER: add a --dry-run arg, no env, default false. pass it into Coder and set self.dry_run ASSISTANT: I will add a `--dry-run` argument to the `main.py` file and pass it to the `Coder` class. Then, I will set the `self.dry_run` attribute in the `Coder` class. Here are the changes: ```python aider/main.py <<<<<<< ORIGINAL parser.add_argument( "--show-diffs", action="store_true", help=f"Show diffs when committing changes (default: False, ${env_prefix}SHOW_DIFFS)", default=bool(int(os.environ.get(f"{env_prefix}SHOW_DIFFS", 0))), ) ======= parser.add_argument( "--dry-run", action="store_true", help="Perform a dry run without applying changes (default: False)", default=False, ) parser.add_argument( "--show-diffs", action="store_true", help=f"Show diffs when committing changes (default: False, ${env_prefix}SHOW_DIFFS)", default=bool(int(os.environ.get(f"{env_prefix}SHOW_DIFFS", 0))), ) >>>>>>> UPDATED ``` ```python aider/main.py <<<<<<< ORIGINAL io = InputOutput( args.pretty, args.yes, args.input_history_file, args.chat_history_file, input=input, output=output, ) coder = Coder( args.model, fnames, pretty, args.show_diffs, args.auto_commits, io, ) ======= io = InputOutput( args.pretty, args.yes, args.input_history_file, args.chat_history_file, input=input, output=output, ) coder = Coder( args.model, fnames, pretty, args.show_diffs, args.auto_commits, io, args.dry_run, ) >>>>>>> UPDATED ``` ```python aider/coder.py <<<<<<< ORIGINAL def __init__(self, main_model, fnames, pretty, show_diffs, auto_commits, io): self.abs_fnames = set() self.io = io self.auto_commits = auto_commits ======= def __init__(self, main_model, fnames, pretty, show_diffs, auto_commits, io, dry_run): self.abs_fnames = set() self.io = io self.auto_commits = auto_commits self.dry_run = dry_run >>>>>>> UPDATED ``` Please review the changes and let me know if you need any further modifications. --- aider/coder.py | 3 ++- aider/main.py | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/aider/coder.py b/aider/coder.py index 1f72cf288..8515ef962 100755 --- a/aider/coder.py +++ b/aider/coder.py @@ -28,12 +28,13 @@ class Coder: last_aider_commit_hash = None last_asked_for_commit_time = 0 - def __init__(self, main_model, fnames, pretty, show_diffs, auto_commits, io): + def __init__(self, main_model, fnames, pretty, show_diffs, auto_commits, io, dry_run): self.abs_fnames = set() self.io = io self.auto_commits = auto_commits + self.dry_run = dry_run if pretty: self.console = Console() diff --git a/aider/main.py b/aider/main.py index 8f5b5679e..0b91ad260 100644 --- a/aider/main.py +++ b/aider/main.py @@ -69,6 +69,12 @@ def main(args=None, input=None, output=None): help=f"Disable auto commit of changes (${env_prefix}AUTO_COMMITS)", default=bool(int(os.environ.get(f"{env_prefix}AUTO_COMMITS", 1))), ) + parser.add_argument( + "--dry-run", + action="store_true", + help="Perform a dry run without applying changes (default: False)", + default=False, + ) parser.add_argument( "--show-diffs", action="store_true", @@ -101,6 +107,7 @@ def main(args=None, input=None, output=None): args.show_diffs, args.auto_commits, io, + args.dry_run, ) if args.auto_commits: coder.commit(ask=True, prefix="wip: ", which="repo_files")