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 6fe7713

Browse filesBrowse files
committed
paginated release builder
1 parent 569dac4 commit 6fe7713
Copy full SHA for 6fe7713

File tree

Expand file treeCollapse file tree

3 files changed

+67
-1
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+67
-1
lines changed

‎pom.xml

Copy file name to clipboardExpand all lines: pom.xml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>org.kohsuke</groupId>
44
<artifactId>cortexapps-github-api</artifactId>
5-
<version>1.318</version>
5+
<version>1.319</version>
66
<name>GitHub API for Java</name>
77
<url>https://github-api.kohsuke.org/</url>
88
<description>GitHub API for Java</description>
+56Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package org.kohsuke.github;
2+
3+
/**
4+
* Builds up the query for listing releases.
5+
*
6+
* @author eyalfoni
7+
* @see GHRepository#queryReleases()
8+
*/
9+
public class GHReleaseQueryBuilder {
10+
private final Requester req;
11+
private final GHRepository repo;
12+
13+
/**
14+
* Instantiates a new GH release query builder.
15+
*
16+
* @param repo
17+
* the repo
18+
*/
19+
GHReleaseQueryBuilder(GHRepository repo) {
20+
this.repo = repo;
21+
this.req = repo.root().createRequest(); // requester to build up
22+
}
23+
24+
/**
25+
* Page gh release query builder.
26+
*
27+
* @param page
28+
* the page
29+
* @return the gh release query builder
30+
*/
31+
public GHReleaseQueryBuilder page(int page) {
32+
req.with("page", page);
33+
return this;
34+
}
35+
36+
/**
37+
* Page size gh release query builder.
38+
*
39+
* @param pageSize
40+
* the page size
41+
* @return the gh release query builder
42+
*/
43+
public GHReleaseQueryBuilder pageSize(int pageSize) {
44+
req.with("per_page", pageSize);
45+
return this;
46+
}
47+
48+
/**
49+
* Lists up the releases with the criteria built so far.
50+
*
51+
* @return the paged iterable
52+
*/
53+
public PagedIterable<GHRelease> list() {
54+
return req.withUrlPath(repo.getApiTailUrl("releases")).toIterable(GHRelease[].class, item -> item.wrap(repo));
55+
}
56+
}

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHRepository.java
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,6 +2102,16 @@ public GHCommitQueryBuilder queryCommits() {
21022102
return new GHCommitQueryBuilder(this);
21032103
}
21042104

2105+
2106+
/**
2107+
* List releases with pagination through a builder pattern.
2108+
*
2109+
* @return the gh release query builder
2110+
*/
2111+
public GHReleaseQueryBuilder queryReleases() {
2112+
return new GHReleaseQueryBuilder(this);
2113+
}
2114+
21052115
/**
21062116
* Lists up all the commit comments in this repository.
21072117
*

0 commit comments

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