Skip to content

Commit d9d08c6

Browse files
select the git root as project root
1 parent b216d93 commit d9d08c6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

codeflash/cli_cmds/cli.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from codeflash.code_utils import env_utils
1212
from codeflash.code_utils.code_utils import exit_with_message
1313
from codeflash.code_utils.config_parser import parse_config_file
14+
from codeflash.code_utils.git_utils import git_root_dir
1415
from codeflash.lsp.helpers import is_LSP_enabled
1516
from codeflash.version import __version__ as version
1617

@@ -222,18 +223,20 @@ def process_pyproject_config(args: Namespace) -> Namespace:
222223
args.module_root = Path(args.module_root).resolve()
223224
# If module-root is "." then all imports are relatives to it.
224225
# 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)
226227
args.tests_root = Path(args.tests_root).resolve()
227228
if args.benchmarks_root:
228229
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)
230231
if is_LSP_enabled():
231232
args.all = None
232233
return args
233234
return handle_optimize_all_arg_parsing(args)
234235

235236

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()
237240
if pyproject_file_path.parent == module_root:
238241
return module_root
239242
return module_root.parent.resolve()

0 commit comments

Comments
 (0)