From ad7575e85ebf6332d324ca5997db18ea81065df4 Mon Sep 17 00:00:00 2001 From: Bernhard Guillon Date: Mon, 6 Jul 2026 21:36:29 +0200 Subject: Implement nested .gitignore support with GitignoreStack - Replaced go-gitignore with custom GitignoreStack that tracks multiple .gitignore files hierarchically - Patterns are processed in root-to-leaf order, last match wins - Negation patterns in child dirs override parent ignores - Patterns only apply within their directory scope (no leaking) - Added 6 new tests for nested .gitignore: - Scoped: patterns only affect own directory - Dir-scoped: different dirs can ignore different things - Negation override: child !pattern un-ignores parent's *.pattern - Deep nesting: 3+ levels of .gitignore - Parent scope doesn't leak to siblings - All 35 tests passing --- main.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 436c7b7..24135f5 100644 --- a/main.go +++ b/main.go @@ -25,12 +25,9 @@ func main() { log.Printf("host: %s, data: %s, dry-run: %v", *hostDir, *dataDir, *dryRun) } - rules, err := loadGitignore(*hostDir) - if err != nil { - log.Fatalf("failed to load .gitignore: %v", err) - } + stack := NewGitignoreStack(*hostDir) - manifest, err := initialSync(*hostDir, *dataDir, rules, *dryRun) + manifest, err := initialSync(*hostDir, *dataDir, stack, *dryRun) if err != nil { log.Fatalf("initial sync failed: %v", err) } @@ -38,7 +35,7 @@ func main() { ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) defer cancel() - if err := watch(ctx, *hostDir, *dataDir, manifest, rules, *dryRun, *verbose); err != nil { + if err := watch(ctx, *hostDir, *dataDir, manifest, stack, *dryRun, *verbose); err != nil { log.Fatalf("watcher failed: %v", err) } } -- cgit v1.2.3