diff --git a/internal/skillignore/stats.go b/internal/skillignore/stats.go new file mode 100644 index 000000000..755b7d0d6 --- /dev/null +++ b/internal/skillignore/stats.go @@ -0,0 +1,24 @@ +package skillignore + +// IgnoreStats holds information about .skillignore files and their effect. +type IgnoreStats struct { + RootFile string // root .skillignore path ("" = not exist) + RepoFiles []string // repo-level .skillignore paths + Patterns []string // all active patterns (no blanks/comments) + IgnoredSkills []string // excluded skill relPaths +} + +// Active reports whether any .skillignore file is in effect. +func (s *IgnoreStats) Active() bool { + return s.RootFile != "" || len(s.RepoFiles) > 0 +} + +// PatternCount returns the total number of active patterns. +func (s *IgnoreStats) PatternCount() int { + return len(s.Patterns) +} + +// IgnoredCount returns the number of ignored skills. +func (s *IgnoreStats) IgnoredCount() int { + return len(s.IgnoredSkills) +} diff --git a/internal/skillignore/stats_test.go b/internal/skillignore/stats_test.go new file mode 100644 index 000000000..26dbe0605 --- /dev/null +++ b/internal/skillignore/stats_test.go @@ -0,0 +1,43 @@ +package skillignore + +import "testing" + +func TestIgnoreStats_Active(t *testing.T) { + tests := []struct { + name string + s IgnoreStats + want bool + }{ + {"root file", IgnoreStats{RootFile: "/path/.skillignore"}, true}, + {"repo file", IgnoreStats{RepoFiles: []string{"_repo/.skillignore"}}, true}, + {"both", IgnoreStats{RootFile: "/path", RepoFiles: []string{"_r"}}, true}, + {"neither", IgnoreStats{}, false}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := tt.s.Active(); got != tt.want { + t.Errorf("Active() = %v, want %v", got, tt.want) + } + }) + } +} + +func TestIgnoreStats_Counts(t *testing.T) { + s := IgnoreStats{ + Patterns: []string{"test-*", "vendor/", "!important"}, + IgnoredSkills: []string{"test-a", "test-b"}, + } + if s.PatternCount() != 3 { + t.Errorf("PatternCount() = %d, want 3", s.PatternCount()) + } + if s.IgnoredCount() != 2 { + t.Errorf("IgnoredCount() = %d, want 2", s.IgnoredCount()) + } +} + +func TestIgnoreStats_ZeroCounts(t *testing.T) { + s := IgnoreStats{} + if s.PatternCount() != 0 || s.IgnoredCount() != 0 { + t.Error("empty stats should have zero counts") + } +}