refactor: make is_important function portable for Windows compatibility

This commit is contained in:
Paul Gauthier (aider) 2024-08-30 14:37:56 -07:00
parent d67872a326
commit 7801aa8cfd

View file

@ -190,7 +190,7 @@ def is_important(file_path):
dir_name = os.path.dirname(file_path) dir_name = os.path.dirname(file_path)
# Check for GitHub Actions workflow files # Check for GitHub Actions workflow files
if dir_name.endswith(".github/workflows") and file_name.endswith(".yml"): if os.path.basename(dir_name) == "workflows" and os.path.basename(os.path.dirname(dir_name)) == ".github" and file_name.endswith(".yml"):
return True return True
# Check for IDE-specific directories # Check for IDE-specific directories
@ -198,7 +198,7 @@ def is_important(file_path):
return True return True
# Check for Kubernetes config files # Check for Kubernetes config files
if "kubernetes" in dir_name.split(os.path.sep) and file_name.endswith(".yaml"): if "kubernetes" in os.path.normpath(dir_name).split(os.sep) and file_name.endswith(".yaml"):
return True return True
# Check for migration directories # Check for migration directories
@ -206,7 +206,7 @@ def is_important(file_path):
return True return True
return file_name in IMPORTANT_FILES or any( return file_name in IMPORTANT_FILES or any(
file_path.endswith(f"/{name}") for name in IMPORTANT_FILES file_path.endswith(os.path.join('', name)) for name in IMPORTANT_FILES
) )