From d9a060a12d12e2538c0cf2885827d13f8d411c04 Mon Sep 17 00:00:00 2001 From: Peter Gallagher Date: Thu, 28 Nov 2019 13:53:18 +0000 Subject: [PATCH] Honour file whitelist for AuditUncommitted function --- audit/repo.go | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/audit/repo.go b/audit/repo.go index a08de932..662f3f47 100644 --- a/audit/repo.go +++ b/audit/repo.go @@ -146,18 +146,22 @@ func (repo *Repo) AuditUncommitted() error { } } - dmp := diffmatchpatch.New() - diffs := dmp.DiffMain(prevFileContents, currFileContents, false) - var diffContents string - for _, d := range diffs { - switch d.Type { - case diffmatchpatch.DiffInsert: - diffContents += fmt.Sprintf("%s\n", d.Text) - case diffmatchpatch.DiffDelete: - diffContents += fmt.Sprintf("%s\n", d.Text) + if fileMatched(filename, repo.config.Whitelist.File) { + log.Debugf("whitelisted file found, skipping audit of file: %s", filename) + } else { + dmp := diffmatchpatch.New() + diffs := dmp.DiffMain(prevFileContents, currFileContents, false) + var diffContents string + for _, d := range diffs { + switch d.Type { + 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) } }