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.
This commit is contained in:
Paul Gauthier 2023-05-14 10:06:16 -07:00
parent 708653290f
commit a8acca9366
2 changed files with 9 additions and 1 deletions

View file

@ -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()

View file

@ -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")