From cf1801cb3c2a548b738295c06345ed13810ab05e Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sun, 25 Aug 2024 12:19:01 -0700 Subject: [PATCH] proper error message if /add non-git dir #1175 --- aider/commands.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/aider/commands.py b/aider/commands.py index 5d79b2717..d332d946e 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -582,15 +582,23 @@ class Commands: all_matched_files.update(matched_files) continue + if "*" in str(fname) or "?" in str(fname): + self.io.tool_error( + f"No match, and cannot create file with wildcard characters: {fname}" + ) + continue + + if fname.exists() and fname.is_dir() and self.coder.repo: + self.io.tool_error(f"Directory {fname} is not in git.") + self.io.tool_error(f"You can add to git with: /git add {fname}") + continue + if self.io.confirm_ask(f"No files matched '{word}'. Do you want to create {fname}?"): - if "*" in str(fname) or "?" in str(fname): - self.io.tool_error(f"Cannot create file with wildcard characters: {fname}") - else: - try: - fname.touch() - all_matched_files.add(str(fname)) - except OSError as e: - self.io.tool_error(f"Error creating file {fname}: {e}") + try: + fname.touch() + all_matched_files.add(str(fname)) + except OSError as e: + self.io.tool_error(f"Error creating file {fname}: {e}") for matched_file in all_matched_files: abs_file_path = self.coder.abs_root_path(matched_file)