File tree Expand file tree Collapse file tree 2 files changed +73
-1
lines changed
Filter options
src/main/java/org/kohsuke/github Expand file tree Collapse file tree 2 files changed +73
-1
lines changed
Original file line number Diff line number Diff line change @@ -935,12 +935,36 @@ public PagedIterable<GHUser> listSubscribers() {
935
935
}
936
936
937
937
/**
938
- * Lists all the users who have starred this repo.
938
+ * Lists all the users who have starred this repo based on the old version of the API. For
939
+ * additional information, like date when the repository was starred, see {@link #listExtendedStargazers()}
939
940
*/
940
941
public PagedIterable <GHUser > listStargazers () {
941
942
return listUsers ("stargazers" );
942
943
}
943
944
945
+ /**
946
+ * Lists all the users who have starred this repo based on new version of the API, having extended
947
+ * information like the time when the repository was starred. For compatibility with the old API
948
+ * see {@link #listStargazers()}
949
+ */
950
+ public PagedIterable <GHStargazer > listExtendedStargazers () {
951
+ return new PagedIterable <GHStargazer >() {
952
+ @ Override
953
+ public PagedIterator <GHStargazer > _iterator (int pageSize ) {
954
+ Requester requester = root .retrieve ();
955
+ requester .setHeader ("Accept" , "application/vnd.github.v3.star+json" );
956
+ return new PagedIterator <GHStargazer >(requester .asIterator (getApiTailUrl ("stargazers" ), GHStargazer [].class , pageSize )) {
957
+ @ Override
958
+ protected void wrapUp (GHStargazer [] page ) {
959
+ for (GHStargazer c : page ) {
960
+ c .wrapUp (GHRepository .this );
961
+ }
962
+ }
963
+ };
964
+ }
965
+ };
966
+ }
967
+
944
968
private PagedIterable <GHUser > listUsers (final String suffix ) {
945
969
return new PagedIterable <GHUser >() {
946
970
public PagedIterator <GHUser > _iterator (int pageSize ) {
Original file line number Diff line number Diff line change
1
+ package org .kohsuke .github ;
2
+
3
+ import java .util .Date ;
4
+
5
+ /**
6
+ * A stargazer at a repository on GitHub.
7
+ *
8
+ * @author noctarius
9
+ */
10
+ public class GHStargazer {
11
+
12
+ private GHRepository repository ;
13
+ private String starred_at ;
14
+ private GHUser user ;
15
+
16
+ /**
17
+ * Gets the repository that is stargazed
18
+ *
19
+ * @return the starred repository
20
+ */
21
+ public GHRepository getRepository () {
22
+ return repository ;
23
+ }
24
+
25
+ /**
26
+ * Gets the date when the repository was starred, however old stars before
27
+ * August 2012, will all show the date the API was changed to support starred_at.
28
+ *
29
+ * @return the date the stargazer was added
30
+ */
31
+ public Date getStarredAt () {
32
+ return GitHub .parseDate (starred_at );
33
+ }
34
+
35
+ /**
36
+ * Gets the user that starred the repository
37
+ *
38
+ * @return the stargazer user
39
+ */
40
+ public GHUser getUser () {
41
+ return user ;
42
+ }
43
+
44
+ void wrapUp (GHRepository repository ) {
45
+ this .repository = repository ;
46
+ user .wrapUp (repository .root );
47
+ }
48
+ }
You can’t perform that action at this time.
0 commit comments