mirror of
https://github.com/simonw/files-to-prompt.git
synced 2025-10-23 00:02:47 +03:00
--ignore patterns now include directory names unless --ignore-files-only (#30)
* Option to --include-directories otherwise ignored by an ignore pattern * --include-directories renamed to --ignore-files-only Refs https://github.com/simonw/files-to-prompt/pull/30/#issuecomment-2658177542 --------- Co-authored-by: Simon Willison <swillison@gmail.com>
This commit is contained in:
@@ -88,7 +88,7 @@ def test_multiple_paths(tmpdir):
|
||||
def test_ignore_patterns(tmpdir):
|
||||
runner = CliRunner()
|
||||
with tmpdir.as_cwd():
|
||||
os.makedirs("test_dir")
|
||||
os.makedirs("test_dir", exist_ok=True)
|
||||
with open("test_dir/file_to_ignore.txt", "w") as f:
|
||||
f.write("This file should be ignored due to ignore patterns")
|
||||
with open("test_dir/file_to_include.txt", "w") as f:
|
||||
@@ -100,12 +100,27 @@ def test_ignore_patterns(tmpdir):
|
||||
assert "This file should be ignored due to ignore patterns" not in result.output
|
||||
assert "test_dir/file_to_include.txt" not in result.output
|
||||
|
||||
result = runner.invoke(cli, ["test_dir", "--ignore", "file_to_ignore.*"])
|
||||
os.makedirs("test_dir/test_subdir", exist_ok=True)
|
||||
with open("test_dir/test_subdir/any_file.txt", "w") as f:
|
||||
f.write("This entire subdirectory should be ignored due to ignore patterns")
|
||||
result = runner.invoke(cli, ["test_dir", "--ignore", "*subdir*"])
|
||||
assert result.exit_code == 0
|
||||
assert "test_dir/file_to_ignore.txt" not in result.output
|
||||
assert "This file should be ignored due to ignore patterns" not in result.output
|
||||
assert "test_dir/test_subdir/any_file.txt" not in result.output
|
||||
assert (
|
||||
"This entire subdirectory should be ignored due to ignore patterns"
|
||||
not in result.output
|
||||
)
|
||||
assert "test_dir/file_to_include.txt" in result.output
|
||||
assert "This file should be included" in result.output
|
||||
assert "This file should be included" in result.output
|
||||
|
||||
result = runner.invoke(
|
||||
cli, ["test_dir", "--ignore", "*subdir*", "--ignore-files-only"]
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert "test_dir/test_subdir/any_file.txt" in result.output
|
||||
|
||||
result = runner.invoke(cli, ["test_dir", "--ignore", ""])
|
||||
|
||||
|
||||
def test_specific_extensions(tmpdir):
|
||||
|
||||
Reference in New Issue
Block a user