mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-13 15:50:09 +00:00
Compare commits
14 Commits
github-api
...
github-api
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1bab63ebd | ||
|
|
40f012b03c | ||
|
|
a380059389 | ||
|
|
24b998ba2d | ||
|
|
9a1bb09c9f | ||
|
|
3ad66f8937 | ||
|
|
a6f3e7df55 | ||
|
|
9345d3be31 | ||
|
|
8e85bf8839 | ||
|
|
1012dcd194 | ||
|
|
70251ea11e | ||
|
|
9381471fbd | ||
|
|
1c4b716f1a | ||
|
|
c8b0584127 |
7
pom.xml
7
pom.xml
@@ -3,11 +3,11 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.kohsuke</groupId>
|
<groupId>org.kohsuke</groupId>
|
||||||
<artifactId>pom</artifactId>
|
<artifactId>pom</artifactId>
|
||||||
<version>17</version>
|
<version>20</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>github-api</artifactId>
|
<artifactId>github-api</artifactId>
|
||||||
<version>1.94</version>
|
<version>1.95</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.94</tag>
|
<tag>github-api-1.95</tag>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
@@ -36,6 +36,7 @@
|
|||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>2.22.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<rerunFailingTestsCount>2</rerunFailingTestsCount>
|
<rerunFailingTestsCount>2</rerunFailingTestsCount>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
@@ -24,19 +24,21 @@
|
|||||||
|
|
||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import static org.kohsuke.github.Previews.SQUIRREL_GIRL;
|
||||||
|
|
||||||
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
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.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Set;
|
||||||
import static org.kohsuke.github.Previews.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an issue on GitHub.
|
* Represents an issue on GitHub.
|
||||||
@@ -216,6 +218,67 @@ public class GHIssue extends GHObject implements Reactable{
|
|||||||
editIssue("labels",labels);
|
editIssue("labels",labels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds labels to the issue.
|
||||||
|
*
|
||||||
|
* @param names Names of the label
|
||||||
|
*/
|
||||||
|
public void addLabels(String... names) throws IOException {
|
||||||
|
_addLabels(Arrays.asList(names));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addLabels(GHLabel... labels) throws IOException {
|
||||||
|
addLabels(Arrays.asList(labels));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addLabels(Collection<GHLabel> labels) throws IOException {
|
||||||
|
_addLabels(GHLabel.toNames(labels));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void _addLabels(Collection<String> names) throws IOException {
|
||||||
|
List<String> newLabels = new ArrayList<String>();
|
||||||
|
|
||||||
|
for (GHLabel label : getLabels()) {
|
||||||
|
newLabels.add(label.getName());
|
||||||
|
}
|
||||||
|
for (String name : names) {
|
||||||
|
if (!newLabels.contains(name)) {
|
||||||
|
newLabels.add(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setLabels(newLabels.toArray(new String[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a given label by name from this issue.
|
||||||
|
*/
|
||||||
|
public void removeLabels(String... names) throws IOException {
|
||||||
|
_removeLabels(Arrays.asList(names));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see #removeLabels(String...)
|
||||||
|
*/
|
||||||
|
public void removeLabels(GHLabel... labels) throws IOException {
|
||||||
|
removeLabels(Arrays.asList(labels));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeLabels(Collection<GHLabel> labels) throws IOException {
|
||||||
|
_removeLabels(GHLabel.toNames(labels));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void _removeLabels(Collection<String> names) throws IOException {
|
||||||
|
List<String> newLabels = new ArrayList<String>();
|
||||||
|
|
||||||
|
for (GHLabel l : getLabels()) {
|
||||||
|
if (!names.contains(l.getName())) {
|
||||||
|
newLabels.add(l.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setLabels(newLabels.toArray(new String[0]));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtains all the comments associated with this issue.
|
* Obtains all the comments associated with this issue.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Kohsuke Kawaguchi
|
* @author Kohsuke Kawaguchi
|
||||||
@@ -42,4 +45,12 @@ public class GHLabel {
|
|||||||
public void setColor(String newColor) throws IOException {
|
public void setColor(String newColor) throws IOException {
|
||||||
repo.root.retrieve().method("PATCH").with("name", name).with("color", newColor).to(url);
|
repo.root.retrieve().method("PATCH").with("name", name).with("color", newColor).to(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*package*/ static Collection<String> toNames(Collection<GHLabel> labels) {
|
||||||
|
List<String> r = new ArrayList<String>();
|
||||||
|
for (GHLabel l : labels) {
|
||||||
|
r.add(l.getName());
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import java.io.IOException;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -58,6 +59,9 @@ public class GHPullRequest extends GHIssue {
|
|||||||
private int changed_files;
|
private int changed_files;
|
||||||
private String merge_commit_sha;
|
private String merge_commit_sha;
|
||||||
|
|
||||||
|
// pull request reviewers
|
||||||
|
private GHUser[] requested_reviewers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GitHub doesn't return some properties of {@link GHIssue} when requesting the GET on the 'pulls' API
|
* GitHub doesn't return some properties of {@link GHIssue} when requesting the GET on the 'pulls' API
|
||||||
* route as opposed to 'issues' API route. This flag remembers whether we made the GET call on the 'issues' route
|
* route as opposed to 'issues' API route. This flag remembers whether we made the GET call on the 'issues' route
|
||||||
@@ -76,6 +80,7 @@ public class GHPullRequest extends GHIssue {
|
|||||||
if (base != null) base.wrapUp(root);
|
if (base != null) base.wrapUp(root);
|
||||||
if (head != null) head.wrapUp(root);
|
if (head != null) head.wrapUp(root);
|
||||||
if (merged_by != null) merged_by.wrapUp(root);
|
if (merged_by != null) merged_by.wrapUp(root);
|
||||||
|
if (requested_reviewers != null) GHUser.wrap(requested_reviewers, root);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,6 +224,11 @@ public class GHPullRequest extends GHIssue {
|
|||||||
return merge_commit_sha;
|
return merge_commit_sha;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<GHUser> getRequestedReviewers() throws IOException {
|
||||||
|
populate();
|
||||||
|
return Collections.unmodifiableList(Arrays.asList(requested_reviewers));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fully populate the data by retrieving missing data.
|
* Fully populate the data by retrieving missing data.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
import static java.util.Arrays.*;
|
import static java.util.Arrays.*;
|
||||||
import static org.kohsuke.github.Previews.*;
|
import static org.kohsuke.github.Previews.*;
|
||||||
@@ -74,15 +75,15 @@ public class GHRepository extends GHObject {
|
|||||||
|
|
||||||
private String git_url, ssh_url, clone_url, svn_url, mirror_url;
|
private String git_url, ssh_url, clone_url, svn_url, mirror_url;
|
||||||
private GHUser owner; // not fully populated. beware.
|
private GHUser owner; // not fully populated. beware.
|
||||||
private boolean has_issues, has_wiki, fork, has_downloads, has_pages;
|
private boolean has_issues, has_wiki, fork, has_downloads, has_pages, archived;
|
||||||
@JsonProperty("private")
|
@JsonProperty("private")
|
||||||
private boolean _private;
|
private boolean _private;
|
||||||
private int forks_count, stargazers_count, watchers_count, size, open_issues_count, subscribers_count;
|
private int forks_count, stargazers_count, watchers_count, size, open_issues_count, subscribers_count;
|
||||||
private String pushed_at;
|
private String pushed_at;
|
||||||
private Map<Integer,GHMilestone> milestones = new HashMap<Integer, GHMilestone>();
|
private Map<Integer,GHMilestone> milestones = new WeakHashMap<Integer, GHMilestone>();
|
||||||
|
|
||||||
private String default_branch,language;
|
private String default_branch,language;
|
||||||
private Map<String,GHCommit> commits = new HashMap<String, GHCommit>();
|
private Map<String,GHCommit> commits = new WeakHashMap<String, GHCommit>();
|
||||||
|
|
||||||
@SkipFromToString
|
@SkipFromToString
|
||||||
private GHRepoPermission permissions;
|
private GHRepoPermission permissions;
|
||||||
@@ -393,6 +394,10 @@ public class GHRepository extends GHObject {
|
|||||||
return fork;
|
return fork;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isArchived() {
|
||||||
|
return archived;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of all forks of this repository.
|
* Returns the number of all forks of this repository.
|
||||||
* This not only counts direct forks, but also forks of forks, and so on.
|
* This not only counts direct forks, but also forks of forks, and so on.
|
||||||
|
|||||||
@@ -14,17 +14,17 @@ public class UserTest extends AbstractGitHubApiTestBase {
|
|||||||
public void listFollowsAndFollowers() throws IOException {
|
public void listFollowsAndFollowers() throws IOException {
|
||||||
GHUser u = gitHub.getUser("rtyler");
|
GHUser u = gitHub.getUser("rtyler");
|
||||||
assertNotEquals(
|
assertNotEquals(
|
||||||
count50(u.listFollowers()),
|
count30(u.listFollowers()),
|
||||||
count50(u.listFollows()));
|
count30(u.listFollows()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<GHUser> count50(PagedIterable<GHUser> l) {
|
private Set<GHUser> count30(PagedIterable<GHUser> l) {
|
||||||
Set<GHUser> users = new HashSet<GHUser>();
|
Set<GHUser> users = new HashSet<GHUser>();
|
||||||
PagedIterator<GHUser> itr = l.iterator();
|
PagedIterator<GHUser> itr = l.iterator();
|
||||||
for (int i=0; i<50 && itr.hasNext(); i++) {
|
for (int i=0; i<30 && itr.hasNext(); i++) {
|
||||||
users.add(itr.next());
|
users.add(itr.next());
|
||||||
}
|
}
|
||||||
assertEquals(50, users.size());
|
assertEquals(30, users.size());
|
||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user