From f048ef42ad201922639c81b83257b20ca5885b04 Mon Sep 17 00:00:00 2001 From: ccwq Date: Fri, 13 Jun 2025 11:29:18 +0800 Subject: [PATCH] fix: If an inclusion pattern exists, apply it only to files. # Directories should be traversed as long as they are not excluded, # because they may contain files that need to be included. --- src/gitingest/ingestion.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/gitingest/ingestion.py b/src/gitingest/ingestion.py index d3005250..f7618723 100644 --- a/src/gitingest/ingestion.py +++ b/src/gitingest/ingestion.py @@ -179,9 +179,13 @@ def _process_node( if query.ignore_patterns and _should_exclude(sub_path, query.local_path, query.ignore_patterns): continue - - if query.include_patterns and not _should_include(sub_path, query.local_path, query.include_patterns): - continue + + # If an inclusion pattern exists, apply it only to files. + # Directories should be traversed as long as they are not excluded, + # because they may contain files that need to be included. + if query.include_patterns and sub_path.is_file(): + if not _should_include(sub_path, query.local_path, query.include_patterns): + continue if sub_path.is_symlink(): _process_symlink(path=sub_path, parent_node=node, stats=stats, local_path=query.local_path)