Merge remote-tracking branch 'github-api/master' into label-description

This commit is contained in:
Liam Newman
2019-10-04 21:44:06 -07:00
265 changed files with 313581 additions and 431 deletions

View File

@@ -24,6 +24,9 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.lang3.StringUtils;
@@ -51,10 +54,11 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.WeakHashMap;
import static java.util.Arrays.*;
import java.util.NoSuchElementException;
import java.util.logging.Level;
import java.util.logging.Logger;
import static java.util.Arrays.*;
import static org.kohsuke.github.Previews.*;
/**
@@ -1409,7 +1413,7 @@ public class GHRepository extends GHObject {
/**
* Replace special characters (e.g. #) with standard values (e.g. %23) so
* GitHub understands what is being requested.
* @param The string to be encoded.
* @param value string to be encoded.
* @return The encoded string.
*/
private String UrlEncode(String value) {
@@ -1651,6 +1655,53 @@ public class GHRepository extends GHObject {
}
}
/**
* Returns the statistics for this repository.
*/
public GHRepositoryStatistics getStatistics() {
// TODO: Use static object and introduce refresh() method,
// instead of returning new object each time.
return new GHRepositoryStatistics(this);
}
/**
* Create a project for this repository.
*/
public GHProject createProject(String name, String body) throws IOException {
return root.retrieve().method("POST")
.withPreview(INERTIA)
.with("name", name)
.with("body", body)
.to(getApiTailUrl("projects"), GHProject.class).wrap(this);
}
/**
* Returns the projects for this repository.
* @param status The status filter (all, open or closed).
*/
public PagedIterable<GHProject> listProjects(final GHProject.ProjectStateFilter status) throws IOException {
return new PagedIterable<GHProject>() {
public PagedIterator<GHProject> _iterator(int pageSize) {
return new PagedIterator<GHProject>(root.retrieve().withPreview(INERTIA)
.with("state", status)
.asIterator(getApiTailUrl("projects"), GHProject[].class, pageSize)) {
@Override
protected void wrapUp(GHProject[] page) {
for (GHProject c : page)
c.wrap(GHRepository.this);
}
};
}
};
}
/**
* Returns open projects for this repository.
*/
public PagedIterable<GHProject> listProjects() throws IOException {
return listProjects(GHProject.ProjectStateFilter.OPEN);
}
/**
* Render a Markdown document.
*