Skip to content

Commit

Permalink
Merge remote-tracking branch 'github-api/master' into BranchMissing
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwiseman committed Nov 15, 2019
2 parents 78ab5ad + da11702 commit 392dc2a
Show file tree
Hide file tree
Showing 72 changed files with 1,126 additions and 489 deletions.
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@
<goals>
<goal>${formatter-maven-plugin.goal}</goal>
</goals>
<configuration>
<configFile>src/main/resources/eclipse/formatter.xml</configFile>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
26 changes: 17 additions & 9 deletions src/main/java/org/kohsuke/github/GHApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,9 @@ GHApp wrapUp(GitHub root) {
@Preview
@Deprecated
public PagedIterable<GHAppInstallation> listInstallations() {
return root.retrieve().withPreview(MACHINE_MAN).asPagedIterable("/app/installations", GHAppInstallation[].class,
item -> item.wrapUp(root));
return root.retrieve()
.withPreview(MACHINE_MAN)
.asPagedIterable("/app/installations", GHAppInstallation[].class, item -> item.wrapUp(root));
}

/**
Expand All @@ -202,8 +203,10 @@ public PagedIterable<GHAppInstallation> listInstallations() {
@Preview
@Deprecated
public GHAppInstallation getInstallationById(long id) throws IOException {
return root.retrieve().withPreview(MACHINE_MAN)
.to(String.format("/app/installations/%d", id), GHAppInstallation.class).wrapUp(root);
return root.retrieve()
.withPreview(MACHINE_MAN)
.to(String.format("/app/installations/%d", id), GHAppInstallation.class)
.wrapUp(root);
}

/**
Expand All @@ -222,8 +225,10 @@ public GHAppInstallation getInstallationById(long id) throws IOException {
@Preview
@Deprecated
public GHAppInstallation getInstallationByOrganization(String name) throws IOException {
return root.retrieve().withPreview(MACHINE_MAN)
.to(String.format("/orgs/%s/installation", name), GHAppInstallation.class).wrapUp(root);
return root.retrieve()
.withPreview(MACHINE_MAN)
.to(String.format("/orgs/%s/installation", name), GHAppInstallation.class)
.wrapUp(root);
}

/**
Expand All @@ -244,7 +249,8 @@ public GHAppInstallation getInstallationByOrganization(String name) throws IOExc
@Preview
@Deprecated
public GHAppInstallation getInstallationByRepository(String ownerName, String repositoryName) throws IOException {
return root.retrieve().withPreview(MACHINE_MAN)
return root.retrieve()
.withPreview(MACHINE_MAN)
.to(String.format("/repos/%s/%s/installation", ownerName, repositoryName), GHAppInstallation.class)
.wrapUp(root);
}
Expand All @@ -264,8 +270,10 @@ public GHAppInstallation getInstallationByRepository(String ownerName, String re
@Preview
@Deprecated
public GHAppInstallation getInstallationByUser(String name) throws IOException {
return root.retrieve().withPreview(MACHINE_MAN)
.to(String.format("/users/%s/installation", name), GHAppInstallation.class).wrapUp(root);
return root.retrieve()
.withPreview(MACHINE_MAN)
.to(String.format("/users/%s/installation", name), GHAppInstallation.class)
.wrapUp(root);
}

}
11 changes: 10 additions & 1 deletion src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.kohsuke.github;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand All @@ -23,7 +24,7 @@ public class GHAppCreateTokenBuilder {
this.root = root;
this.apiUrlTail = apiUrlTail;
this.builder = new Requester(root);
this.builder.withPermissions("permissions", permissions);
withPermissions(builder, permissions);
}

/**
Expand Down Expand Up @@ -58,4 +59,12 @@ public GHAppInstallationToken create() throws IOException {
.wrapUp(root);
}

private static Requester withPermissions(Requester builder, Map<String, GHPermissionType> value) {
Map<String, String> retMap = new HashMap<String, String>();
for (Map.Entry<String, GHPermissionType> entry : value.entrySet()) {
retMap.put(entry.getKey(), Requester.transformEnum(entry.getValue()));
}
return builder.with("permissions", retMap);
}

}
2 changes: 1 addition & 1 deletion src/main/java/org/kohsuke/github/GHAsset.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public String getBrowserDownloadUrl() {
}

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

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/kohsuke/github/GHAuthorization.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ GHAuthorization wrap(GitHub root) {
return this;
}

@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD",
"UWF_UNWRITTEN_FIELD" }, justification = "JSON API")
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD" },
justification = "JSON API")
private static class App {
private String url;
private String name;
Expand Down
22 changes: 13 additions & 9 deletions src/main/java/org/kohsuke/github/GHBranch.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
*
* @author Yusuke Kokubo
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
"URF_UNREAD_FIELD" }, justification = "JSON API")
@SuppressFBWarnings(
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
"URF_UNREAD_FIELD" },
justification = "JSON API")
public class GHBranch {
private GitHub root;
private GHRepository owner;
Expand Down Expand Up @@ -149,13 +151,15 @@ public GHBranchProtectionBuilder enableProtection() {
@Deprecated
public void enableProtection(EnforcementLevel level, Collection<String> contexts) throws IOException {
switch (level) {
case OFF:
disableProtection();
break;
case NON_ADMINS:
case EVERYONE:
enableProtection().addRequiredChecks(contexts).includeAdmins(level == EnforcementLevel.EVERYONE).enable();
break;
case OFF :
disableProtection();
break;
case NON_ADMINS :
case EVERYONE :
enableProtection().addRequiredChecks(contexts)
.includeAdmins(level == EnforcementLevel.EVERYONE)
.enable();
break;
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/kohsuke/github/GHBranchProtection.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
/**
* The type GHBranchProtection.
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
"URF_UNREAD_FIELD" }, justification = "JSON API")
@SuppressFBWarnings(
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
"URF_UNREAD_FIELD" },
justification = "JSON API")
public class GHBranchProtection {
private static final String REQUIRE_SIGNATURES_URI = "/required_signatures";

Expand Down
15 changes: 10 additions & 5 deletions src/main/java/org/kohsuke/github/GHBranchProtectionBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
*
* @see GHBranch#enableProtection() GHBranch#enableProtection()
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
"URF_UNREAD_FIELD" }, justification = "JSON API")
@SuppressFBWarnings(
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
"URF_UNREAD_FIELD" },
justification = "JSON API")
public class GHBranchProtectionBuilder {
private final GHBranch branch;

Expand Down Expand Up @@ -86,10 +88,13 @@ public GHBranchProtectionBuilder dismissStaleReviews(boolean v) {
* the io exception
*/
public GHBranchProtection enable() throws IOException {
return requester().method("PUT").withNullable("required_status_checks", statusChecks)
.withNullable("required_pull_request_reviews", prReviews).withNullable("restrictions", restrictions)
return requester().method("PUT")
.withNullable("required_status_checks", statusChecks)
.withNullable("required_pull_request_reviews", prReviews)
.withNullable("restrictions", restrictions)
.withNullable("enforce_admins", enforceAdmins)
.to(branch.getProtectionUrl().toString(), GHBranchProtection.class).wrap(branch);
.to(branch.getProtectionUrl().toString(), GHBranchProtection.class)
.wrap(branch);
}

/**
Expand Down
23 changes: 15 additions & 8 deletions src/main/java/org/kohsuke/github/GHCommit.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ public class GHCommit {
/**
* Short summary of this commit.
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD",
"NP_UNWRITTEN_FIELD", "UWF_UNWRITTEN_FIELD" }, justification = "JSON API")
@SuppressFBWarnings(
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
"UWF_UNWRITTEN_FIELD" },
justification = "JSON API")
public static class ShortInfo {
private GHAuthor author;
private GHAuthor committer;
Expand Down Expand Up @@ -167,7 +169,8 @@ public String getStatus() {
*
* @return Full path in the repository.
*/
@SuppressFBWarnings(value = "NM_CONFUSING", justification = "It's a part of the library's API and cannot be renamed")
@SuppressFBWarnings(value = "NM_CONFUSING",
justification = "It's a part of the library's API and cannot be renamed")
public String getFileName() {
return filename;
}
Expand Down Expand Up @@ -344,7 +347,7 @@ public String getSHA1() {
*/
public List<File> getFiles() throws IOException {
populate();
return files != null ? Collections.unmodifiableList(files) : Collections.<File> emptyList();
return files != null ? Collections.unmodifiableList(files) : Collections.<File>emptyList();
}

/**
Expand Down Expand Up @@ -438,9 +441,11 @@ private GHUser resolveUser(User author) throws IOException {
* @return {@link PagedIterable} with all the commit comments in this repository.
*/
public PagedIterable<GHCommitComment> listComments() {
return owner.root.retrieve().asPagedIterable(
String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha),
GHCommitComment[].class, item -> item.wrap(owner));
return owner.root.retrieve()
.asPagedIterable(
String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha),
GHCommitComment[].class,
item -> item.wrap(owner));
}

