adding recover for patch generation (#534)

This commit is contained in:
Zachary Rice authored and GitHub committed 2021-03-05 16:00:41 -05:00
1 parent a10ae91ba7
commit b3bed5658d
1 file changed
+9 -1
+9 -1
View File
@@ -43,6 +43,14 @@ func (cs *CommitScanner) SetRepoName(repoName string) {
func (cs *CommitScanner) Scan() (Report, error) {
var scannerReport Report
defer func() {
if err := recover(); err != nil {
// sometimes the Patch generation will fail due to a known bug in
// sergi's go-diff: https://github.com/sergi/go-diff/issues/89.
return
}
}()
if cs.cfg.Allowlist.CommitAllowed(cs.commit.Hash.String()) {
return scannerReport, nil
}
@@ -62,7 +70,7 @@ func (cs *CommitScanner) Scan() (Report, error) {
}
patch, err := parent.Patch(cs.commit)
if err != nil {
if err != nil || patch == nil {
return scannerReport, fmt.Errorf("could not generate Patch")
}