Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion codeflash/code_utils/git_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_git_diff(
only_this_commit + "^1", only_this_commit, ignore_blank_lines=True, ignore_space_at_eol=True
)
elif uncommitted_changes:
uni_diff_text = repository.git.diff(None, "HEAD", ignore_blank_lines=True, ignore_space_at_eol=True)
uni_diff_text = repository.git.diff("HEAD", ignore_blank_lines=True, ignore_space_at_eol=True)
else:
uni_diff_text = repository.git.diff(
commit.hexsha + "^1", commit.hexsha, ignore_blank_lines=True, ignore_space_at_eol=True
Expand Down
15 changes: 9 additions & 6 deletions codeflash/discovery/functions_to_optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,30 +666,33 @@ def filter_functions(
submodule_ignored_paths_count: int = 0
blocklist_funcs_removed_count: int = 0
previous_checkpoint_functions_removed_count: int = 0
tests_root_str = str(tests_root)
module_root_str = str(module_root)
# Normalize paths for case-insensitive comparison on Windows
tests_root_str = os.path.normcase(str(tests_root))
module_root_str = os.path.normcase(str(module_root))

# We desperately need Python 3.10+ only support to make this code readable with structural pattern matching
for file_path_path, functions in modified_functions.items():
_functions = functions
file_path = str(file_path_path)
if file_path.startswith(tests_root_str + os.sep):
file_path_normalized = os.path.normcase(file_path)
if file_path_normalized.startswith(tests_root_str + os.sep):
test_functions_removed_count += len(_functions)
continue
if file_path in ignore_paths or any(
file_path.startswith(str(ignore_path) + os.sep) for ignore_path in ignore_paths
file_path_normalized.startswith(os.path.normcase(str(ignore_path)) + os.sep) for ignore_path in ignore_paths
):
ignore_paths_removed_count += 1
continue
if file_path in submodule_paths or any(
file_path.startswith(str(submodule_path) + os.sep) for submodule_path in submodule_paths
file_path_normalized.startswith(os.path.normcase(str(submodule_path)) + os.sep)
for submodule_path in submodule_paths
):
submodule_ignored_paths_count += 1
continue
if path_belongs_to_site_packages(Path(file_path)):
site_packages_removed_count += len(_functions)
continue
if not file_path.startswith(module_root_str + os.sep):
if not file_path_normalized.startswith(module_root_str + os.sep):
non_modules_removed_count += len(_functions)
continue
try:
Expand Down
Loading