better ssh handling

This commit is contained in:
zach rice committed 2018-10-24 15:49:53 -05:00
1 parent e288db29a8
commit 98e6ba9378
3 files changed
+57 -73

No files matched your search

+7 -13
View File
@@ -117,11 +117,11 @@ func auditGithubRepos() ([]Leak, error) {
break
}
if opts.GithubUser != "" {
if opts.IncludePrivate {
pagedGithubRepos, resp, err = githubClient.Repositories.List(ctx, "", githubOptions)
} else {
pagedGithubRepos, resp, err = githubClient.Repositories.List(ctx, opts.GithubUser, githubOptions)
}
// if opts.IncludePrivate {
// pagedGithubRepos, resp, err = githubClient.Repositories.List(ctx, "", githubOptions)
// } else {
pagedGithubRepos, resp, err = githubClient.Repositories.List(ctx, opts.GithubUser, githubOptions)
// }
if err != nil {
done = true
}
@@ -199,10 +199,7 @@ func cloneGithubRepo(githubRepo *github.Repository) (*RepoDescriptor, error) {
if err != nil {
return nil, fmt.Errorf("unable to generater owner temp dir: %v", err)
}
if opts.IncludePrivate {
if sshAuth == nil {
return nil, fmt.Errorf("no ssh auth available")
}
if sshAuth != nil {
repo, err = git.PlainClone(fmt.Sprintf("%s/%s", ownerDir, *githubRepo.Name), false, &git.CloneOptions{
URL: *githubRepo.SSHURL,
Auth: sshAuth,
@@ -213,10 +210,7 @@ func cloneGithubRepo(githubRepo *github.Repository) (*RepoDescriptor, error) {
})
}
} else {
if opts.IncludePrivate {
if sshAuth == nil {
return nil, fmt.Errorf("no ssh auth available")
}
if sshAuth != nil {
repo, err = git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
URL: *githubRepo.SSHURL,
Auth: sshAuth,