mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 13:14:22 +01:00
Fixed failure when Branch option is ommited
This commit is contained in:
1 parent
a7ccb7a9d1
commit
d99588fe19
1 file changed
+14
-12
@@ -445,19 +445,21 @@ func auditRepo(r *git.Repository) ([]Leak, error) {
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
foundBranch := false
|
if opts.Branch != "" {
|
||||||
refs, _ := r.Storer.IterReferences()
|
foundBranch := false
|
||||||
branch := strings.Split(opts.Branch, "/")[len(strings.Split(opts.Branch, "/"))-1]
|
refs, _ := r.Storer.IterReferences()
|
||||||
err = refs.ForEach(func(refBranch *plumbing.Reference) error {
|
branch := strings.Split(opts.Branch, "/")[len(strings.Split(opts.Branch, "/"))-1]
|
||||||
if strings.Split(refBranch.Name().String(), "/")[len(strings.Split(refBranch.Name().String(), "/"))-1] == branch {
|
err = refs.ForEach(func(refBranch *plumbing.Reference) error {
|
||||||
foundBranch = true
|
if strings.Split(refBranch.Name().String(), "/")[len(strings.Split(refBranch.Name().String(), "/"))-1] == branch {
|
||||||
ref = refBranch
|
foundBranch = true
|
||||||
|
ref = refBranch
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if foundBranch == false {
|
||||||
|
log.Fatalf("No branch with name", opts.Branch)
|
||||||
|
return nil, nil
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
})
|
|
||||||
if foundBranch == false {
|
|
||||||
log.Fatalf("No branch with name", opts.Branch)
|
|
||||||
return nil, nil
|
|
||||||
}
|
}
|
||||||
auditRef(r, ref, &commitWg, commitChan)
|
auditRef(r, ref, &commitWg, commitChan)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user