Skip to content

Commit d61bc81

Browse files
authored
Merge branch 'main' into feat/1133
2 parents 336189e + dae92fc commit d61bc81

File tree

288 files changed

+5716
-2819
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

288 files changed

+5716
-2819
lines changed

pom.xml

Lines 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>github-api</artifactId>
5-
<version>1.133-SNAPSHOT</version>
5+
<version>1.134-SNAPSHOT</version>
66
<name>GitHub API for Java</name>
77
<url>https://github-api.kohsuke.org/</url>
88
<description>GitHub API for Java</description>

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

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,6 @@ public void setPermissions(Map<String, String> permissions) {
183183
throw new RuntimeException("Do not use this method.");
184184
}
185185

186-
GHApp wrapUp(GitHub root) {
187-
this.root = root;
188-
return this;
189-
}
190-
191186
/**
192187
* Obtains all the installations associated with this app.
193188
* <p>
@@ -198,10 +193,10 @@ GHApp wrapUp(GitHub root) {
198193
*/
199194
@Preview(MACHINE_MAN)
200195
public PagedIterable<GHAppInstallation> listInstallations() {
201-
return root.createRequest()
196+
return root().createRequest()
202197
.withPreview(MACHINE_MAN)
203198
.withUrlPath("/app/installations")
204-
.toIterable(GHAppInstallation[].class, item -> item.wrapUp(root));
199+
.toIterable(GHAppInstallation[].class, null);
205200
}
206201

207202
/**
@@ -218,11 +213,10 @@ public PagedIterable<GHAppInstallation> listInstallations() {
218213
*/
219214
@Preview(MACHINE_MAN)
220215
public GHAppInstallation getInstallationById(long id) throws IOException {
221-
return root.createRequest()
216+
return root().createRequest()
222217
.withPreview(MACHINE_MAN)
223218
.withUrlPath(String.format("/app/installations/%d", id))
224-
.fetch(GHAppInstallation.class)
225-
.wrapUp(root);
219+
.fetch(GHAppInstallation.class);
226220
}
227221

228222
/**
@@ -240,11 +234,10 @@ public GHAppInstallation getInstallationById(long id) throws IOException {
240234
*/
241235
@Preview(MACHINE_MAN)
242236
public GHAppInstallation getInstallationByOrganization(String name) throws IOException {
243-
return root.createRequest()
237+
return root().createRequest()
244238
.withPreview(MACHINE_MAN)
245239
.withUrlPath(String.format("/orgs/%s/installation", name))
246-
.fetch(GHAppInstallation.class)
247-
.wrapUp(root);
240+
.fetch(GHAppInstallation.class);
248241
}
249242

250243
/**
@@ -264,11 +257,10 @@ public GHAppInstallation getInstallationByOrganization(String name) throws IOExc
264257
*/
265258
@Preview(MACHINE_MAN)
266259
public GHAppInstallation getInstallationByRepository(String ownerName, String repositoryName) throws IOException {
267-
return root.createRequest()
260+
return root().createRequest()
268261
.withPreview(MACHINE_MAN)
269262
.withUrlPath(String.format("/repos/%s/%s/installation", ownerName, repositoryName))
270-
.fetch(GHAppInstallation.class)
271-
.wrapUp(root);
263+
.fetch(GHAppInstallation.class);
272264
}
273265

274266
/**
@@ -285,11 +277,10 @@ public GHAppInstallation getInstallationByRepository(String ownerName, String re
285277
*/
286278
@Preview(MACHINE_MAN)
287279
public GHAppInstallation getInstallationByUser(String name) throws IOException {
288-
return root.createRequest()
280+
return root().createRequest()
289281
.withPreview(MACHINE_MAN)
290282
.withUrlPath(String.format("/users/%s/installation", name))
291-
.fetch(GHAppInstallation.class)
292-
.wrapUp(root);
283+
.fetch(GHAppInstallation.class);
293284
}
294285

295286
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class GHAppCreateTokenBuilder extends GitHubInteractiveObject {
2020

2121
@BetaApi
2222
GHAppCreateTokenBuilder(GitHub root, String apiUrlTail) {
23-
this.root = root;
23+
super(root);
2424
this.apiUrlTail = apiUrlTail;
2525
this.builder = root.createRequest();
2626
}
@@ -78,8 +78,7 @@ public GHAppInstallationToken create() throws IOException {
7878
return builder.method("POST")
7979
.withPreview(MACHINE_MAN)
8080
.withUrlPath(apiUrlTail)
81-
.fetch(GHAppInstallationToken.class)
82-
.wrapUp(root);
81+
.fetch(GHAppInstallationToken.class);
8382
}
8483

8584
}

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

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,6 @@ public URL getHtmlUrl() {
5050
return GitHubClient.parseURL(htmlUrl);
5151
}
5252