/**
Expand All @@ -461,7 +466,9 @@ public PagedIterable<GHCommitComment> listComments() {
* if comment is not created
*/
public GHCommitComment createComment(String body, String path, Integer line, Integer position) throws IOException {
GHCommitComment r = new Requester(owner.root).with("body", body).with("path", path).with("line", line)
GHCommitComment r = new Requester(owner.root).with("body", body)
.with("path", path)
.with("line", line)
.with("position", position)
.to(String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha),
GHCommitComment.class);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/kohsuke/github/GHCommitBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public GHCommitBuilder parent(String parent) {
* @return the gh commit builder
*/
public GHCommitBuilder author(String name, String email, Date date) {
req._with("author", new UserInfo(name, email, date));
req.with("author", new UserInfo(name, email, date));
return this;
}

Expand All @@ -101,7 +101,7 @@ public GHCommitBuilder author(String name, String email, Date date) {
* @return the gh commit builder
*/
public GHCommitBuilder committer(String name, String email, Date date) {
req._with("committer", new UserInfo(name, email, date));
req.with("committer", new UserInfo(name, email, date));
return this;
}

Expand All @@ -117,7 +117,7 @@ private String getApiTail() {
* the io exception
*/
public GHCommit create() throws IOException {
req._with("parents", parents);
req.with("parents", parents);
return req.method("POST").to(getApiTail(), GHCommit.class).wrapUp(repo);
}
}
15 changes: 9 additions & 6 deletions src/main/java/org/kohsuke/github/GHCommitComment.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* @see GHCommit#createComment(String, String, Integer, Integer) GHCommit#createComment(String, String, Integer,
* Integer)
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD",
"NP_UNWRITTEN_FIELD" }, justification = "JSON API")
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
justification = "JSON API")
public class GHCommitComment extends GHObject implements Reactable {
private GHRepository owner;

Expand Down Expand Up @@ -120,15 +120,18 @@ public void update(String body) throws IOException {
@Preview
@Deprecated
public GHReaction createReaction(ReactionContent content) throws IOException {
return new Requester(owner.root).withPreview(SQUIRREL_GIRL).with("content", content.getContent())
.to(getApiTail() + "/reactions", GHReaction.class).wrap(owner.root);
return new Requester(owner.root).withPreview(SQUIRREL_GIRL)
.with("content", content.getContent())
.to(getApiTail() + "/reactions", GHReaction.class)
.wrap(owner.root);
}

@Preview
@Deprecated
public PagedIterable<GHReaction> listReactions() {
return owner.root.retrieve().withPreview(SQUIRREL_GIRL).asPagedIterable(getApiTail() + "/reactions",
GHReaction[].class, item -> item.wrap(owner.root));
return owner.root.retrieve()
.withPreview(SQUIRREL_GIRL)
.asPagedIterable(getApiTail() + "/reactions", GHReaction[].class, item -> item.wrap(owner.root));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/kohsuke/github/GHCompare.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ public GHCompare wrap(GHRepository owner) {
* Compare commits had a child commit element with additional details we want to capture. This extenstion of
* GHCommit provides that.
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD",
"UWF_UNWRITTEN_FIELD" }, justification = "JSON API")
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD" },
justification = "JSON API")
public static class Commit extends GHCommit {

private InnerCommit commit;
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/org/kohsuke/github/GHContent.java
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,11 @@ public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessa
throws IOException {
String encodedContent = Base64.encodeBase64String(newContentBytes);

Requester requester = new Requester(root).with("path", path).with("message", commitMessage).with("sha", sha)
.with("content", encodedContent).method("PUT");
Requester requester = new Requester(root).with("path", path)
.with("message", commitMessage)
.with("sha", sha)
.with("content", encodedContent)
.method("PUT");

if (branch != null) {
requester.with("branch", branch);
Expand Down Expand Up @@ -347,7 +350,9 @@ public GHContentUpdateResponse delete(String message) throws IOException {
* the io exception
*/
public GHContentUpdateResponse delete(String commitMessage, String branch) throws IOException {
Requester requester = new Requester(root).with("path", path).with("message", commitMessage).with("sha", sha)
Requester requester = new Requester(root).with("path", path)
.with("message", commitMessage)
.with("sha", sha)
.method("DELETE");

if (branch != null) {
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/kohsuke/github/GHEmail.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
*
* @author Kelly Campbell
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
"NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD" }, justification = "JSON API")
@SuppressFBWarnings(
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
"NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD" },
justification = "JSON API")
public class GHEmail {

protected String email;
Expand Down
Loading

0 comments on commit 392dc2a

Please sign in to comment.