|
11 | 11 | from codeflash.code_utils import env_utils |
12 | 12 | from codeflash.code_utils.code_utils import exit_with_message |
13 | 13 | from codeflash.code_utils.config_parser import parse_config_file |
| 14 | +from codeflash.code_utils.git_utils import git_root_dir |
14 | 15 | from codeflash.lsp.helpers import is_LSP_enabled |
15 | 16 | from codeflash.version import __version__ as version |
16 | 17 |
|
@@ -222,18 +223,20 @@ def process_pyproject_config(args: Namespace) -> Namespace: |
222 | 223 | args.module_root = Path(args.module_root).resolve() |
223 | 224 | # If module-root is "." then all imports are relatives to it. |
224 | 225 | # in this case, the ".." becomes outside project scope, causing issues with un-importable paths |
225 | | - args.project_root = project_root_from_module_root(args.module_root, pyproject_file_path) |
| 226 | + args.project_root = project_root_from_module_root(args.module_root, pyproject_file_path, args.worktree) |
226 | 227 | args.tests_root = Path(args.tests_root).resolve() |
227 | 228 | if args.benchmarks_root: |
228 | 229 | args.benchmarks_root = Path(args.benchmarks_root).resolve() |
229 | | - args.test_project_root = project_root_from_module_root(args.tests_root, pyproject_file_path) |
| 230 | + args.test_project_root = project_root_from_module_root(args.tests_root, pyproject_file_path, args.worktree) |
230 | 231 | if is_LSP_enabled(): |
231 | 232 | args.all = None |
232 | 233 | return args |
233 | 234 | return handle_optimize_all_arg_parsing(args) |
234 | 235 |
|
235 | 236 |
|
236 | | -def project_root_from_module_root(module_root: Path, pyproject_file_path: Path) -> Path: |
| 237 | +def project_root_from_module_root(module_root: Path, pyproject_file_path: Path, in_worktree: bool = False) -> Path: # noqa: FBT001, FBT002 |
| 238 | + if in_worktree: |
| 239 | + return git_root_dir() |
237 | 240 | if pyproject_file_path.parent == module_root: |
238 | 241 | return module_root |
239 | 242 | return module_root.parent.resolve() |
|
0 commit comments