mirror of
https://github.com/jlengrand/github-api.git
synced 2026-04-04 08:21:23 +00:00
Merge remote-tracking branch 'github-api/master' into label-description
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user