add_lang_ext_support_to_diff

This commit is contained in:
Sarthak Agarwal 2026-03-18 05:10:20 +05:30
parent 1e92f3d2ed
commit 5ecbd46c1c

View file

@ -13,6 +13,7 @@ from rich.prompt import Confirm
from unidiff import PatchSet
from codeflash.cli_cmds.console import logger
from codeflash.languages.registry import get_supported_extensions
if TYPE_CHECKING:
from git import Repo
@ -35,11 +36,12 @@ def get_git_diff(
uni_diff_text = repository.git.diff(
commit.hexsha + "^1", commit.hexsha, ignore_blank_lines=True, ignore_space_at_eol=True
)
supported_extensions = set(get_supported_extensions())
patch_set = PatchSet(StringIO(uni_diff_text))
change_list: dict[str, list[int]] = {} # list of changes
for patched_file in patch_set:
file_path: Path = Path(patched_file.path)
if file_path.suffix != ".py":
if file_path.suffix not in supported_extensions:
continue
file_path = Path(repository.working_dir) / file_path
logger.debug(f"file name: {file_path}")