Skip to content

Commit

Permalink
fix: .cache wasnt ignored (ApeWorX#2076)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored May 8, 2024
1 parent aa1f16d commit 22d3cb1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ape/cli/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def exclude_patterns(self) -> List[str]:
return self.config_manager.get_config("compile").exclude or []

def do_exclude(self, path: Union[Path, str]) -> bool:
name = path if isinstance(path, str) else path.name
name = path if isinstance(path, str) else str(path)
if name not in self.exclude_list:
self.exclude_list[name] = any(fnmatch(name, p) for p in self.exclude_patterns)

Expand Down
2 changes: 1 addition & 1 deletion src/ape/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
DEFAULT_TRANSACTION_TYPE = 0
DEFAULT_MAX_RETRIES_TX = 20
SOURCE_EXCLUDE_PATTERNS = (
".cache",
"**/.cache/**",
".DS_Store",
".gitkeep",
"**/.build/**/*.json",
Expand Down
8 changes: 8 additions & 0 deletions tests/functional/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,17 @@ def test_contract_file_paths_handles_exclude(project_with_contract, runner, cont
cfg = project_with_contract.config_manager.get_config("compile")
failmsg = "Setup failed - missing exclude config (set in ape-config.yaml)."
assert "*Excl*" in cfg.exclude, failmsg

# make a .cache file to show it is ignored.
cache_file = project_with_contract.contracts_folder / ".cache" / "thing.json"
cache_file.parent.mkdir(parents=True, exist_ok=True)
cache_file.write_text("FAILS IF LOADED")

result = runner.invoke(contracts_paths_cmd, "contracts")
assert "Exclude.json" not in result.output
assert "ExcludeNested.json" not in result.output
# Ensure .cache always ignored!
assert ".cache" not in result.output


@pytest.mark.parametrize("name", ("contracts/subdir", "subdir"))
Expand Down

0 comments on commit 22d3cb1

Please sign in to comment.