Skip to content

Commit 0412be7

Browse files
mashraf-222claude
andcommitted
fix: set language singleton early so git diff auto-detection works for all languages
The language singleton was only set after function discovery, but get_git_diff() needs it during discovery to filter by file extension. Now set it in process_pyproject_config() based on the config file type. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 506eb44 commit 0412be7

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

codeflash/cli_cmds/cli.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from codeflash.code_utils import env_utils
1111
from codeflash.code_utils.code_utils import exit_with_message, normalize_ignore_paths
1212
from codeflash.code_utils.config_parser import parse_config_file
13+
from codeflash.languages import set_current_language
1314
from codeflash.languages.test_framework import set_current_test_framework
1415
from codeflash.lsp.helpers import is_LSP_enabled
1516
from codeflash.version import __version__ as version
@@ -108,10 +109,18 @@ def process_pyproject_config(args: Namespace) -> Namespace:
108109
assert args.module_root is not None, "--module-root must be specified"
109110
assert Path(args.module_root).is_dir(), f"--module-root {args.module_root} must be a valid directory"
110111

111-
# For JS/TS projects, tests_root is optional (Jest auto-discovers tests)
112-
# Default to module_root if not specified
113-
is_js_ts_project = pyproject_config.get("language") in ("javascript", "typescript")
114-
is_java_project = pyproject_config.get("language") == "java"
112+
# Determine project language from explicit config or config file name.
113+
# Java projects use codeflash.toml but don't always have an explicit language field.
114+
config_language = pyproject_config.get("language")
115+
if config_language is None and pyproject_file_path.name == "codeflash.toml":
116+
config_language = "java"
117+
is_js_ts_project = config_language in ("javascript", "typescript")
118+
is_java_project = config_language == "java"
119+
120+
# Set the language singleton early so downstream code (e.g. get_git_diff)
121+
# can use current_language_support() before function discovery.
122+
if config_language:
123+
set_current_language(config_language)
115124

116125
# Set the test framework singleton for JS/TS projects
117126
if is_js_ts_project and pyproject_config.get("test_framework"):

0 commit comments

Comments
 (0)