This repository was archived by the owner on Jul 31, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed
main/java/org/kohsuke/github
test/java/org/kohsuke/github Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -1093,6 +1093,27 @@ public GHSubscription getSubscription() throws IOException {
10931093 }
10941094 }
10951095
1096+ public PagedIterable <Contributor > listContributors () throws IOException {
1097+ return new PagedIterable <Contributor >() {
1098+ public PagedIterator <Contributor > iterator () {
1099+ return new PagedIterator <Contributor >(root .retrieve ().asIterator (getApiTailUrl ("contributors" ), Contributor [].class )) {
1100+ @ Override
1101+ protected void wrapUp (Contributor [] page ) {
1102+ for (Contributor c : page )
1103+ c .wrapUp (root );
1104+ }
1105+ };
1106+ }
1107+ };
1108+ }
1109+
1110+ public static class Contributor extends GHUser {
1111+ private int contributions ;
1112+
1113+ public int getContributions () {
1114+ return contributions ;
1115+ }
1116+ }
10961117
10971118
10981119
Original file line number Diff line number Diff line change 11package org .kohsuke .github ;
22
33import org .junit .Test ;
4+ import org .kohsuke .github .GHRepository .Contributor ;
45
56import java .io .IOException ;
67
@@ -21,6 +22,24 @@ public void subscription() throws Exception {
2122 assertNull (r .getSubscription ());
2223 }
2324
25+ @ Test
26+ public void listContributors () throws IOException {
27+ GHRepository r = gitHub .getOrganization ("stapler" ).getRepository ("stapler" );
28+ int i =0 ;
29+ boolean kohsuke = false ;
30+
31+ for (Contributor c : r .listContributors ()) {
32+ System .out .println (c .getName ());
33+ assertTrue (c .getContributions ()>0 );
34+ if (c .getLogin ().equals ("kohsuke" ))
35+ kohsuke = true ;
36+ if (i ++ > 5 )
37+ break ;
38+ }
39+
40+ assertTrue (kohsuke );
41+ }
42+
2443 private GHRepository getRepository () throws IOException {
2544 return gitHub .getOrganization ("github-api-test-org" ).getRepository ("jenkins" );
2645 }
You can’t perform that action at this time.
0 commit comments