Merge pull request #88 from Fabse333/master

Added Support for branches
This commit is contained in:
Zachary Rice authored and GitHub committed 2018-09-12 12:41:00 -05:00
commit 5e289ed0cc
1 file changed
+16
+16
View File
@@ -445,6 +445,22 @@ func auditRepo(r *git.Repository) ([]Leak, error) {
return nil
})
} else {
if opts.Branch != "" {
foundBranch := false
refs, _ := r.Storer.IterReferences()
branch := strings.Split(opts.Branch, "/")[len(strings.Split(opts.Branch, "/"))-1]
err = refs.ForEach(func(refBranch *plumbing.Reference) error {
if strings.Split(refBranch.Name().String(), "/")[len(strings.Split(refBranch.Name().String(), "/"))-1] == branch {
foundBranch = true
ref = refBranch
}
return nil
})
if foundBranch == false {
log.Fatalf("No branch with name", opts.Branch)
return nil, nil
}
}
auditRef(r, ref, &commitWg, commitChan)
}