Skip to content

Commit 4157d47

Browse files
authored
Merge pull request #1027 from codeflash-ai/fix/git-diff-windows-path-case
fix: resolve Windows path case sensitivity in optimize changed code
2 parents e680f74 + aeee0ae commit 4157d47

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

codeflash/code_utils/git_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def get_git_diff(
3434
only_this_commit + "^1", only_this_commit, ignore_blank_lines=True, ignore_space_at_eol=True
3535
)
3636
elif uncommitted_changes:
37-
uni_diff_text = repository.git.diff(None, "HEAD", ignore_blank_lines=True, ignore_space_at_eol=True)
37+
uni_diff_text = repository.git.diff("HEAD", ignore_blank_lines=True, ignore_space_at_eol=True)
3838
else:
3939
uni_diff_text = repository.git.diff(
4040
commit.hexsha + "^1", commit.hexsha, ignore_blank_lines=True, ignore_space_at_eol=True

codeflash/discovery/functions_to_optimize.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -666,30 +666,33 @@ def filter_functions(
666666
submodule_ignored_paths_count: int = 0
667667
blocklist_funcs_removed_count: int = 0
668668
previous_checkpoint_functions_removed_count: int = 0
669-
tests_root_str = str(tests_root)
670-
module_root_str = str(module_root)
669+
# Normalize paths for case-insensitive comparison on Windows
670+
tests_root_str = os.path.normcase(str(tests_root))
671+
module_root_str = os.path.normcase(str(module_root))
671672

672673
# We desperately need Python 3.10+ only support to make this code readable with structural pattern matching
673674
for file_path_path, functions in modified_functions.items():
674675
_functions = functions
675676
file_path = str(file_path_path)
676-
if file_path.startswith(tests_root_str + os.sep):
677+
file_path_normalized = os.path.normcase(file_path)
678+
if file_path_normalized.startswith(tests_root_str + os.sep):
677679
test_functions_removed_count += len(_functions)
678680
continue
679681
if file_path in ignore_paths or any(
680-
file_path.startswith(str(ignore_path) + os.sep) for ignore_path in ignore_paths
682+
file_path_normalized.startswith(os.path.normcase(str(ignore_path)) + os.sep) for ignore_path in ignore_paths
681683
):
682684
ignore_paths_removed_count += 1
683685
continue
684686
if file_path in submodule_paths or any(
685-
file_path.startswith(str(submodule_path) + os.sep) for submodule_path in submodule_paths
687+
file_path_normalized.startswith(os.path.normcase(str(submodule_path)) + os.sep)
688+
for submodule_path in submodule_paths
686689
):
687690
submodule_ignored_paths_count += 1
688691
continue
689692
if path_belongs_to_site_packages(Path(file_path)):
690693
site_packages_removed_count += len(_functions)
691694
continue
692-
if not file_path.startswith(module_root_str + os.sep):
695+
if not file_path_normalized.startswith(module_root_str + os.sep):
693696
non_modules_removed_count += len(_functions)
694697
continue
695698
try:

0 commit comments

Comments
 (0)