From 496525c6c2dde39cbc246ecef649f5edcbb59535 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Fri, 30 Aug 2024 14:35:38 -0700 Subject: [PATCH] refactor: move is_important function to top level --- aider/special.py | 50 ++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/aider/special.py b/aider/special.py index 80001bc4e..6b1c4b1f8 100644 --- a/aider/special.py +++ b/aider/special.py @@ -158,6 +158,31 @@ IMPORTANT_FILES = [ ] +def is_important(file_path): + file_name = os.path.basename(file_path) + dir_name = os.path.dirname(file_path) + + # Check for GitHub Actions workflow files + if dir_name.endswith(".github/workflows") and file_name.endswith(".yml"): + return True + + # Check for IDE-specific directories + if file_name in [".idea", ".vscode"]: + return True + + # Check for Kubernetes config files + if "kubernetes" in dir_name.split(os.path.sep) and file_name.endswith(".yaml"): + return True + + # Check for migration directories + if file_name == "migrations" and os.path.isdir(file_path): + return True + + return file_name in IMPORTANT_FILES or any( + file_path.endswith(f"/{name}") for name in IMPORTANT_FILES + ) + + def filter_important_files(file_paths): """ Filter a list of file paths to return only those that are commonly important in codebases. @@ -165,29 +190,4 @@ def filter_important_files(file_paths): :param file_paths: List of file paths to check :return: List of file paths that match important file patterns """ - - def is_important(file_path): - file_name = os.path.basename(file_path) - dir_name = os.path.dirname(file_path) - - # Check for GitHub Actions workflow files - if dir_name.endswith(".github/workflows") and file_name.endswith(".yml"): - return True - - # Check for IDE-specific directories - if file_name in [".idea", ".vscode"]: - return True - - # Check for Kubernetes config files - if "kubernetes" in dir_name.split(os.path.sep) and file_name.endswith(".yaml"): - return True - - # Check for migration directories - if file_name == "migrations" and os.path.isdir(file_path): - return True - - return file_name in IMPORTANT_FILES or any( - file_path.endswith(f"/{name}") for name in IMPORTANT_FILES - ) - return list(filter(is_important, file_paths))