@@ -10,7 +10,9 @@ import (
1010
1111// FindFoldersRecursive finds all folders recursively in the given directory
1212// that can be validated (i.e., have a detectable category)
13- func FindFoldersRecursive (dir string ) ([]string , error ) {
13+ // Note: overwriteCategory parameter is kept for API compatibility but not used here.
14+ // The overwrite category is applied during validation, not during folder discovery.
15+ func FindFoldersRecursive (dir string , overwriteCategory string ) ([]string , error ) {
1416 var folders []string
1517
1618 err := filepath .Walk (dir , func (path string , info os.FileInfo , err error ) error {
@@ -20,8 +22,9 @@ func FindFoldersRecursive(dir string) ([]string, error) {
2022 }
2123
2224 if info .IsDir () {
23- // Try to detect category for this folder
24- category , err := DetectCategory (path )
25+ // Always try to detect category for this folder to filter for valid releases
26+ // The overwrite category will be applied later during validation
27+ category , err := DetectCategory (path , "" )
2528 if err == nil && category != "" {
2629 folders = append (folders , path )
2730 }
@@ -39,8 +42,8 @@ func FindFoldersRecursive(dir string) ([]string, error) {
3942
4043// validateSingleFolder validates a single folder and displays results
4144func validateSingleFolder (folderPath string , presetConfig * preset.PresetConfig , opts Options ) (bool , error ) {
42- // Detect category
43- category , err := DetectCategory (folderPath )
45+ // Detect category (or use overwrite if provided)
46+ category , err := DetectCategory (folderPath , opts . OverwriteCategory )
4447 if err != nil {
4548 return false , fmt .Errorf ("failed to detect category for %s: %w" , folderPath , err )
4649 }
@@ -72,6 +75,13 @@ func ValidateFolders(folders []string, opts Options) error {
7275 return fmt .Errorf ("failed to load presets: %w" , err )
7376 }
7477
78+ // Validate overwrite category if provided
79+ if opts .OverwriteCategory != "" {
80+ if _ , exists := presetConfig .Rules [opts .OverwriteCategory ]; ! exists {
81+ return fmt .Errorf ("invalid category '%s': category not found in preset configuration" , opts .OverwriteCategory )
82+ }
83+ }
84+
7585 var hasErrors bool
7686
7787 for _ , folder := range folders {
@@ -99,7 +109,7 @@ func ValidateFolders(folders []string, opts Options) error {
99109
100110 if opts .Recursive {
101111 // Find all folders recursively
102- subFolders , err := FindFoldersRecursive (absPath )
112+ subFolders , err := FindFoldersRecursive (absPath , opts . OverwriteCategory )
103113 if err != nil {
104114 fmt .Fprintf (os .Stderr , "Error: failed to find folders recursively in %s: %v\n " , folder , err )
105115 hasErrors = true
0 commit comments