mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-14 00:11:23 +00:00
Compare commits
8 Commits
github-api
...
github-api
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6516b20e16 | ||
|
|
839cb03690 | ||
|
|
2bcd99b14f | ||
|
|
e3ebf6e8a1 | ||
|
|
76d28314b0 | ||
|
|
ec450b8fd8 | ||
|
|
79c5b2edd5 | ||
|
|
2d45ac51ef |
10
pom.xml
10
pom.xml
@@ -7,7 +7,7 @@
|
|||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>github-api</artifactId>
|
<artifactId>github-api</artifactId>
|
||||||
<version>1.69</version>
|
<version>1.70</version>
|
||||||
<name>GitHub API for Java</name>
|
<name>GitHub API for Java</name>
|
||||||
<url>http://github-api.kohsuke.org/</url>
|
<url>http://github-api.kohsuke.org/</url>
|
||||||
<description>GitHub API for Java</description>
|
<description>GitHub API for Java</description>
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
<connection>scm:git:git@github.com/kohsuke/${project.artifactId}.git</connection>
|
<connection>scm:git:git@github.com/kohsuke/${project.artifactId}.git</connection>
|
||||||
<developerConnection>scm:git:ssh://git@github.com/kohsuke/${project.artifactId}.git</developerConnection>
|
<developerConnection>scm:git:ssh://git@github.com/kohsuke/${project.artifactId}.git</developerConnection>
|
||||||
<url>http://${project.artifactId}.kohsuke.org/</url>
|
<url>http://${project.artifactId}.kohsuke.org/</url>
|
||||||
<tag>github-api-1.69</tag>
|
<tag>github-api-1.70</tag>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
@@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<findbugs-maven-plugin.version>3.0.1</findbugs-maven-plugin.version>
|
||||||
|
<findbugs-maven-plugin.failOnError>true</findbugs-maven-plugin.failOnError>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@@ -47,11 +49,11 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>findbugs-maven-plugin</artifactId>
|
<artifactId>findbugs-maven-plugin</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>${findbugs-maven-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<xmlOutput>true</xmlOutput>
|
<xmlOutput>true</xmlOutput>
|
||||||
<findbugsXmlWithMessages>true</findbugsXmlWithMessages>
|
<findbugsXmlWithMessages>true</findbugsXmlWithMessages>
|
||||||
<failOnError>false</failOnError>
|
<failOnError>${findbugs-maven-plugin.failOnError}</failOnError>
|
||||||
</configuration>
|
</configuration>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
|
|||||||
@@ -23,9 +23,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Kohsuke Kawaguchi
|
* @author Kohsuke Kawaguchi
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings(value = "UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD",
|
||||||
|
justification = "Being constructed by JSON deserialization")
|
||||||
class DeleteToken {
|
class DeleteToken {
|
||||||
public String delete_token;
|
public String delete_token;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -59,6 +60,8 @@ public class GHAuthorization extends GHObject {
|
|||||||
return app.name;
|
return app.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressFBWarnings(value = "NM_CONFUSING",
|
||||||
|
justification = "It's a part of the library API, cannot be changed")
|
||||||
public URL getApiURL() {
|
public URL getApiURL() {
|
||||||
return GitHub.parseURL(url);
|
return GitHub.parseURL(url);
|
||||||
}
|
}
|
||||||
@@ -84,7 +87,8 @@ public class GHAuthorization extends GHObject {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD"},
|
||||||
|
justification = "JSON API")
|
||||||
private static class App {
|
private static class App {
|
||||||
private String url;
|
private String url;
|
||||||
private String name;
|
private String name;
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A branch in a repository.
|
* A branch in a repository.
|
||||||
*
|
*
|
||||||
* @author Yusuke Kokubo
|
* @author Yusuke Kokubo
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD",
|
||||||
|
"NP_UNWRITTEN_FIELD"}, justification = "JSON API")
|
||||||
public class GHBranch {
|
public class GHBranch {
|
||||||
private GitHub root;
|
private GitHub root;
|
||||||
private GHRepository owner;
|
private GHRepository owner;
|
||||||
@@ -13,7 +17,10 @@ public class GHBranch {
|
|||||||
private Commit commit;
|
private Commit commit;
|
||||||
|
|
||||||
public static class Commit {
|
public static class Commit {
|
||||||
String sha,url;
|
String sha;
|
||||||
|
|
||||||
|
@SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
|
||||||
|
String url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GitHub getRoot() {
|
public GitHub getRoot() {
|
||||||
@@ -37,7 +44,7 @@ public class GHBranch {
|
|||||||
public String getSHA1() {
|
public String getSHA1() {
|
||||||
return commit.sha;
|
return commit.sha;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final String url = owner != null ? owner.getUrl().toString() : "unknown";
|
final String url = owner != null ? owner.getUrl().toString() : "unknown";
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@@ -16,6 +17,8 @@ import java.util.List;
|
|||||||
* @see GHRepository#getCommit(String)
|
* @see GHRepository#getCommit(String)
|
||||||
* @see GHCommitComment#getCommit()
|
* @see GHCommitComment#getCommit()
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings(value = {"NP_UNWRITTEN_FIELD", "UWF_UNWRITTEN_FIELD"},
|
||||||
|
justification = "JSON API")
|
||||||
public class GHCommit {
|
public class GHCommit {
|
||||||
private GHRepository owner;
|
private GHRepository owner;
|
||||||
|
|
||||||
@@ -24,6 +27,8 @@ public class GHCommit {
|
|||||||
/**
|
/**
|
||||||
* Short summary of this commit.
|
* 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")
|
||||||
public static class ShortInfo {
|
public static class ShortInfo {
|
||||||
private GHAuthor author;
|
private GHAuthor author;
|
||||||
private GHAuthor committer;
|
private GHAuthor committer;
|
||||||
@@ -67,6 +72,8 @@ public class GHCommit {
|
|||||||
/**
|
/**
|
||||||
* A file that was modified.
|
* A file that was modified.
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD",
|
||||||
|
justification = "It's being initilized by JSON deserialization")
|
||||||
public static class File {
|
public static class File {
|
||||||
String status;
|
String status;
|
||||||
int changes,additions,deletions;
|
int changes,additions,deletions;
|
||||||
@@ -104,6 +111,8 @@ public class GHCommit {
|
|||||||
/**
|
/**
|
||||||
* Full path in the repository.
|
* Full path in the repository.
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings(value = "NM_CONFUSING",
|
||||||
|
justification = "It's a part of the library's API and cannot be renamed")
|
||||||
public String getFileName() {
|
public String getFileName() {
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
@@ -147,13 +156,19 @@ public class GHCommit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class Parent {
|
public static class Parent {
|
||||||
String url,sha;
|
@SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
|
||||||
|
String url;
|
||||||
|
String sha;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class User {
|
static class User {
|
||||||
// TODO: what if someone who doesn't have an account on GitHub makes a commit?
|
// TODO: what if someone who doesn't have an account on GitHub makes a commit?
|
||||||
String url,avatar_url,login,gravatar_id;
|
@SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
|
||||||
|
String url,avatar_url,gravatar_id;
|
||||||
|
@SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
|
String login;
|
||||||
}
|
}
|
||||||
|
|
||||||
String url,sha;
|
String url,sha;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -12,6 +13,8 @@ import java.util.Date;
|
|||||||
* @see GHCommit#listComments()
|
* @see GHCommit#listComments()
|
||||||
* @see GHCommit#createComment(String, String, Integer, Integer)
|
* @see GHCommit#createComment(String, String, Integer, Integer)
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD",
|
||||||
|
"NP_UNWRITTEN_FIELD"}, justification = "JSON API")
|
||||||
public class GHCommitComment extends GHObject {
|
public class GHCommitComment extends GHObject {
|
||||||
private GHRepository owner;
|
private GHRepository owner;
|
||||||
|
|
||||||
@@ -22,8 +25,12 @@ public class GHCommitComment extends GHObject {
|
|||||||
|
|
||||||
static class User {
|
static class User {
|
||||||
// TODO: what if someone who doesn't have an account on GitHub makes a commit?
|
// TODO: what if someone who doesn't have an account on GitHub makes a commit?
|
||||||
String url,avatar_url,login,gravatar_id;
|
@SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
|
||||||
|
String url,avatar_url,gravatar_id;
|
||||||
|
@SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
|
String login;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GHRepository getOwner() {
|
public GHRepository getOwner() {
|
||||||
@@ -83,7 +90,7 @@ public class GHCommitComment extends GHObject {
|
|||||||
* Updates the body of the commit message.
|
* Updates the body of the commit message.
|
||||||
*/
|
*/
|
||||||
public void update(String body) throws IOException {
|
public void update(String body) throws IOException {
|
||||||
GHCommitComment r = new Requester(owner.root)
|
new Requester(owner.root)
|
||||||
.with("body", body)
|
.with("body", body)
|
||||||
.method("PATCH").to(getApiTail(), GHCommitComment.class);
|
.method("PATCH").to(getApiTail(), GHCommitComment.class);
|
||||||
this.body = body;
|
this.body = body;
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,12 +67,20 @@ public class GHCompare {
|
|||||||
return merge_base_commit;
|
return merge_base_commit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets an array of commits.
|
||||||
|
* @return A copy of the array being stored in the class.
|
||||||
|
*/
|
||||||
public Commit[] getCommits() {
|
public Commit[] getCommits() {
|
||||||
return commits;
|
return Arrays.copyOf(commits, commits.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets an array of commits.
|
||||||
|
* @return A copy of the array being stored in the class.
|
||||||
|
*/
|
||||||
public GHCommit.File[] getFiles() {
|
public GHCommit.File[] getFiles() {
|
||||||
return files;
|
return Arrays.copyOf(files, files.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GHCompare wrap(GHRepository owner) {
|
public GHCompare wrap(GHRepository owner) {
|
||||||
@@ -87,6 +97,8 @@ public class GHCompare {
|
|||||||
* Compare commits had a child commit element with additional details we want to capture.
|
* Compare commits had a child commit element with additional details we want to capture.
|
||||||
* This extenstion of GHCommit provides that.
|
* This extenstion of GHCommit provides that.
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD"},
|
||||||
|
justification = "JSON API")
|
||||||
public static class Commit extends GHCommit {
|
public static class Commit extends GHCommit {
|
||||||
|
|
||||||
private InnerCommit commit;
|
private InnerCommit commit;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
@@ -75,6 +76,7 @@ public class GHContent {
|
|||||||
* @deprecated
|
* @deprecated
|
||||||
* Use {@link #read()}
|
* Use {@link #read()}
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings("DM_DEFAULT_ENCODING")
|
||||||
public String getContent() throws IOException {
|
public String getContent() throws IOException {
|
||||||
return new String(DatatypeConverter.parseBase64Binary(getEncodedContent()));
|
return new String(DatatypeConverter.parseBase64Binary(getEncodedContent()));
|
||||||
}
|
}
|
||||||
@@ -161,10 +163,12 @@ public class GHContent {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressFBWarnings("DM_DEFAULT_ENCODING")
|
||||||
public GHContentUpdateResponse update(String newContent, String commitMessage) throws IOException {
|
public GHContentUpdateResponse update(String newContent, String commitMessage) throws IOException {
|
||||||
return update(newContent.getBytes(), commitMessage, null);
|
return update(newContent.getBytes(), commitMessage, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressFBWarnings("DM_DEFAULT_ENCODING")
|
||||||
public GHContentUpdateResponse update(String newContent, String commitMessage, String branch) throws IOException {
|
public GHContentUpdateResponse update(String newContent, String commitMessage, String branch) throws IOException {
|
||||||
return update(newContent.getBytes(), commitMessage, branch);
|
return update(newContent.getBytes(), commitMessage, branch);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class GHDeploymentStatus extends GHObject {
|
public class GHDeploymentStatus extends GHObject {
|
||||||
private GHRepository owner;
|
private GHRepository owner;
|
||||||
@@ -28,8 +29,9 @@ public class GHDeploymentStatus extends GHObject {
|
|||||||
public URL getRepositoryUrl() {
|
public URL getRepositoryUrl() {
|
||||||
return GitHub.parseURL(repository_url);
|
return GitHub.parseURL(repository_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GHDeploymentState getState() {
|
public GHDeploymentState getState() {
|
||||||
return GHDeploymentState.valueOf(state.toUpperCase());
|
return GHDeploymentState.valueOf(state.toUpperCase(Locale.ENGLISH));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class GHDeploymentStatusBuilder {
|
public class GHDeploymentStatusBuilder {
|
||||||
private final Requester builder;
|
private final Requester builder;
|
||||||
@@ -11,7 +12,7 @@ public class GHDeploymentStatusBuilder {
|
|||||||
this.repo = repo;
|
this.repo = repo;
|
||||||
this.deploymentId = deploymentId;
|
this.deploymentId = deploymentId;
|
||||||
this.builder = new Requester(repo.root);
|
this.builder = new Requester(repo.root);
|
||||||
this.builder.with("state",state.toString().toLowerCase());
|
this.builder.with("state",state.toString().toLowerCase(Locale.ENGLISH));
|
||||||
}
|
}
|
||||||
|
|
||||||
public GHDeploymentStatusBuilder description(String description) {
|
public GHDeploymentStatusBuilder description(String description) {
|
||||||
|
|||||||
@@ -23,12 +23,16 @@
|
|||||||
*/
|
*/
|
||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an email of GitHub.
|
* Represents an email of GitHub.
|
||||||
*
|
*
|
||||||
* @author Kelly Campbell
|
* @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")
|
||||||
public class GHEmail {
|
public class GHEmail {
|
||||||
|
|
||||||
protected String email;
|
protected String email;
|
||||||
|
|||||||
@@ -4,12 +4,14 @@ import java.io.IOException;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an event.
|
* Represents an event.
|
||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
* @author Kohsuke Kawaguchi
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON API")
|
||||||
public class GHEventInfo {
|
public class GHEventInfo {
|
||||||
private GitHub root;
|
private GitHub root;
|
||||||
|
|
||||||
@@ -27,8 +29,12 @@ public class GHEventInfo {
|
|||||||
/**
|
/**
|
||||||
* Inside the event JSON model, GitHub uses a slightly different format.
|
* Inside the event JSON model, GitHub uses a slightly different format.
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD",
|
||||||
|
"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" }, justification = "JSON API")
|
||||||
public static class GHEventRepository {
|
public static class GHEventRepository {
|
||||||
|
@SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
|
||||||
private int id;
|
private int id;
|
||||||
|
@SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
|
||||||
private String url; // repository API URL
|
private String url; // repository API URL
|
||||||
private String name; // owner/repo
|
private String name; // owner/repo
|
||||||
}
|
}
|
||||||
@@ -55,10 +61,14 @@ public class GHEventInfo {
|
|||||||
/**
|
/**
|
||||||
* Repository where the change was made.
|
* Repository where the change was made.
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings(value = {"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" },
|
||||||
|
justification = "The field comes from JSON deserialization")
|
||||||
public GHRepository getRepository() throws IOException {
|
public GHRepository getRepository() throws IOException {
|
||||||
return root.getRepository(repo.name);
|
return root.getRepository(repo.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressFBWarnings(value = {"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" },
|
||||||
|
justification = "The field comes from JSON deserialization")
|
||||||
public GHUser getActor() throws IOException {
|
public GHUser getActor() throws IOException {
|
||||||
return root.getUser(actor.getLogin());
|
return root.getUser(actor.getLogin());
|
||||||
}
|
}
|
||||||
@@ -70,6 +80,8 @@ public class GHEventInfo {
|
|||||||
return actor.getLogin();
|
return actor.getLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressFBWarnings(value = {"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" },
|
||||||
|
justification = "The field comes from JSON deserialization")
|
||||||
public GHOrganization getOrganization() throws IOException {
|
public GHOrganization getOrganization() throws IOException {
|
||||||
return (org==null || org.getLogin()==null) ? null : root.getOrganization(org.getLogin());
|
return (org==null || org.getLogin()==null) ? null : root.getOrganization(org.getLogin());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -25,6 +26,8 @@ public abstract class GHEventPayload {
|
|||||||
*
|
*
|
||||||
* @see <a href="http://developer.github.com/v3/activity/events/types/#pullrequestevent">authoritative source</a>
|
* @see <a href="http://developer.github.com/v3/activity/events/types/#pullrequestevent">authoritative source</a>
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD",
|
||||||
|
"NP_UNWRITTEN_FIELD"}, justification = "JSON API")
|
||||||
public static class PullRequest extends GHEventPayload {
|
public static class PullRequest extends GHEventPayload {
|
||||||
private String action;
|
private String action;
|
||||||
private int number;
|
private int number;
|
||||||
@@ -67,12 +70,15 @@ public abstract class GHEventPayload {
|
|||||||
*
|
*
|
||||||
* @see <a href="http://developer.github.com/v3/activity/events/types/#issuecommentevent">authoritative source</a>
|
* @see <a href="http://developer.github.com/v3/activity/events/types/#issuecommentevent">authoritative source</a>
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings(value = {"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_UNWRITTEN_FIELD" },
|
||||||
|
justification = "Constructed by JSON deserialization")
|
||||||
public static class IssueComment extends GHEventPayload {
|
public static class IssueComment extends GHEventPayload {
|
||||||
private String action;
|
private String action;
|
||||||
private GHIssueComment comment;
|
private GHIssueComment comment;
|
||||||
private GHIssue issue;
|
private GHIssue issue;
|
||||||
private GHRepository repository;
|
private GHRepository repository;
|
||||||
|
|
||||||
|
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Comes from JSON deserialization")
|
||||||
public String getAction() {
|
public String getAction() {
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -11,6 +12,8 @@ import java.util.Map;
|
|||||||
/**
|
/**
|
||||||
* @author Kohsuke Kawaguchi
|
* @author Kohsuke Kawaguchi
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD",
|
||||||
|
"NP_UNWRITTEN_FIELD"}, justification = "JSON API")
|
||||||
public abstract class GHHook extends GHObject {
|
public abstract class GHHook extends GHObject {
|
||||||
String name;
|
String name;
|
||||||
List<String> events;
|
List<String> events;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@@ -269,6 +270,8 @@ public class GHIssue extends GHObject {
|
|||||||
return milestone;
|
return milestone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD"},
|
||||||
|
justification = "JSON API")
|
||||||
public static class PullRequest{
|
public static class PullRequest{
|
||||||
private String diff_url, patch_url, html_url;
|
private String diff_url, patch_url, html_url;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
import org.apache.commons.lang.builder.ToStringBuilder;
|
import org.apache.commons.lang.builder.ToStringBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -7,6 +8,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
|
|||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
* @author Kohsuke Kawaguchi
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON API")
|
||||||
public class GHKey {
|
public class GHKey {
|
||||||
/*package almost final*/ GitHub root;
|
/*package almost final*/ GitHub root;
|
||||||
|
|
||||||
@@ -33,6 +35,10 @@ public class GHKey {
|
|||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GitHub getRoot() {
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isVerified() {
|
public boolean isVerified() {
|
||||||
return verified;
|
return verified;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import java.util.Arrays;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
@@ -159,7 +160,7 @@ public class GHMyself extends GHUser {
|
|||||||
return new PagedIterable<GHRepository>() {
|
return new PagedIterable<GHRepository>() {
|
||||||
public PagedIterator<GHRepository> iterator() {
|
public PagedIterator<GHRepository> iterator() {
|
||||||
return new PagedIterator<GHRepository>(root.retrieve().asIterator("/user/repos?per_page=" + pageSize +
|
return new PagedIterator<GHRepository>(root.retrieve().asIterator("/user/repos?per_page=" + pageSize +
|
||||||
"&type=" + repoType.name().toLowerCase(), GHRepository[].class)) {
|
"&type=" + repoType.name().toLowerCase(Locale.ENGLISH), GHRepository[].class)) {
|
||||||
@Override
|
@Override
|
||||||
protected void wrapUp(GHRepository[] page) {
|
protected void wrapUp(GHRepository[] page) {
|
||||||
for (GHRepository c : page)
|
for (GHRepository c : page)
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ public class GHNotificationStream implements Iterable<GHThread> {
|
|||||||
while (true) {
|
while (true) {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
if (nextCheckTime < now) break;
|
if (nextCheckTime < now) break;
|
||||||
long waitTime = Math.max(Math.min(nextCheckTime - now, 1000), 60 * 1000);
|
long waitTime = Math.min(Math.max(nextCheckTime - now, 1000), 60 * 1000);
|
||||||
Thread.sleep(waitTime);
|
Thread.sleep(waitTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,7 +180,8 @@ public class GHNotificationStream implements Iterable<GHThread> {
|
|||||||
private long calcNextCheckTime() {
|
private long calcNextCheckTime() {
|
||||||
String v = req.getResponseHeader("X-Poll-Interval");
|
String v = req.getResponseHeader("X-Poll-Interval");
|
||||||
if (v==null) v="60";
|
if (v==null) v="60";
|
||||||
return System.currentTimeMillis()+Integer.parseInt(v)*1000;
|
long seconds = Integer.parseInt(v);
|
||||||
|
return System.currentTimeMillis() + seconds*1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove() {
|
public void remove() {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@@ -9,6 +10,8 @@ import java.util.Date;
|
|||||||
/**
|
/**
|
||||||
* Most (all?) domain objects in GitHub seems to have these 4 properties.
|
* Most (all?) domain objects in GitHub seems to have these 4 properties.
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD",
|
||||||
|
"NP_UNWRITTEN_FIELD"}, justification = "JSON API")
|
||||||
public abstract class GHObject {
|
public abstract class GHObject {
|
||||||
protected String url;
|
protected String url;
|
||||||
protected int id;
|
protected int id;
|
||||||
@@ -26,10 +29,6 @@ public abstract class GHObject {
|
|||||||
return GitHub.parseDate(created_at);
|
return GitHub.parseDate(created_at);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object createdAtStr(Date id, Class type) {
|
|
||||||
return created_at;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API URL of this object.
|
* API URL of this object.
|
||||||
*/
|
*/
|
||||||
@@ -58,12 +57,4 @@ public abstract class GHObject {
|
|||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object intToString(int id, Class type) {
|
|
||||||
return String.valueOf(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Object urlToString(URL url, Class type) {
|
|
||||||
return url==null ? null : url.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ public class GHOrganization extends GHPerson {
|
|||||||
* Creates a new team and assigns the repositories.
|
* Creates a new team and assigns the repositories.
|
||||||
*/
|
*/
|
||||||
public GHTeam createTeam(String name, Permission p, Collection<GHRepository> repositories) throws IOException {
|
public GHTeam createTeam(String name, Permission p, Collection<GHRepository> repositories) throws IOException {
|
||||||
Requester post = new Requester(root).with("name", name).with("permission", p.name().toLowerCase());
|
Requester post = new Requester(root).with("name", name).with("permission", p.name().toLowerCase(Locale.ENGLISH));
|
||||||
List<String> repo_names = new ArrayList<String>();
|
List<String> repo_names = new ArrayList<String>();
|
||||||
for (GHRepository r : repositories) {
|
for (GHRepository r : repositories) {
|
||||||
repo_names.add(r.getName());
|
repo_names.add(r.getName());
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import java.util.HashSet;
|
|||||||
* @author Kohsuke Kawaguchi
|
* @author Kohsuke Kawaguchi
|
||||||
*/
|
*/
|
||||||
public class GHPersonSet<T extends GHPerson> extends HashSet<T> {
|
public class GHPersonSet<T extends GHPerson> extends HashSet<T> {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public GHPersonSet() {
|
public GHPersonSet() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,10 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commit detail inside a {@link GHPullRequest}.
|
* Commit detail inside a {@link GHPullRequest}.
|
||||||
@@ -33,6 +35,8 @@ import java.net.URL;
|
|||||||
* @author Luca Milanesio
|
* @author Luca Milanesio
|
||||||
* @see GHPullRequest#listCommits()
|
* @see GHPullRequest#listCommits()
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD",
|
||||||
|
"NP_UNWRITTEN_FIELD", "URF_UNREAD_FIELD"}, justification = "JSON API")
|
||||||
public class GHPullRequestCommitDetail {
|
public class GHPullRequestCommitDetail {
|
||||||
private GHPullRequest owner;
|
private GHPullRequest owner;
|
||||||
|
|
||||||
@@ -88,6 +92,10 @@ public class GHPullRequestCommitDetail {
|
|||||||
public int getComment_count() {
|
public int getComment_count() {
|
||||||
return comment_count;
|
return comment_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Tree getTree() {
|
||||||
|
return tree;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class CommitPointer {
|
public static class CommitPointer {
|
||||||
@@ -136,6 +144,6 @@ public class GHPullRequestCommitDetail {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CommitPointer[] getParents() {
|
public CommitPointer[] getParents() {
|
||||||
return parents;
|
return Arrays.copyOf(parents, parents.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,6 +25,8 @@ public class GHRateLimit {
|
|||||||
/**
|
/**
|
||||||
* Non-epoch date
|
* Non-epoch date
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings(value = "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR",
|
||||||
|
justification = "The value comes from JSON deserialization")
|
||||||
public Date getResetDate() {
|
public Date getResetDate() {
|
||||||
return new Date(reset.getTime() * 1000);
|
return new Date(reset.getTime() * 1000);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
@@ -77,7 +78,8 @@ public class GHRef {
|
|||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD",
|
||||||
|
"NP_UNWRITTEN_FIELD"}, justification = "JSON API")
|
||||||
public static class GHObject {
|
public static class GHObject {
|
||||||
private String type, sha, url;
|
private String type, sha, url;
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,12 @@ public class GHRelease extends GHObject {
|
|||||||
return draft;
|
return draft;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GHRelease setDraft(boolean draft) throws IOException {
|
||||||
|
edit("draft", draft);
|
||||||
|
this.draft = draft;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public URL getHtmlUrl() {
|
public URL getHtmlUrl() {
|
||||||
return GitHub.parseURL(html_url);
|
return GitHub.parseURL(html_url);
|
||||||
}
|
}
|
||||||
@@ -70,7 +76,7 @@ public class GHRelease extends GHObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Date getPublished_at() {
|
public Date getPublished_at() {
|
||||||
return published_at;
|
return new Date(published_at.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
public GitHub getRoot() {
|
public GitHub getRoot() {
|
||||||
@@ -123,9 +129,14 @@ public class GHRelease extends GHObject {
|
|||||||
|
|
||||||
String url = format("https://uploads.github.com%s/releases/%d/assets?name=%s",
|
String url = format("https://uploads.github.com%s/releases/%d/assets?name=%s",
|
||||||
owner.getApiTailUrl(""), getId(), file.getName());
|
owner.getApiTailUrl(""), getId(), file.getName());
|
||||||
return builder.contentType(contentType)
|
FileInputStream istream = new FileInputStream(file);
|
||||||
.with(new FileInputStream(file))
|
try {
|
||||||
|
return builder.contentType(contentType)
|
||||||
|
.with(istream)
|
||||||
.to(url, GHAsset.class).wrap(this);
|
.to(url, GHAsset.class).wrap(this);
|
||||||
|
} finally {
|
||||||
|
istream.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<GHAsset> getAssets() throws IOException {
|
public List<GHAsset> getAssets() throws IOException {
|
||||||
@@ -144,6 +155,13 @@ public class GHRelease extends GHObject {
|
|||||||
new Requester(root).method("DELETE").to(owner.getApiTailUrl("releases/"+id));
|
new Requester(root).method("DELETE").to(owner.getApiTailUrl("releases/"+id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edit this release.
|
||||||
|
*/
|
||||||
|
private void edit(String key, Object value) throws IOException {
|
||||||
|
new Requester(root)._with(key, value).method("PATCH").to(owner.getApiTailUrl("releases/"+id));
|
||||||
|
}
|
||||||
|
|
||||||
private String getApiTailUrl(String end) {
|
private String getApiTailUrl(String end) {
|
||||||
return owner.getApiTailUrl(format("releases/%s/%s",id,end));
|
return owner.getApiTailUrl(format("releases/%s/%s",id,end));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ package org.kohsuke.github;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
import javax.xml.bind.DatatypeConverter;
|
import javax.xml.bind.DatatypeConverter;
|
||||||
@@ -33,7 +34,9 @@ import java.io.IOException;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.InterruptedIOException;
|
import java.io.InterruptedIOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
@@ -44,6 +47,8 @@ import static java.util.Arrays.asList;
|
|||||||
* @author Kohsuke Kawaguchi
|
* @author Kohsuke Kawaguchi
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"UnusedDeclaration"})
|
@SuppressWarnings({"UnusedDeclaration"})
|
||||||
|
@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD",
|
||||||
|
"NP_UNWRITTEN_FIELD"}, justification = "JSON API")
|
||||||
public class GHRepository extends GHObject {
|
public class GHRepository extends GHObject {
|
||||||
/*package almost final*/ GitHub root;
|
/*package almost final*/ GitHub root;
|
||||||
|
|
||||||
@@ -217,7 +222,8 @@ public class GHRepository extends GHObject {
|
|||||||
public List<GHIssue> getIssues(GHIssueState state, GHMilestone milestone) throws IOException {
|
public List<GHIssue> getIssues(GHIssueState state, GHMilestone milestone) throws IOException {
|
||||||
return Arrays.asList(GHIssue.wrap(root.retrieve()
|
return Arrays.asList(GHIssue.wrap(root.retrieve()
|
||||||
.to(getApiTailUrl(String.format("issues?state=%s&milestone=%s",
|
.to(getApiTailUrl(String.format("issues?state=%s&milestone=%s",
|
||||||
state.toString().toLowerCase(), milestone == null ? "none" : "" + milestone.getNumber())),
|
state.toString().toLowerCase(Locale.ENGLISH),
|
||||||
|
milestone == null ? "none" : "" + milestone.getNumber())),
|
||||||
GHIssue[].class
|
GHIssue[].class
|
||||||
), this));
|
), this));
|
||||||
}
|
}
|
||||||
@@ -383,7 +389,8 @@ public class GHRepository extends GHObject {
|
|||||||
public int getSize() {
|
public int getSize() {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the collaborators on this repository.
|
* Gets the collaborators on this repository.
|
||||||
* This set always appear to include the owner.
|
* This set always appear to include the owner.
|
||||||
@@ -950,6 +957,8 @@ public class GHRepository extends GHObject {
|
|||||||
* @deprecated
|
* @deprecated
|
||||||
* Use {@link #getHooks()} and {@link #createHook(String, Map, Collection, boolean)}
|
* Use {@link #getHooks()} and {@link #createHook(String, Map, Collection, boolean)}
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings(value = "DMI_COLLECTION_OF_URLS",
|
||||||
|
justification = "It causes a performance degradation, but we have already exposed it to the API")
|
||||||
public Set<URL> getPostCommitHooks() {
|
public Set<URL> getPostCommitHooks() {
|
||||||
return postCommitHooks;
|
return postCommitHooks;
|
||||||
}
|
}
|
||||||
@@ -957,6 +966,8 @@ public class GHRepository extends GHObject {
|
|||||||
/**
|
/**
|
||||||
* Live set view of the post-commit hook.
|
* Live set view of the post-commit hook.
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings(value = "DMI_COLLECTION_OF_URLS",
|
||||||
|
justification = "It causes a performance degradation, but we have already exposed it to the API")
|
||||||
private final Set<URL> postCommitHooks = new AbstractSet<URL>() {
|
private final Set<URL> postCommitHooks = new AbstractSet<URL>() {
|
||||||
private List<URL> getPostCommitHooks() {
|
private List<URL> getPostCommitHooks() {
|
||||||
try {
|
try {
|
||||||
@@ -1101,11 +1112,17 @@ public class GHRepository extends GHObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public GHContentUpdateResponse createContent(String content, String commitMessage, String path) throws IOException {
|
public GHContentUpdateResponse createContent(String content, String commitMessage, String path) throws IOException {
|
||||||
return createContent(content.getBytes(), commitMessage, path, null);
|
return createContent(content, commitMessage, path, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GHContentUpdateResponse createContent(String content, String commitMessage, String path, String branch) throws IOException {
|
public GHContentUpdateResponse createContent(String content, String commitMessage, String path, String branch) throws IOException {
|
||||||
return createContent(content.getBytes(), commitMessage, path, branch);
|
final byte[] payload;
|
||||||
|
try {
|
||||||
|
payload = content.getBytes("UTF-8");
|
||||||
|
} catch (UnsupportedEncodingException ex) {
|
||||||
|
throw new IOException("UTF-8 encoding is not supported", ex);
|
||||||
|
}
|
||||||
|
return createContent(payload, commitMessage, path, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GHContentUpdateResponse createContent(byte[] contentBytes, String commitMessage, String path) throws IOException {
|
public GHContentUpdateResponse createContent(byte[] contentBytes, String commitMessage, String path) throws IOException {
|
||||||
@@ -1225,6 +1242,18 @@ public class GHRepository extends GHObject {
|
|||||||
public int getContributions() {
|
public int getContributions() {
|
||||||
return contributions;
|
return contributions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
// We ignore contributions in the calculation
|
||||||
|
return super.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
// We ignore contributions in the calculation
|
||||||
|
return super.equals(obj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a tag in {@link GHRepository}
|
* Represents a tag in {@link GHRepository}
|
||||||
*
|
*
|
||||||
* @see GHRepository#listTags()
|
* @see GHRepository#listTags()
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD",
|
||||||
|
"NP_UNWRITTEN_FIELD"}, justification = "JSON API")
|
||||||
public class GHTag {
|
public class GHTag {
|
||||||
private GHRepository owner;
|
private GHRepository owner;
|
||||||
private GitHub root;
|
private GitHub root;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@@ -12,6 +13,8 @@ import java.util.Date;
|
|||||||
* @see GHNotificationStream
|
* @see GHNotificationStream
|
||||||
* @author Kohsuke Kawaguchi
|
* @author Kohsuke Kawaguchi
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD",
|
||||||
|
"NP_UNWRITTEN_FIELD"}, justification = "JSON API")
|
||||||
public class GHThread extends GHObject {
|
public class GHThread extends GHObject {
|
||||||
private GitHub root;
|
private GitHub root;
|
||||||
private GHRepository repository;
|
private GHRepository repository;
|
||||||
@@ -67,6 +70,10 @@ public class GHThread extends GHObject {
|
|||||||
public String getType() {
|
public String getType() {
|
||||||
return subject.type;
|
return subject.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLastCommentUrl() {
|
||||||
|
return subject.latest_comment_url;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If this thread is about an issue, return that issue.
|
* If this thread is about an issue, return that issue.
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.introspect.VisibilityChecker.Std;
|
import com.fasterxml.jackson.databind.introspect.VisibilityChecker.Std;
|
||||||
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Root of the GitHub API.
|
* Root of the GitHub API.
|
||||||
@@ -128,7 +129,13 @@ public class GitHub {
|
|||||||
} else {
|
} else {
|
||||||
if (password!=null) {
|
if (password!=null) {
|
||||||
String authorization = (login + ':' + password);
|
String authorization = (login + ':' + password);
|
||||||
encodedAuthorization = "Basic "+new String(Base64.encodeBase64(authorization.getBytes()));
|
final Charset charset;
|
||||||
|
try {
|
||||||
|
charset = Charset.forName("UTF-8");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
throw new IOException("UTF-8 encoding is not supported", ex);
|
||||||
|
}
|
||||||
|
encodedAuthorization = "Basic "+new String(Base64.encodeBase64(authorization.getBytes(charset)), charset);
|
||||||
} else {// anonymous access
|
} else {// anonymous access
|
||||||
encodedAuthorization = null;
|
encodedAuthorization = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,6 +12,8 @@ import java.util.Date;
|
|||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
* @author Kohsuke Kawaguchi
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD",
|
||||||
|
"NP_UNWRITTEN_FIELD"}, justification = "JSON API")
|
||||||
public class GitUser {
|
public class GitUser {
|
||||||
private String name, email, date;
|
private String name, email, date;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -7,6 +8,8 @@ import java.util.Iterator;
|
|||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
* @author Kohsuke Kawaguchi
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD",
|
||||||
|
"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"}, justification = "Constructed by JSON API")
|
||||||
public abstract class PagedSearchIterable<T> extends PagedIterable<T> {
|
public abstract class PagedSearchIterable<T> extends PagedIterable<T> {
|
||||||
private final GitHub root;
|
private final GitHub root;
|
||||||
|
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ class Requester {
|
|||||||
|
|
||||||
public Requester with(String key, Integer value) {
|
public Requester with(String key, Integer value) {
|
||||||
if (value!=null)
|
if (value!=null)
|
||||||
_with(key, value.intValue());
|
_with(key, value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,23 +323,26 @@ class Requester {
|
|||||||
*
|
*
|
||||||
* Every iterator call reports a new batch.
|
* Every iterator call reports a new batch.
|
||||||
*/
|
*/
|
||||||
/*package*/ <T> Iterator<T> asIterator(String _tailApiUrl, final Class<T> type) {
|
/*package*/ <T> Iterator<T> asIterator(final String _tailApiUrl, final Class<T> type) {
|
||||||
method("GET");
|
method("GET");
|
||||||
|
|
||||||
|
final StringBuilder strBuilder = new StringBuilder(_tailApiUrl);
|
||||||
if (!args.isEmpty()) {
|
if (!args.isEmpty()) {
|
||||||
boolean first=true;
|
boolean first=true;
|
||||||
try {
|
try {
|
||||||
for (Entry a : args) {
|
for (Entry a : args) {
|
||||||
_tailApiUrl += first ? '?' : '&';
|
strBuilder.append(first ? '?' : '&');
|
||||||
first = false;
|
first = false;
|
||||||
_tailApiUrl += URLEncoder.encode(a.key,"UTF-8")+'='+URLEncoder.encode(a.value.toString(),"UTF-8");
|
strBuilder.append(URLEncoder.encode(a.key, "UTF-8"));
|
||||||
|
strBuilder.append('=');
|
||||||
|
strBuilder.append(URLEncoder.encode(a.value.toString(), "UTF-8"));
|
||||||
}
|
}
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
throw new AssertionError(e); // UTF-8 is mandatory
|
throw new AssertionError(e); // UTF-8 is mandatory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final String tailApiUrl = _tailApiUrl;
|
final String tailApiUrl = strBuilder.toString();
|
||||||
|
|
||||||
return new Iterator<T>() {
|
return new Iterator<T>() {
|
||||||
/**
|
/**
|
||||||
@@ -507,11 +510,4 @@ class Requester {
|
|||||||
IOUtils.closeQuietly(es);
|
IOUtils.closeQuietly(es);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> toSet(String s) {
|
|
||||||
Set<String> r = new HashSet<String>();
|
|
||||||
for (String t : s.split(","))
|
|
||||||
r.add(t.trim());
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,18 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the result of a search
|
* Represents the result of a search
|
||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
* @author Kohsuke Kawaguchi
|
||||||
*/
|
*/
|
||||||
|
|
||||||
abstract class SearchResult<T> {
|
abstract class SearchResult<T> {
|
||||||
|
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
|
||||||
int total_count;
|
int total_count;
|
||||||
|
|
||||||
|
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
|
||||||
boolean incomplete_results;
|
boolean incomplete_results;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user