Skip to content

Commit

Permalink
fix: restrict-to-files only avoids skip-files, not skip-dirs.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcchavezs committed Oct 1, 2023
1 parent 081ee6f commit 1aec06c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cmd/porto/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func main() {
flagSkipDirs := flag.String("skip-dirs", "", "Regexps of directories to skip")
flagSkipDefaultDirs := flag.Bool("skip-dirs-use-default", true, "Use default skip directory list")
flagIncludeInternal := flag.Bool("include-internal", false, "Include internal folders")
flagRestrictToFiles := flag.String("restrict-to-files", "", "Regexps of files to restrict the inspection on. It takes precedence over -skip-files and -skip-dirs")
flagRestrictToFiles := flag.String("restrict-to-files", "", "Regexps of files to restrict the inspection on. It takes precedence over -skip-files")
flag.Parse()

baseDir := flag.Arg(0)
Expand Down Expand Up @@ -54,7 +54,7 @@ Add import path to a folder
log.Fatalf("failed to build files regexes to include: %v", err)
}

var skipDirsRegex []*regexp.Regexp
var skipDirsRegex = []*regexp.Regexp{}
if *flagSkipDefaultDirs {
skipDirsRegex = append(skipDirsRegex, porto.StdExcludeDirRegexps...)
}
Expand All @@ -68,13 +68,13 @@ Add import path to a folder
WriteResultToFile: *flagWriteOutputToFile,
ListDiffFiles: *flagListDiff,
IncludeInternal: *flagIncludeInternal,
SkipDirsRegexes: skipDirsRegex,
}

if len(restrictToFilesRegex) > 0 {
opts.RestrictToFilesRegexes = restrictToFilesRegex
} else {
opts.SkipFilesRegexes = skipFilesRegex
opts.SkipDirsRegexes = skipDirsRegex
}

diffCount, err := porto.FindAndAddVanityImportForDir(workingDir, baseAbsDir, opts)
Expand Down

0 comments on commit 1aec06c

Please sign in to comment.