Honour file whitelist for AuditUncommitted function

This commit is contained in:
Peter Gallagher committed 2019-11-28 13:53:18 +00:00
1 parent 725da55905
commit d9a060a12d
1 file changed
+14 -10
+14 -10
View File
@@ -146,18 +146,22 @@ func (repo *Repo) AuditUncommitted() error {
} }
} }
dmp := diffmatchpatch.New() if fileMatched(filename, repo.config.Whitelist.File) {
diffs := dmp.DiffMain(prevFileContents, currFileContents, false) log.Debugf("whitelisted file found, skipping audit of file: %s", filename)
var diffContents string } else {
for _, d := range diffs { dmp := diffmatchpatch.New()
switch d.Type { diffs := dmp.DiffMain(prevFileContents, currFileContents, false)
case diffmatchpatch.DiffInsert: var diffContents string
diffContents += fmt.Sprintf("%s\n", d.Text) for _, d := range diffs {
case diffmatchpatch.DiffDelete: switch d.Type {
diffContents += fmt.Sprintf("%s\n", d.Text) case diffmatchpatch.DiffInsert:
diffContents += fmt.Sprintf("%s\n", d.Text)
case diffmatchpatch.DiffDelete:
diffContents += fmt.Sprintf("%s\n", d.Text)
}
} }
InspectString(diffContents, c, repo, filename)
} }
InspectString(diffContents, c, repo, filename)
} }
} }