Skip to content

Commit 2e4114f

Browse files
dguidoclaude
andcommitted
fix: make --foundry-no-force skip forge clean automatically
- Move shutil import to top of file - Update clean() to skip when foundry_no_force is set - Update help text to clarify the flag's behavior Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent c5b2c97 commit 2e4114f

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

crytic_compile/cryticparser/cryticparser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ def _init_foundry(parser: ArgumentParser) -> None:
476476

477477
group_foundry.add_argument(
478478
"--foundry-no-force",
479-
help="Do not use --force flag for incremental compilation",
479+
help="Enable incremental compilation (skips forge clean and --force flag)",
480480
action="store_true",
481481
dest="foundry_no_force",
482482
default=DEFAULTS_FLAG_IN_CONFIG["foundry_no_force"],

crytic_compile/platform/foundry.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import json
66
import logging
77
import re
8+
import shutil
89
import subprocess
910
from pathlib import Path
1011
from typing import TYPE_CHECKING, TypeVar
@@ -118,8 +119,6 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None:
118119
out_dir = foundry_config.out_path if foundry_config else "out"
119120
build_info_dir = Path(self._project_root, out_dir, "build-info")
120121
if build_info_dir.exists():
121-
import shutil
122-
123122
shutil.rmtree(build_info_dir)
124123
LOGGER.info("Cleaned %s for fresh build-info generation", build_info_dir)
125124

@@ -157,14 +156,16 @@ def clean(self, **kwargs: str) -> None:
157156
"""Clean compilation artifacts
158157
159158
Args:
160-
**kwargs: optional arguments.
159+
**kwargs: optional arguments. Used: "foundry_ignore_compile", "ignore_compile",
160+
"foundry_no_force"
161161
"""
162-
163162
ignore_compile = kwargs.get("foundry_ignore_compile", False) or kwargs.get(
164163
"ignore_compile", False
165164
)
165+
no_force = kwargs.get("foundry_no_force", False)
166166

167-
if ignore_compile:
167+
# Skip cleaning when using incremental compilation mode
168+
if ignore_compile or no_force:
168169
return
169170

170171
run(["forge", "clean"], cwd=self._project_root)

0 commit comments

Comments
 (0)