diff --git a/main.go b/main.go index 00047b6..57288cf 100644 --- a/main.go +++ b/main.go @@ -126,6 +126,7 @@ func main() { Action: func(c *cli.Context) error { if dry { res := pkg.GetExcludedPaths(rulePath, par, buffer, verbose) + fmt.Println("-----") fmt.Print(strings.Join(res,"\r\n")) fmt.Print("\n") } else { diff --git a/pkg/parser/file-trigger.go b/pkg/parser/file-trigger.go index 9890c89..3cf31b3 100644 --- a/pkg/parser/file-trigger.go +++ b/pkg/parser/file-trigger.go @@ -14,8 +14,6 @@ type FileTriggerSettings struct { ExcludePaths []string } -const FileTriggerType = "" - func fileTriggerSettingsParse(i map[string]interface{}) (*FileTriggerSettings, error) { fileTrigger, found1 := i["fileTrigger"].(string) excludePathsI, found2 := i["excludePaths"].([]interface{}) @@ -37,14 +35,14 @@ func fileTriggerWalker(rule Rule, settings FileTriggerSettings) walker.Walker { fixIgnorePaths = append(fixIgnorePaths, path) } } - return func(path string, subfiles []os.FileInfo) ([]string, []string, []string) { + return func(path string, subfiles []os.FileInfo) ([]string, []string, []string, string) { if utils.ContainsFIA(subfiles, settings.FileTrigger) { var ret []string for _, f := range settings.ExcludePaths { ret = append(ret, filepath.Join(path, f)) } - return ret, []string{}, fixIgnorePaths + return ret, []string{}, fixIgnorePaths, rule.Name } - return []string{}, []string{}, fixIgnorePaths + return []string{}, []string{}, fixIgnorePaths, rule.Name } } diff --git a/pkg/walker/walker.go b/pkg/walker/walker.go index cf7fe66..4a51e94 100644 --- a/pkg/walker/walker.go +++ b/pkg/walker/walker.go @@ -12,7 +12,8 @@ import ( //first ret is the excluding paths we found //second ret is the global ignore paths if we don't want other runners to go into it //third ret is the local ignore path if we don't want to go into it next time -type Walker = func(path string, files []os.FileInfo) ([]string, []string, []string) +//last param is the name of the rule for verbose +type Walker = func(path string, files []os.FileInfo) ([]string, []string, []string, string) type WalkerIgnores struct { w Walker @@ -94,7 +95,23 @@ func walk(runnerId int, rootpath string, walkers []Walker, alreadyFiltered []str ignores := []WalkerIgnores{} globalIgnores := []string{} for _, walker := range walkers { - r, i1, i2 := walker(l.Data, files) + r, i1, i2, name := walker(l.Data, files) + if(verbose && len(r) > 0) { + fmt.Println("-----") + fmt.Println(name) + fmt.Println(l.Data) + for _, v := range r { + fmt.Println("\t", v) + } + fmt.Println("-") + for _, v := range i1 { + fmt.Println("\t", v) + } + fmt.Println("-") + for _, v := range i2 { + fmt.Println("\t", v) + } + } res = res.Prepend(r) ignores = append(ignores, WalkerIgnores{walker, i2}) globalIgnores = append(globalIgnores, i1...) diff --git a/rules/python-pip.yaml b/rules/python-pip.yaml new file mode 100644 index 0000000..cfbb58d --- /dev/null +++ b/rules/python-pip.yaml @@ -0,0 +1,10 @@ +name: "python-pip" +enabled: true +searchPaths: ["~"] +ignorePaths: [] +ruleType: "file-trigger" +ruleSettings: + fileTrigger: "Pipfile" + excludePaths: + - ".venv" + - "venv"