Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a83aad2

Browse filesBrowse files
committed
renamed Sort enum, some cleanup, better javadoc
1 parent a5425a3 commit a83aad2
Copy full SHA for a83aad2

File tree

Expand file treeCollapse file tree

1 file changed

+14
-6
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+14
-6
lines changed

‎src/main/java/org/kohsuke/github/GHRepository.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHRepository.java
+14-6Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import java.util.*;
3838

3939
import static java.util.Arrays.asList;
40+
import static org.apache.commons.lang.ObjectUtils.defaultIfNull;
4041

4142
/**
4243
* A repository on GitHub.
@@ -512,27 +513,34 @@ public void delete() throws IOException {
512513
/**
513514
* Sort orders for listing forks
514515
*/
515-
public static enum Sort { NEWEST, OLDEST, STARGAZERS }
516+
public static enum ForkSort { NEWEST, OLDEST, STARGAZERS }
516517

517518
/**
518-
* Lists all the direct forks of this repository, sorted by {@link Sort#NEWEST Sort.NEWEST}
519+
* Lists all the direct forks of this repository, sorted by
520+
* github api default, currently {@link ForkSort#NEWEST ForkSort.NEWEST}.
519521
*/
520522
public PagedIterable<GHRepository> listForks() {
521523
return listForks(null);
522524
}
523525

524526
/**
525527
* Lists all the direct forks of this repository, sorted by the given sort order.
526-
* @param sort the sort order. If null, defaults to {@link Sort#NEWEST Sort.NEWEST}.
528+
* @param sort the sort order. If null, defaults to github api default,
529+
* currently {@link ForkSort#NEWEST ForkSort.NEWEST}.
527530
*/
528-
public PagedIterable<GHRepository> listForks(final Sort sort) {
531+
public PagedIterable<GHRepository> listForks(final ForkSort sort) {
529532
return new PagedIterable<GHRepository>() {
530533
public PagedIterator<GHRepository> iterator() {
531-
return new PagedIterator<GHRepository>(root.retrieve().asIterator(getApiTailUrl("forks" + ((sort == null)?"":("?sort="+sort.toString().toLowerCase(Locale.ENGLISH)))), GHRepository[].class)) {
534+
String sortParam = "";
535+
if (sort != null) {
536+
sortParam = "?sort=" + sort.toString().toLowerCase(Locale.ENGLISH);
537+
}
538+
return new PagedIterator<GHRepository>(root.retrieve().asIterator(getApiTailUrl("forks" + sortParam), GHRepository[].class)) {
532539
@Override
533540
protected void wrapUp(GHRepository[] page) {
534-
for (GHRepository c : page)
541+
for (GHRepository c : page) {
535542
c.wrap(root);
543+
}
536544
}
537545
};
538546
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.