From 7a8dc5dd1643e54bb0b67ffa0d5ec5665b8b5080 Mon Sep 17 00:00:00 2001 From: Zsolt Ero Date: Sat, 4 Oct 2025 00:18:37 +0200 Subject: [PATCH] fix gitignore bug --- files_to_prompt/cli.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/files_to_prompt/cli.py b/files_to_prompt/cli.py index 7eee04f..f37ddf3 100644 --- a/files_to_prompt/cli.py +++ b/files_to_prompt/cli.py @@ -125,16 +125,20 @@ def process_path( files = [f for f in files if not f.startswith(".")] if not ignore_gitignore: - gitignore_rules.extend(read_gitignore(root)) + # Build the gitignore rules for this directory + # by combining parent rules with this directory's rules + current_rules = gitignore_rules.copy() + current_rules.extend(read_gitignore(root)) + dirs[:] = [ d for d in dirs - if not should_ignore(os.path.join(root, d), gitignore_rules) + if not should_ignore(os.path.join(root, d), current_rules) ] files = [ f for f in files - if not should_ignore(os.path.join(root, f), gitignore_rules) + if not should_ignore(os.path.join(root, f), current_rules) ] if ignore_patterns: