Skip to content

Instantly share code, notes, and snippets.

@mtomas
Created November 14, 2012 16:18
Show Gist options
  • Save mtomas/4073064 to your computer and use it in GitHub Desktop.
Save mtomas/4073064 to your computer and use it in GitHub Desktop.
Get repos associated to user
private static List<Repository> getRepositoryByGitUsername(String gitUsername) throws IOException {
RepositoryService repositoryService = new RepositoryService(Projects.gitHubClient);
CollaboratorService collaboratorService = new CollaboratorService(Projects.gitHubClient);
List<Repository> repositoryList = repositoryService.getRepositories();
List<Repository> userRepositoryNameList = new ArrayList<Repository>();
for (Repository repository : repositoryList) {
if (collaboratorService.isCollaborator(repository, gitUsername)) {
userRepositoryNameList.add(repository);
}
}
return userRepositoryNameList;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment