proper error message if /add non-git dir #1175

This commit is contained in:
Paul Gauthier 2024-08-25 12:19:01 -07:00
parent 65d224fba4
commit cf1801cb3c

View file

@ -582,10 +582,18 @@ class Commands:
all_matched_files.update(matched_files)
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:
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}?"):
try:
fname.touch()
all_matched_files.add(str(fname))