From 660a60924e78b08ae7a62717eca0cc94376c7cff Mon Sep 17 00:00:00 2001 From: mrT23 Date: Tue, 20 Aug 2024 11:23:37 +0300 Subject: [PATCH] Add filename parameter and skip logic to extend_patch function in git_patch_processing.py --- pr_agent/algo/git_patch_processing.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pr_agent/algo/git_patch_processing.py b/pr_agent/algo/git_patch_processing.py index de216f6a..30bdd8c9 100644 --- a/pr_agent/algo/git_patch_processing.py +++ b/pr_agent/algo/git_patch_processing.py @@ -7,7 +7,8 @@ from pr_agent.algo.types import EDIT_TYPE, FilePatchInfo from pr_agent.log import get_logger -def extend_patch(original_file_str, patch_str, patch_extra_lines_before=0, patch_extra_lines_after=0) -> str: +def extend_patch(original_file_str, patch_str, patch_extra_lines_before=0, + patch_extra_lines_after=0, filename: str = "") -> str: if not patch_str or (patch_extra_lines_before == 0 and patch_extra_lines_after == 0) or not original_file_str: return patch_str @@ -17,6 +18,13 @@ def extend_patch(original_file_str, patch_str, patch_extra_lines_before=0, patch except UnicodeDecodeError: return "" + # skip patches + skip_types = get_settings().config.skip_types #[".md",".txt"] + if skip_types: + if any([filename.endswith(skip_type) for skip_type in skip_types]): + return patch_str + + # dynamic context settings allow_dynamic_context = get_settings().config.allow_dynamic_context max_extra_lines_before_dynamic_context = get_settings().config.max_extra_lines_before_dynamic_context patch_extra_lines_before_dynamic = patch_extra_lines_before