diff --git a/src/main/java/org/kohsuke/github/GHMyself.java b/src/main/java/org/kohsuke/github/GHMyself.java index 2507d4d65d..4f145402ec 100644 --- a/src/main/java/org/kohsuke/github/GHMyself.java +++ b/src/main/java/org/kohsuke/github/GHMyself.java @@ -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 getEmails() throws IOException { + return listEmails().toList().stream().map(email -> email.getEmail()).toList(); + } + /** * Returns the read-only list of e-mail addresses configured for you. *

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

+ * 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 getEmails() throws IOException { - return root().createRequest().withUrlPath("/user/emails").toIterable(GHEmail[].class, null).toList(); + public PagedIterable listEmails() { + return root().createRequest().withUrlPath("/user/emails").toIterable(GHEmail[].class, null); } /** diff --git a/src/main/java/org/kohsuke/github/GHOrganization.java b/src/main/java/org/kohsuke/github/GHOrganization.java index c3d25c6363..2ea7ef22d2 100644 --- a/src/main/java/org/kohsuke/github/GHOrganization.java +++ b/src/main/java/org/kohsuke/github/GHOrganization.java @@ -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. *

* This used to be an efficient method that didn't involve traversing every repository, but now it doesn't do any * optimization. @@ -595,9 +595,10 @@ public PagedIterable 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 listRepositories() { diff --git a/src/main/java/org/kohsuke/github/GHPerson.java b/src/main/java/org/kohsuke/github/GHPerson.java index 989fd3a8d2..a3a5d2b1fc 100644 --- a/src/main/java/org/kohsuke/github/GHPerson.java +++ b/src/main/java/org/kohsuke/github/GHPerson.java @@ -78,7 +78,7 @@ public synchronized Map 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. *

* Unlike {@link #getRepositories()}, this does not wait until all the repositories are returned. * @@ -91,6 +91,20 @@ public PagedIterable 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 listRepositories(final int pageSize) { + return listRepositories().withPageSize(pageSize); + } + /** * Gets repository. * diff --git a/src/main/java/org/kohsuke/github/PagedIterable.java b/src/main/java/org/kohsuke/github/PagedIterable.java index a92d0ef693..ac332a89fd 100644 --- a/src/main/java/org/kohsuke/github/PagedIterable.java +++ b/src/main/java/org/kohsuke/github/PagedIterable.java @@ -37,6 +37,9 @@ public abstract class PagedIterable implements Iterable { * @return the paged iterable */ public PagedIterable withPageSize(int size) { + if (size < 0) { + size = 0; + } this.pageSize = size; return this; } diff --git a/src/test/resources/slow-or-flaky-tests.txt b/src/test/resources/slow-or-flaky-tests.txt index b9c6fbbdc2..df6827bec0 100644 --- a/src/test/resources/slow-or-flaky-tests.txt +++ b/src/test/resources/slow-or-flaky-tests.txt @@ -1,4 +1,5 @@ **/extras/** +**/AbuseLimitHandlerTest **/GHRateLimitTest **/GHPullRequestTest **/RequesterRetryTest