Skip to content

Commit 392dc2a

Browse files
committed
Merge remote-tracking branch 'github-api/master' into BranchMissing
2 parents 78ab5ad + da11702 commit 392dc2a

File tree

72 files changed

+1126
-489
lines changed

Some content is hidden

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

72 files changed

+1126
-489
lines changed

pom.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@
175175
<goals>
176176
<goal>${formatter-maven-plugin.goal}</goal>
177177
</goals>
178+
<configuration>
179+
<configFile>src/main/resources/eclipse/formatter.xml</configFile>
180+
</configuration>
178181
</execution>
179182
</executions>
180183
</plugin>

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

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,9 @@ GHApp wrapUp(GitHub root) {
183183
@Preview
184184
@Deprecated
185185
public PagedIterable<GHAppInstallation> listInstallations() {
186-
return root.retrieve().withPreview(MACHINE_MAN).asPagedIterable("/app/installations", GHAppInstallation[].class,
187-
item -> item.wrapUp(root));
186+
return root.retrieve()
187+
.withPreview(MACHINE_MAN)
188+
.asPagedIterable("/app/installations", GHAppInstallation[].class, item -> item.wrapUp(root));
188189
}
189190

190191
/**
@@ -202,8 +203,10 @@ public PagedIterable<GHAppInstallation> listInstallations() {
202203
@Preview
203204
@Deprecated
204205
public GHAppInstallation getInstallationById(long id) throws IOException {
205-
return root.retrieve().withPreview(MACHINE_MAN)
206-
.to(String.format("/app/installations/%d", id), GHAppInstallation.class).wrapUp(root);
206+
return root.retrieve()
207+
.withPreview(MACHINE_MAN)
208+
.to(String.format("/app/installations/%d", id), GHAppInstallation.class)
209+
.wrapUp(root);
207210
}
208211

209212
/**
@@ -222,8 +225,10 @@ public GHAppInstallation getInstallationById(long id) throws IOException {
222225
@Preview
223226
@Deprecated
224227
public GHAppInstallation getInstallationByOrganization(String name) throws IOException {
225-
return root.retrieve().withPreview(MACHINE_MAN)
226-
.to(String.format("/orgs/%s/installation", name), GHAppInstallation.class).wrapUp(root);
228+
return root.retrieve()
229+
.withPreview(MACHINE_MAN)
230+
.to(String.format("/orgs/%s/installation", name), GHAppInstallation.class)
231+
.wrapUp(root);
227232
}
228233

229234
/**
@@ -244,7 +249,8 @@ public GHAppInstallation getInstallationByOrganization(String name) throws IOExc
244249
@Preview
245250
@Deprecated
246251
public GHAppInstallation getInstallationByRepository(String ownerName, String repositoryName) throws IOException {
247-
return root.retrieve().withPreview(MACHINE_MAN)
252+
return root.retrieve()
253+
.withPreview(MACHINE_MAN)
248254
.to(String.format("/repos/%s/%s/installation", ownerName, repositoryName), GHAppInstallation.class)
249255
.wrapUp(root);
250256
}
@@ -264,8 +270,10 @@ public GHAppInstallation getInstallationByRepository(String ownerName, String re
264270
@Preview
265271
@Deprecated
266272
public GHAppInstallation getInstallationByUser(String name) throws IOException {
267-
return root.retrieve().withPreview(MACHINE_MAN)
268-
.to(String.format("/users/%s/installation", name), GHAppInstallation.class).wrapUp(root);
273+
return root.retrieve()
274+
.withPreview(MACHINE_MAN)
275+
.to(String.format("/users/%s/installation", name), GHAppInstallation.class)
276+
.wrapUp(root);
269277
}
270278

271279
}

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.kohsuke.github;
22

33
import java.io.IOException;
4+
import java.util.HashMap;
45
import java.util.List;
56
import java.util.Map;
67

@@ -23,7 +24,7 @@ public class GHAppCreateTokenBuilder {
2324
this.root = root;
2425
this.apiUrlTail = apiUrlTail;
2526
this.builder = new Requester(root);
26-
this.builder.withPermissions("permissions", permissions);
27+
withPermissions(builder, permissions);
2728
}
2829

2930
/**
@@ -58,4 +59,12 @@ public GHAppInstallationToken create() throws IOException {
5859
.wrapUp(root);
5960
}
6061

62+
private static Requester withPermissions(Requester builder, Map<String, GHPermissionType> value) {
63+
Map<String, String> retMap = new HashMap<String, String>();
64+
for (Map.Entry<String, GHPermissionType> entry : value.entrySet()) {
65+
retMap.put(entry.getKey(), Requester.transformEnum(entry.getValue()));
66+
}
67+
return builder.with("permissions", retMap);
68+
}
69+
6170
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public String getBrowserDownloadUrl() {
135135
}
136136

137137
private void edit(String key, Object value) throws IOException {
138-
new Requester(root)._with(key, value).method("PATCH").to(getApiRoute());
138+
new Requester(root).with(key, value).method("PATCH").to(getApiRoute());
139139
}
140140

141141
/**

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ GHAuthorization wrap(GitHub root) {
158158
return this;
159159
}
160160

161-
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD",
162-
"UWF_UNWRITTEN_FIELD" }, justification = "JSON API")
161+
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD" },
162+
justification = "JSON API")
163163
private static class App {
164164
private String url;
165165
private String name;

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
*
1717
* @author Yusuke Kokubo
1818
*/
19-
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
20-
"URF_UNREAD_FIELD" }, justification = "JSON API")
19+
@SuppressFBWarnings(
20+
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
21+
"URF_UNREAD_FIELD" },
22+
justification = "JSON API")
2123
public class GHBranch {
2224
private GitHub root;
2325
private GHRepository owner;
@@ -149,13 +151,15 @@ public GHBranchProtectionBuilder enableProtection() {
149151
@Deprecated
150152
public void enableProtection(EnforcementLevel level, Collection<String> contexts) throws IOException {
151153
switch (level) {
152-
case OFF:
153-
disableProtection();
154-
break;
155-
case NON_ADMINS:
156-
case EVERYONE:
157-
enableProtection().addRequiredChecks(contexts).includeAdmins(level == EnforcementLevel.EVERYONE).enable();
158-
break;
154+
case OFF :
155+
disableProtection();
156+
break;
157+
case NON_ADMINS :
158+
case EVERYONE :
159+
enableProtection().addRequiredChecks(contexts)
160+
.includeAdmins(level == EnforcementLevel.EVERYONE)
161+
.enable();
162+
break;
159163
}
160164
}
161165

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
/**
1212
* The type GHBranchProtection.
1313
*/
14-
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
15-
"URF_UNREAD_FIELD" }, justification = "JSON API")
14+
@SuppressFBWarnings(
15+
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
16+
"URF_UNREAD_FIELD" },
17+
justification = "JSON API")
1618
public class GHBranchProtection {
1719
private static final String REQUIRE_SIGNATURES_URI = "/required_signatures";
1820

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
*
2020
* @see GHBranch#enableProtection() GHBranch#enableProtection()
2121
*/
22-
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
23-
"URF_UNREAD_FIELD" }, justification = "JSON API")
22+
@SuppressFBWarnings(
23+
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
24+
"URF_UNREAD_FIELD" },
25+
justification = "JSON API")
2426
public class GHBranchProtectionBuilder {
2527
private final GHBranch branch;
2628

@@ -86,10 +88,13 @@ public GHBranchProtectionBuilder dismissStaleReviews(boolean v) {
8688
* the io exception
8789
*/
8890
public GHBranchProtection enable() throws IOException {
89-
return requester().method("PUT").withNullable("required_status_checks", statusChecks)
90-
.withNullable("required_pull_request_reviews", prReviews).withNullable("restrictions", restrictions)
91+
return requester().method("PUT")
92+
.withNullable("required_status_checks", statusChecks)
93+
.withNullable("required_pull_request_reviews", prReviews)
94+
.withNullable("restrictions", restrictions)
9195
.withNullable("enforce_admins", enforceAdmins)
92-
.to(branch.getProtectionUrl().toString(), GHBranchProtection.class).wrap(branch);
96+
.to(branch.getProtectionUrl().toString(), GHBranchProtection.class)
97+
.wrap(branch);
9398
}
9499

95100
/**

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ public class GHCommit {
2727
/**
2828
* Short summary of this commit.
2929
*/
30-
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD",
31-
"NP_UNWRITTEN_FIELD", "UWF_UNWRITTEN_FIELD" }, justification = "JSON API")
30+
@SuppressFBWarnings(
31+
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
32+
"UWF_UNWRITTEN_FIELD" },
33+
justification = "JSON API")
3234
public static class ShortInfo {
3335
private GHAuthor author;
3436
private GHAuthor committer;
@@ -167,7 +169,8 @@ public String getStatus() {
167169
*
168170
* @return Full path in the repository.
169171
*/
170-
@SuppressFBWarnings(value = "NM_CONFUSING", justification = "It's a part of the library's API and cannot be renamed")
172+
@SuppressFBWarnings(value = "NM_CONFUSING",
173+
justification = "It's a part of the library's API and cannot be renamed")
171174
public String getFileName() {
172175
return filename;
173176
}
@@ -344,7 +347,7 @@ public String getSHA1() {
344347
*/
345348
public List<File> getFiles() throws IOException {
346349
populate();
347-
return files != null ? Collections.unmodifiableList(files) : Collections.<File> emptyList();
350+
return files != null ? Collections.unmodifiableList(files) : Collections.<File>emptyList();
348351
}
349352

350353
/**
@@ -438,9 +441,11 @@ private GHUser resolveUser(User author) throws IOException {
438441
* @return {@link PagedIterable} with all the commit comments in this repository.
439442
*/
440443
public PagedIterable<GHCommitComment> listComments() {
441-
return owner.root.retrieve().asPagedIterable(
442-
String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha),
443-
GHCommitComment[].class, item -> item.wrap(owner));
444+
return owner.root.retrieve()
445+
.asPagedIterable(
446+
String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha),
447+
GHCommitComment[].class,
448+
item -> item.wrap(owner));
444449
}
445450

446451
/**
@@ -461,7 +466,9 @@ public PagedIterable<GHCommitComment> listComments() {
461466
* if comment is not created
462467
*/
463468
public GHCommitComment createComment(String body, String path, Integer line, Integer position) throws IOException {
464-
GHCommitComment r = new Requester(owner.root).with("body", body).with("path", path).with("line", line)
469+
GHCommitComment r = new Requester(owner.root).with("body", body)
470+
.with("path", path)
471+
.with("line", line)
465472
.with("position", position)
466473
.to(String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha),
467474
GHCommitComment.class);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public GHCommitBuilder parent(String parent) {
8585
* @return the gh commit builder
8686
*/
8787
public GHCommitBuilder author(String name, String email, Date date) {
88-
req._with("author", new UserInfo(name, email, date));
88+
req.with("author", new UserInfo(name, email, date));
8989
return this;
9090
}
9191

@@ -101,7 +101,7 @@ public GHCommitBuilder author(String name, String email, Date date) {
101101
* @return the gh commit builder
102102
*/
103103
public GHCommitBuilder committer(String name, String email, Date date) {
104-
req._with("committer", new UserInfo(name, email, date));
104+
req.with("committer", new UserInfo(name, email, date));
105105
return this;
106106
}
107107

@@ -117,7 +117,7 @@ private String getApiTail() {
117117
* the io exception
118118
*/
119119
public GHCommit create() throws IOException {
120-
req._with("parents", parents);
120+
req.with("parents", parents);
121121
return req.method("POST").to(getApiTail(), GHCommit.class).wrapUp(repo);
122122
}
123123
}

0 commit comments

Comments
 (0)