Skip to content

Commit 31d3682

Browse files
committed
Restore listRepositories()
1 parent d9019e0 commit 31d3682

File tree

5 files changed

+51
-5
lines changed

5 files changed

+51
-5
lines changed

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

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ public enum RepositoryListFilter {
3737
MEMBER;
3838
}
3939

40+
/**
41+
* Gets emails.
42+
*
43+
* @return the emails
44+
* @throws IOException
45+
* the io exception
46+
* @deprecated Use {@link #getEmails2()}
47+
*/
48+
@Deprecated
49+
public List<String> getEmails() throws IOException {
50+
return listEmails().toList().stream().map(email -> email.getEmail()).toList();
51+
}
52+
4053
/**
4154
* Returns the read-only list of e-mail addresses configured for you.
4255
* <p>
@@ -46,9 +59,23 @@ public enum RepositoryListFilter {
4659
* @return Always non-null.
4760
* @throws IOException
4861
* the io exception
62+
* @deprecated Use {@link #listEmails()}
63+
*/
64+
@Deprecated
65+
public List<GHEmail> getEmails2() throws IOException {
66+
return listEmails().toList();
67+
}
68+
69+
/**
70+
* Returns the read-only list of e-mail addresses configured for you.
71+
* <p>
72+
* This corresponds to the stuff you configure in https://github.com/settings/emails, and not to be confused with
73+
* {@link #getEmail()} that shows your public e-mail address set in https://github.com/settings/profile
74+
*
75+
* @return Always non-null.
4976
*/
50-
public List<GHEmail> getEmails() throws IOException {
51-
return root().createRequest().withUrlPath("/user/emails").toIterable(GHEmail[].class, null).toList();
77+
public PagedIterable<GHEmail> listEmails() {
78+
return root().createRequest().withUrlPath("/user/emails").toIterable(GHEmail[].class, null);
5279
}
5380

5481
/**

src/main/java/org/kohsuke/github/GHOrganization.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ public GHTeamBuilder createTeam(String name) {
546546
}
547547

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

597597
/**
598-
* Lists up all the repositories using the specified page size.
598+
* List all the repositories using a default of 30 items page size.
599599
*
600600
* @return the paged iterable
601+
* @deprecated Use #listRepositories().withPageSize() instead.
601602
*/
602603
@Override
603604
public PagedIterable<GHRepository> listRepositories() {

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public synchronized Map<String, GHRepository> getRepositories() throws IOExcepti
7878
}
7979

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

94+
/**
95+
* Lists up all the repositories using the specified page size.
96+
*
97+
* @param pageSize
98+
* size for each page of items returned by GitHub. Maximum page size is 100. Unlike
99+
* {@link #getRepositories()}, this does not wait until all the repositories are returned.
100+
* @return the paged iterable
101+
* @deprecated Use #listRepositories().withPageSize() instead.
102+
*/
103+
@Deprecated
104+
public PagedIterable<GHRepository> listRepositories(final int pageSize) {
105+
return listRepositories().withPageSize(pageSize);
106+
}
107+
94108
/**
95109
* Gets repository.
96110
*

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public abstract class PagedIterable<T> implements Iterable<T> {
3737
* @return the paged iterable
3838
*/
3939
public PagedIterable<T> withPageSize(int size) {
40+
if (size < 0) {
41+
size = 0;
42+
}
4043
this.pageSize = size;
4144
return this;
4245
}

src/test/resources/slow-or-flaky-tests.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
**/extras/**
2+
**/AbuseLimitHandlerTest
23
**/GHRateLimitTest
34
**/GHPullRequestTest
45
**/RequesterRetryTest

0 commit comments

Comments
 (0)