Skip to content

Commit

Permalink
Restore listRepositories()
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwiseman committed Sep 14, 2024
1 parent d9019e0 commit 31d3682
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 5 deletions.
31 changes: 29 additions & 2 deletions src/main/java/org/kohsuke/github/GHMyself.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ public enum RepositoryListFilter {
MEMBER;
}

/**
* Gets emails.
*
* @return the emails
* @throws IOException
* the io exception
* @deprecated Use {@link #getEmails2()}
*/
@Deprecated
public List<String> getEmails() throws IOException {
return listEmails().toList().stream().map(email -> email.getEmail()).toList();

Check warning on line 50 in src/main/java/org/kohsuke/github/GHMyself.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/kohsuke/github/GHMyself.java#L50

Added line #L50 was not covered by tests
}

/**
* Returns the read-only list of e-mail addresses configured for you.
* <p>
Expand All @@ -46,9 +59,23 @@ public enum RepositoryListFilter {
* @return Always non-null.
* @throws IOException
* the io exception
* @deprecated Use {@link #listEmails()}
*/
@Deprecated
public List<GHEmail> getEmails2() throws IOException {
return listEmails().toList();

Check warning on line 66 in src/main/java/org/kohsuke/github/GHMyself.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/kohsuke/github/GHMyself.java#L66

Added line #L66 was not covered by tests
}

/**
* Returns the read-only list of e-mail addresses configured for you.
* <p>
* This corresponds to the stuff you configure in https://github.com/settings/emails, and not to be confused with
* {@link #getEmail()} that shows your public e-mail address set in https://github.com/settings/profile
*
* @return Always non-null.
*/
public List<GHEmail> getEmails() throws IOException {
return root().createRequest().withUrlPath("/user/emails").toIterable(GHEmail[].class, null).toList();
public PagedIterable<GHEmail> listEmails() {
return root().createRequest().withUrlPath("/user/emails").toIterable(GHEmail[].class, null);

Check warning on line 78 in src/main/java/org/kohsuke/github/GHMyself.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/kohsuke/github/GHMyself.java#L78

Added line #L78 was not covered by tests
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/kohsuke/github/GHOrganization.java
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ public GHTeamBuilder createTeam(String name) {
}

/**
* List up repositories that has some open pull requests.
* List repositories that has some open pull requests.
* <p>
* This used to be an efficient method that didn't involve traversing every repository, but now it doesn't do any
* optimization.
Expand Down Expand Up @@ -595,9 +595,10 @@ public PagedIterable<GHEventInfo> listEvents() throws IOException {
}

/**
* Lists up all the repositories using the specified page size.
* List all the repositories using a default of 30 items page size.
*
* @return the paged iterable
* @deprecated Use #listRepositories().withPageSize() instead.
*/
@Override
public PagedIterable<GHRepository> listRepositories() {
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/org/kohsuke/github/GHPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public synchronized Map<String, GHRepository> getRepositories() throws IOExcepti
}

/**
* Lists up all the repositories using a 30 items page size.
* List all the repositories using a default of 30 items page size.
* <p>
* Unlike {@link #getRepositories()}, this does not wait until all the repositories are returned.
*
Expand All @@ -91,6 +91,20 @@ public PagedIterable<GHRepository> listRepositories() {
.withPageSize(30);
}

/**
* Lists up all the repositories using the specified page size.
*
* @param pageSize
* size for each page of items returned by GitHub. Maximum page size is 100. Unlike
* {@link #getRepositories()}, this does not wait until all the repositories are returned.
* @return the paged iterable
* @deprecated Use #listRepositories().withPageSize() instead.
*/
@Deprecated
public PagedIterable<GHRepository> listRepositories(final int pageSize) {
return listRepositories().withPageSize(pageSize);

Check warning on line 105 in src/main/java/org/kohsuke/github/GHPerson.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/kohsuke/github/GHPerson.java#L105

Added line #L105 was not covered by tests
}

/**
* Gets repository.
*
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/kohsuke/github/PagedIterable.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public abstract class PagedIterable<T> implements Iterable<T> {
* @return the paged iterable
*/
public PagedIterable<T> withPageSize(int size) {
if (size < 0) {
size = 0;

Check warning on line 41 in src/main/java/org/kohsuke/github/PagedIterable.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/kohsuke/github/PagedIterable.java#L41

Added line #L41 was not covered by tests
}
this.pageSize = size;
return this;
}
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/slow-or-flaky-tests.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
**/extras/**
**/AbuseLimitHandlerTest
**/GHRateLimitTest
**/GHPullRequestTest
**/RequesterRetryTest
Expand Down

0 comments on commit 31d3682

Please sign in to comment.