Fixing patch direction and making additions the default (#408)

* Fixing patch direction and making additions the default

* adding test
This commit is contained in:
Zachary Rice authored and GitHub committed 2020-07-22 13:32:46 -04:00
1 parent e36b550851
commit cfbb600fcb
16 files changed
+103 -410

No files matched your search

+7 -5
View File
@@ -213,10 +213,7 @@ func (repo *Repo) AuditUncommitted() error {
diffs := diffmatchpatch.New().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:
if d.Type == diffmatchpatch.DiffInsert {
diffContents += fmt.Sprintf("%s\n", d.Text)
}
}
@@ -312,8 +309,13 @@ func (repo *Repo) Audit() error {
if repo.timeoutReached() {
return nil
}
if parent == nil {
// shouldn't reach this point but just in case
return nil
}
start := time.Now()
patch, err := c.Patch(parent)
patch, err := parent.Patch(c)
if err != nil {
return fmt.Errorf("could not generate patch")
}