Compare commits

..
4 Commits
Author SHA1 Message Date
Zachary Rice f3a8359ac0 Merge pull request #86 from zricethezav/patch-err-check
Patch err check
2018-08-11 15:33:39 -04:00
zach rice 829e8fed8c up check to warning msg 2018-08-11 14:30:34 -05:00
zach rice c7e3605bff bump patch 2018-08-11 14:29:23 -05:00
zach rice c1774b1596 err check on patch 2018-08-11 14:27:51 -05:00
2 changed files with 16 additions and 3 deletions

No files matched your search

+4
View File
@@ -1,6 +1,10 @@
CHANGELOG
=========
1.2.1
-----
- Check errors when generating commit patch
1.2.0
-----
- Added support for providing an alternate GitHub URL to support scanning GitHub Enteprise repositories
+12 -3
View File
@@ -276,8 +276,8 @@ func getRepo() (Repo, error) {
r *git.Repository
)
log.Infof("cloning %s", opts.Repo)
if opts.Disk {
log.Infof("cloning %s", opts.Repo)
cloneTarget := fmt.Sprintf("%s/%x", dir, md5.Sum([]byte(fmt.Sprintf("%s%s", opts.GithubUser, opts.Repo))))
if opts.IncludePrivate {
r, err = git.PlainClone(cloneTarget, false, &git.CloneOptions{
@@ -293,8 +293,10 @@ func getRepo() (Repo, error) {
}
} else if opts.RepoPath != "" {
// use existing repo
log.Infof("opening %s", opts.Repo)
r, err = git.PlainOpen(opts.RepoPath)
} else {
log.Infof("cloning %s", opts.Repo)
if opts.IncludePrivate {
r, err = git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
URL: opts.Repo,
@@ -351,7 +353,6 @@ func auditRef(r *git.Repository, ref *plumbing.Reference, commitWg *sync.WaitGro
if prevCommit == nil {
prevCommit = c
}
commitWg.Add(1)
go func(c *object.Commit, prevCommit *object.Commit) {
var (
@@ -359,7 +360,15 @@ func auditRef(r *git.Repository, ref *plumbing.Reference, commitWg *sync.WaitGro
filePath string
skipFile bool
)
patch, _ := c.Patch(prevCommit)
patch, err := c.Patch(prevCommit)
if err != nil {
log.Warnf("problem generating patch for commit: %s\n", c.Hash.String())
if limitGoRoutines {
<-semaphore
}
commitChan <- leaks
return
}
for _, f := range patch.FilePatches() {
skipFile = false
from, to := f.Files()