feat: add .shushignore support for flexible file exclusion

- Add .shushignore file support (project root + global ~/.config/.shushignore)
- Support gitignore-style patterns: wildcards (*), directories (dir/), negation (\!pattern)
- Universal integration: works with all processing modes (files, directories, git-aware)
- Smart messaging: explicit ignore messages for direct file access
- Silent skipping: directory traversal automatically skips ignored files
- Enhanced verbose output: distinguishes between ignored vs unsupported files
- Pattern examples: *.tmp, build/, test*.js, \!important.js
This commit is contained in:
carraes
2025-07-07 15:39:20 -03:00
parent c50bd8f203
commit 6e78bc9700
4 changed files with 254 additions and 2 deletions
+5 -1
View File
@@ -63,7 +63,11 @@ func (p *Processor) processGitChanges() error {
if IsSupportedFile(change.Path) {
supportedChanges = append(supportedChanges, change)
} else if p.cli.Verbose {
fmt.Printf("Skipping unsupported file: %s\n", change.Path)
if IsIgnored(change.Path) {
fmt.Printf("Skipping ignored file: %s\n", change.Path)
} else {
fmt.Printf("Skipping unsupported file: %s\n", change.Path)
}
}
}
+14 -1
View File
@@ -5,6 +5,7 @@ import (
"path/filepath"
"strings"
"github.com/carlosarraes/shush/internal/ignore"
"github.com/carlosarraes/shush/internal/types"
)
@@ -152,5 +153,17 @@ func IsSupportedFile(filename string) bool {
}
ext = strings.TrimPrefix(ext, ".")
_, ok := languageMap[ext]
return ok
if !ok {
return false
}
return !IsIgnored(filename)
}
func IsIgnored(filename string) bool {
ignoreChecker, err := ignore.Load()
if err != nil {
return false
}
return ignoreChecker.IsIgnored(filename)
}
+5
View File
@@ -40,6 +40,11 @@ func (p *Processor) Process() error {
return p.processDirectory(p.cli.Path)
}
if IsIgnored(p.cli.Path) {
fmt.Printf("File %s is in .shushignore, ignoring\n", p.cli.Path)
return nil
}
return p.processFile(p.cli.Path)
}