func (p *GitHubProvider) gatherPage(user string, page int) ([]GitRepository, error) {
	total := fmt.Sprint(p.totalPages)
	if total == fmt.Sprint(unknownTotal) {
		total = "?"
	}

	log.Infof("Gathering page %v/%v for %s\n", page, total, user)

	var (
		resp       *github.Response
		repos      []*github.Repository
		collectErr error
		visibility string
	)

	if p.options.IncludePublicRepos {
		visibility = "all"
	} else {
		visibility = "private"
	}

	if p.isOrg {
		opt := &github.RepositoryListByOrgOptions{
			ListOptions: github.ListOptions{
				PerPage: reposPerPage, Page: page,
			},
			Type: visibility,
		}
		repos, resp, collectErr = p.client.Repositories.ListByOrg(context.Background(), user, opt)

		if resp.StatusCode == 404 && page == 1 {
			p.isOrg = false
		}
	}

	if !p.isOrg {
		opt := &github.RepositoryListOptions{
			ListOptions: github.ListOptions{
				PerPage: reposPerPage, Page: page,
			},
			Visibility: visibility,
		}

		repos, resp, collectErr = p.client.Repositories.List(context.Background(), user, opt)
	}

	if collectErr != nil {
		return nil, collectErr
	}

	if p.totalPages == unknownTotal {
		p.totalPages = resp.LastPage
	}

	repositories := make([]GitRepository, 0, len(repos))

	for _, repo := range repos {
		if !p.options.IncludeForkedRepos && repo.GetFork() {
			continue
		}

		if !p.options.IncludeArchivedRepos && repo.Archived != nil && *repo.Archived {
			continue
		}

		repositories = append(repositories, createFromGithubRepo(repo))
	}

	return repositories, nil
}
// Gather Page for GitHub provider.
// If is first page update the total page count and try as user as well.
Gather Page for GitHub provider.
If is first page update the total page count and try as user as well.
// Gather Page for GitHub provider . // If is first page update the total page count and try as user as well .
func (p *GitHubProvider) gatherPage(user string, page int) ([]GitRepository, error) {
	total := fmt.Sprint(p.totalPages)
	if total == fmt.Sprint(unknownTotal) {
		total = "?"
	}
	log.Infof("Gathering page %v/%v for %s\n", page, total, user)
	var (
		resp       *github.Response
		repos      []*github.Repository
		collectErr error
		visibility string
	)
	if p.options.IncludePublicRepos {
		visibility = "all"
	} else {
		visibility = "private"
	}
	if p.isOrg {
		opt := &github.RepositoryListByOrgOptions{
			ListOptions: github.ListOptions{
				PerPage: reposPerPage, Page: page,
			},
			Type: visibility,
		}
		repos, resp, collectErr = p.client.Repositories.ListByOrg(context.Background(), user, opt)
		if resp.StatusCode == 404 && page == 1 {
			p.isOrg = false
		}
	}
	if !p.isOrg {
		opt := &github.RepositoryListOptions{
			ListOptions: github.ListOptions{
				PerPage: reposPerPage, Page: page,
			},
			Visibility: visibility,
		}
		repos, resp, collectErr = p.client.Repositories.List(context.Background(), user, opt)
	}
	if collectErr != nil {
		return nil, collectErr
	}
	if p.totalPages == unknownTotal {
		p.totalPages = resp.LastPage
	}
	repositories := make([]GitRepository, 0, len(repos))
	for _, repo := range repos {
		if !p.options.IncludeForkedRepos && repo.GetFork() {
			continue
		}
		if !p.options.IncludeArchivedRepos && repo.Archived != nil && *repo.Archived {
			continue
		}
		repositories = append(repositories, createFromGithubRepo(repo))
	}
	return repositories, nil
}
func ( p * GitHubProvider ) gatherPage ( user string , page int ) ( [ ] GitRepository , error ) { total := fmt . Sprint ( p . totalPages ) if total == fmt . Sprint ( unknownTotal ) { total = " " } log . Infof ( " \n " , page , total , user ) var ( resp * github . Response repos [ ] * github . Repository collectErr error visibility string ) if p . options . IncludePublicRepos { visibility = " " } else { visibility = " " } if p . isOrg { opt := & github . RepositoryListByOrgOptions { ListOptions : github . ListOptions { PerPage : reposPerPage , Page : page , } , Type : visibility , } repos , resp , collectErr = p . client . Repositories . ListByOrg ( context . Background ( ) , user , opt ) if resp . StatusCode == 404 && page == 1 { p . isOrg = false } } if ! p . isOrg { opt := & github . RepositoryListOptions { ListOptions : github . ListOptions { PerPage : reposPerPage , Page : page , } , Visibility : visibility , } repos , resp , collectErr = p . client . Repositories . List ( context . Background ( ) , user , opt ) } if collectErr != nil { return nil , collectErr } if p . totalPages == unknownTotal { p . totalPages = resp . LastPage } repositories := make ( [ ] GitRepository , 0 , len ( repos ) ) for _ , repo := range repos { if ! p . options . IncludeForkedRepos && repo . GetFork ( ) { continue } if ! p . options . IncludeArchivedRepos && repo . Archived != nil && * repo . Archived { continue } repositories = append ( repositories , createFromGithubRepo ( repo ) ) } return repositories , nil }
Gather Page for GitHub provider.
Gather Page for GitHub provider .