Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor code to not fetch repos that are explicitly excluded #26

Open
MasonEgger opened this issue Oct 12, 2020 · 2 comments
Open

Refactor code to not fetch repos that are explicitly excluded #26

MasonEgger opened this issue Oct 12, 2020 · 2 comments
Labels
good first issue Good for newcomers hacktoberfest Help wanted for hacktoberfest help wanted Extra attention is needed

Comments

@MasonEgger
Copy link
Member

Currently in the code base we fetch the repositories for a user or an organization with the following respectively

opt := &github.RepositoryListOptions{Type: "all"}
...
var repos, resp, err = client.Repositories.List(ctx, *githubUser, opt)

and

opt := &github.RepositoryListByOrgOptions{Type: "all"}
...
var repos, resp, err = client.Repositories.ListByOrg(ctx, *githubOrg, opt)

And when we want to exclude things such as forks,private, archived or disabled repos we simply pass over them in our evaluation

if *repo.Archived == true {
	loggerWithFields.Info("skipping archived")
	continue
}

if *repo.Disabled == true {
	loggerWithFields.Info("skipping disabled")
	continue
}

if *includeForks == false {
	if *repo.Fork == true {
		loggerWithFields.Info("skipping fork")
		continue
	}
}

if *includePrivate == false {
	if *repo.Private == true {
		loggerWithFields.Info("skipping private")
		continue
	}
}

The GitHub API supports changing the types in the options that are declared above as shown in their documentation https://developer.github.com/v3/repos/#list-repositories-for-the-authenticated-user

This would be a good issue if someone wanted to investigate this and see if they can instead modify the opts variable with the appropriate string to prevent us from getting unnecessary repos.

@MasonEgger MasonEgger added good first issue Good for newcomers help wanted Extra attention is needed hacktoberfest Help wanted for hacktoberfest labels Oct 12, 2020
@dragoneena12
Copy link
Contributor

I worked on this issue and find a few things

ListByOrg is easy to refactor to fetch only appropriate repos thanks to the list-organization-repositories API has useful type values like public, private, and forks. I created PR about this. #27

However List is not because the list-repos-for-user API does not have such type values. Also this API does not provide private repo and this mean include-private flag does not work for user repos.

I think it is good to use list-repositories-for-the authenticated-user API if no username is provided. The go-github library List method uses this API if no username is provided too(https://godoc.org/github.com/google/go-github/github#RepositoriesService.List ).

@Daksheshapkare
Copy link

@Hacktoberfest Hacktoberfest deleted a comment from Firoj19 Feb 26, 2024
@Hacktoberfest Hacktoberfest deleted a comment from rexionmars Feb 26, 2024
@Hacktoberfest Hacktoberfest deleted a comment from zaidhfarshad Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers hacktoberfest Help wanted for hacktoberfest help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants