Skip to content

Commit

Permalink
feat: revert
Browse files Browse the repository at this point in the history
  • Loading branch information
amazingandyyy committed Apr 18, 2022
1 parent 2450ac4 commit d7d3d94
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
Binary file modified bin/gofuzzyclone
Binary file not shown.
32 changes: 11 additions & 21 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import (
"path"
"regexp"
"strings"
"time"

"gofuzzyclone/internal/helper"
"gofuzzyclone/internal/logger"

"github.com/briandowns/spinner"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing/transport/http"
"github.com/google/go-github/v43/github"
Expand Down Expand Up @@ -71,19 +73,13 @@ func getOrgRepos(client *github.Client, org string) ([]*github.Repository, error
max := 1000
var allRepos []*github.Repository
opt := &github.RepositoryListByOrgOptions{
Sort: "pushed",
Sort: "updated",
ListOptions: github.ListOptions{
PerPage: 80,
PerPage: 100,
},
}
counter := 0
dotsCounter := 0
dots := []string{".", ".", ".", "."}
for {
fmt.Printf("\rScanning %d repositories %s", counter, strings.Join(dots[:dotsCounter%3+1], ""))
dotsCounter++
repos, resp, err := client.Repositories.ListByOrg(context.Background(), org, opt)
counter += len(repos)
if len(allRepos) > max {
allRepos = allRepos[:max]
break
Expand All @@ -109,20 +105,13 @@ func getPersonalRepos(client *github.Client, owner string) ([]*github.Repository
max := 1000
var allRepos []*github.Repository
opt := &github.RepositoryListOptions{
Sort: "pushed",
Visibility: "all",
Sort: "updated",
ListOptions: github.ListOptions{
PerPage: 60,
PerPage: 100,
},
}
counter := 0
dotsCounter := 0
dots := []string{".", ".", ".", ".", "."}
for {
fmt.Printf("\rScanning %d repositories %s", counter, strings.Join(dots[:dotsCounter%4], " "))
dotsCounter++
repos, resp, err := client.Repositories.List(context.Background(), owner, opt)
counter += len(repos)
if len(allRepos) > max {
allRepos = allRepos[:max]
break
Expand All @@ -131,6 +120,7 @@ func getPersonalRepos(client *github.Client, owner string) ([]*github.Repository
if len(repos) == 0 {
break
}

opt.Page = resp.NextPage
allRepos = append(allRepos, repos...)
if resp.NextPage == 0 {
Expand Down Expand Up @@ -202,9 +192,9 @@ func main() {
fmt.Scanf("%s", owner)
}

// s := spinner.New(spinner.CharSets[4], 200*time.Millisecond) // Build our new spinner
// s.Prefix = fmt.Sprintf("Searching %q ", *search)
// s.Start() // Start the spinner
s := spinner.New(spinner.CharSets[4], 200*time.Millisecond) // Build our new spinner
s.Prefix = fmt.Sprintf("Searching %q ", *search)
s.Start() // Start the spinner

ctx := context.Background()
ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: ghToken})
Expand All @@ -227,7 +217,7 @@ func main() {
}
}
fmt.Println("")
// s.Stop()
s.Stop()
for i, repo := range all_repos_matched {
fmt.Printf("%d %v\n", i+1, repo.GetFullName())
}
Expand Down

0 comments on commit d7d3d94

Please sign in to comment.