53-
/**
54-
* Gets root.
55-
*
56-
* @return the root
57-
* @deprecated This method should be used internally only.
58-
*/
59-
@Deprecated
60-
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
61-
public GitHub getRoot() {
62-
return root;
63-
}
64-
6553
/**
6654
* Sets root.
6755
*
@@ -136,21 +124,19 @@ public PagedSearchIterable<GHRepository> listRepositories() {
136124
GitHubRequest request;
137125

138126
try {
139-
request = root.createRequest().withPreview(MACHINE_MAN).withUrlPath("/installation/repositories").build();
127+
request = root().createRequest().withPreview(MACHINE_MAN).withUrlPath("/installation/repositories").build();
140128
} catch (MalformedURLException e) {
141129
throw new GHException("", e);
142130
}
143131

144-
return new PagedSearchIterable<>(root, request, GHAppInstallationRepositoryResult.class);
132+
return new PagedSearchIterable<>(root(), request, GHAppInstallationRepositoryResult.class);
145133
}
146134

147135
private static class GHAppInstallationRepositoryResult extends SearchResult<GHRepository> {
148136
private GHRepository[] repositories;
149137

150138
@Override
151139
GHRepository[] getItems(GitHub root) {
152-
for (GHRepository item : repositories)
153-
item.wrap(root);
154140
return repositories;
155141
}
156142
}
@@ -316,11 +302,6 @@ public void setRepositorySelection(GHRepositorySelection repositorySelection) {
316302
throw new RuntimeException("Do not use this method.");
317303
}
318304

319-
GHAppInstallation wrapUp(GitHub root) {
320-
this.root = root;
321-
return this;
322-
}
323-
324305
/**
325306
* Delete a Github App installation
326307
* <p>
@@ -332,7 +313,7 @@ GHAppInstallation wrapUp(GitHub root) {
332313
*/
333314
@Preview(GAMBIT)
334315
public void deleteInstallation() throws IOException {
335-
root.createRequest()
316+
root().createRequest()
336317
.method("DELETE")
337318
.withPreview(GAMBIT)
338319
.withUrlPath(String.format("/app/installations/%d", getId()))
@@ -353,7 +334,7 @@ public void deleteInstallation() throws IOException {
353334
*/
354335
@BetaApi
355336
public GHAppCreateTokenBuilder createToken(Map<String, GHPermissionType> permissions) {
356-
return new GHAppCreateTokenBuilder(root,
337+
return new GHAppCreateTokenBuilder(root(),
357338
String.format("/app/installations/%d/access_tokens", getId()),
358339
permissions);
359340
}
@@ -369,6 +350,6 @@ public GHAppCreateTokenBuilder createToken(Map<String, GHPermissionType> permiss
369350
*/
370351
@BetaApi
371352
public GHAppCreateTokenBuilder createToken() {
372-
return new GHAppCreateTokenBuilder(root, String.format("/app/installations/%d/access_tokens", getId()));
353+
return new GHAppCreateTokenBuilder(root(), String.format("/app/installations/%d/access_tokens", getId()));
373354
}
374355
}

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,6 @@ public class GHAppInstallationToken extends GitHubInteractiveObject {
1919
private List<GHRepository> repositories;
2020
private GHRepositorySelection repositorySelection;
2121

22-
/**
23-
* Gets root.
24-
*
25-
* @return the root
26-
* @deprecated This method should be used internally only.
27-
*/
28-
@Deprecated
29-
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
30-
public GitHub getRoot() {
31-
return root;
32-
}
33-
3422
/**
3523
* Sets root.
3624
*
@@ -143,9 +131,4 @@ public Date getExpiresAt() throws IOException {
143131
private Object expiresAtStr(Date id, Class type) {
144132
return expires_at;
145133
}
146-
147-
GHAppInstallationToken wrapUp(GitHub root) {
148-
this.root = root;
149-
return this;
150-
}
151134
}

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public URL getHtmlUrl() throws IOException {
9999
* the io exception
100100
*/
101101
public void delete() throws IOException {
102-
root.createRequest().method("DELETE").withUrlPath(getApiRoute()).fetchHttpStatusCode();
102+
root().createRequest().method("DELETE").withUrlPath(getApiRoute()).fetchHttpStatusCode();
103103
}
104104

105105
/**
@@ -116,27 +116,21 @@ public void delete() throws IOException {
116116
public <T> T download(InputStreamFunction<T> streamFunction) throws IOException {
117117
requireNonNull(streamFunction, "Stream function must not be null");
118118

119-
return root.createRequest().method("GET").withUrlPath(getApiRoute(), "zip").fetchStream(streamFunction);
119+
return root().createRequest().method("GET").withUrlPath(getApiRoute(), "zip").fetchStream(streamFunction);
120120
}
121121

122122
private String getApiRoute() {
123123
if (owner == null) {
124124
// Workflow runs returned from search to do not have an owner. Attempt to use url.
125125
final URL url = Objects.requireNonNull(getUrl(), "Missing instance URL!");
126-
return StringUtils.prependIfMissing(url.toString().replace(root.getApiUrl(), ""), "/");
126+
return StringUtils.prependIfMissing(url.toString().replace(root().getApiUrl(), ""), "/");
127127
}
128128
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/actions/artifacts/" + getId();
129129
}
130130

131131
GHArtifact wrapUp(GHRepository owner) {
132132
this.owner = owner;
133-
return wrapUp(owner.root);
134-
}
135-
136-
GHArtifact wrapUp(GitHub root) {
137-
this.root = root;
138-
if (owner != null)
139-
owner.wrap(root);
140133
return this;
141134
}
135+
142136
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public GHArtifactsIterable(GHRepository owner, GitHubRequest.Builder<?> requestB
2727
@Override
2828
public PagedIterator<GHArtifact> _iterator(int pageSize) {
2929
return new PagedIterator<>(
30-
adapt(GitHubPageIterator.create(owner.getRoot().getClient(), GHArtifactsPage.class, request, pageSize)),
30+
adapt(GitHubPageIterator.create(owner.root().getClient(), GHArtifactsPage.class, request, pageSize)),
3131
null);
3232
}
3333

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

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,6 @@ public GHRepository getOwner() {
9292
return owner;
9393
}
9494

95-
/**
96-
* Gets root.
97-
*
98-
* @return the root
99-
* @deprecated This method should be used internally only.
100-
*/
101-
@Deprecated
102-
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
103-
public GitHub getRoot() {
104-
return root;
105-
}
106-
10795
/**
10896
* Gets size.
10997
*
@@ -140,7 +128,7 @@ public String getBrowserDownloadUrl() {
140128
}
141129

142130
private void edit(String key, Object value) throws IOException {
143-
root.createRequest().with(key, value).method("PATCH").withUrlPath(getApiRoute()).send();
131+
root().createRequest().with(key, value).method("PATCH").withUrlPath(getApiRoute()).send();
144132
}
145133

146134
/**
@@ -150,7 +138,7 @@ private void edit(String key, Object value) throws IOException {
150138
* the io exception
151139
*/
152140
public void delete() throws IOException {
153-
root.createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
141+
root().createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
154142
}
155143

156144
private String getApiRoute() {
@@ -159,7 +147,6 @@ private String getApiRoute() {
159147

160148
GHAsset wrap(GHRelease release) {
161149
this.owner = release.getOwner();
162-
this.root = owner.root;
163150
return this;
164151
}
165152

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,6 @@ public class GHAuthorization extends GHObject {
4545
// TODO add some user class for https://developer.github.com/v3/oauth_authorizations/#check-an-authorization ?
4646
// private GHUser user;
4747

48-
/**
49-
* Gets root.
50-
*
51-
* @return the root
52-
* @deprecated This method should be used internally only.
53-
*/
54-
@Deprecated
55-
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
56-
public GitHub getRoot() {
57-
return root;
58-
}
59-
6048
/**
6149
* Gets scopes.
6250
*
@@ -158,11 +146,6 @@ public String getFingerprint() {
158146
return fingerprint;
159147
}
160148

161-
GHAuthorization wrap(GitHub root) {
162-
this.root = root;
163-
return this;
164-
}
165-
166149
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD" },
167150
justification = "JSON API")
168151
private static class App {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class GHBlobBuilder {
1212

1313
GHBlobBuilder(GHRepository repo) {
1414
this.repo = repo;
15-
req = repo.root.createRequest();
15+
req = repo.root().createRequest();
1616
}
1717

1818
/**

0 commit comments

Comments
 (0)