diff --git a/pom.xml b/pom.xml
index a0428a8a09..9d599f2ade 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,11 +3,11 @@
org.kohsuke
pom
- 17
+ 20
github-api
- 1.94
+ 1.95
GitHub API for Java
http://github-api.kohsuke.org/
GitHub API for Java
@@ -16,7 +16,7 @@
scm:git:git@github.com/kohsuke/${project.artifactId}.git
scm:git:ssh://git@github.com/kohsuke/${project.artifactId}.git
http://${project.artifactId}.kohsuke.org/
- github-api-1.94
+ github-api-1.95
@@ -36,6 +36,7 @@
maven-surefire-plugin
+ 2.22.1
2
diff --git a/src/main/java/org/kohsuke/github/GHIssue.java b/src/main/java/org/kohsuke/github/GHIssue.java
index f7cfd9245c..55cf54b81f 100644
--- a/src/main/java/org/kohsuke/github/GHIssue.java
+++ b/src/main/java/org/kohsuke/github/GHIssue.java
@@ -24,19 +24,21 @@
package org.kohsuke.github;
+import static org.kohsuke.github.Previews.SQUIRREL_GIRL;
+
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-
import java.io.IOException;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
+import java.util.HashSet;
import java.util.List;
import java.util.Locale;
-
-import static org.kohsuke.github.Previews.*;
+import java.util.Set;
/**
* Represents an issue on GitHub.
@@ -216,6 +218,67 @@ public void setLabels(String... labels) throws IOException {
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 labels) throws IOException {
+ _addLabels(GHLabel.toNames(labels));
+ }
+
+ private void _addLabels(Collection names) throws IOException {
+ List newLabels = new ArrayList();
+
+ 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 labels) throws IOException {
+ _removeLabels(GHLabel.toNames(labels));
+ }
+
+ private void _removeLabels(Collection names) throws IOException {
+ List newLabels = new ArrayList();
+
+ 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.
*
diff --git a/src/main/java/org/kohsuke/github/GHLabel.java b/src/main/java/org/kohsuke/github/GHLabel.java
index 3792fdcca3..9210bb5f5c 100644
--- a/src/main/java/org/kohsuke/github/GHLabel.java
+++ b/src/main/java/org/kohsuke/github/GHLabel.java
@@ -1,6 +1,9 @@
package org.kohsuke.github;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
/**
* @author Kohsuke Kawaguchi
@@ -42,4 +45,12 @@ public void delete() throws IOException {
public void setColor(String newColor) throws IOException {
repo.root.retrieve().method("PATCH").with("name", name).with("color", newColor).to(url);
}
+
+ /*package*/ static Collection toNames(Collection labels) {
+ List r = new ArrayList();
+ for (GHLabel l : labels) {
+ r.add(l.getName());
+ }
+ return r;
+ }
}
diff --git a/src/main/java/org/kohsuke/github/GHPullRequest.java b/src/main/java/org/kohsuke/github/GHPullRequest.java
index 16c3f953c6..b4098829b9 100644
--- a/src/main/java/org/kohsuke/github/GHPullRequest.java
+++ b/src/main/java/org/kohsuke/github/GHPullRequest.java
@@ -28,6 +28,7 @@
import java.net.URL;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.Date;
import java.util.List;
@@ -58,6 +59,9 @@ public class GHPullRequest extends GHIssue {
private int changed_files;
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
* route as opposed to 'issues' API route. This flag remembers whether we made the GET call on the 'issues' route
@@ -76,6 +80,7 @@ GHPullRequest wrapUp(GitHub root) {
if (base != null) base.wrapUp(root);
if (head != null) head.wrapUp(root);
if (merged_by != null) merged_by.wrapUp(root);
+ if (requested_reviewers != null) GHUser.wrap(requested_reviewers, root);
return this;
}
@@ -219,6 +224,11 @@ public String getMergeCommitSha() throws IOException {
return merge_commit_sha;
}
+ public List getRequestedReviewers() throws IOException {
+ populate();
+ return Collections.unmodifiableList(Arrays.asList(requested_reviewers));
+ }
+
/**
* Fully populate the data by retrieving missing data.
*
diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java
index 2acc864123..a937836b27 100644
--- a/src/main/java/org/kohsuke/github/GHRepository.java
+++ b/src/main/java/org/kohsuke/github/GHRepository.java
@@ -48,6 +48,7 @@
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
+import java.util.WeakHashMap;
import static java.util.Arrays.*;
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 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")
private boolean _private;
private int forks_count, stargazers_count, watchers_count, size, open_issues_count, subscribers_count;
private String pushed_at;
- private Map milestones = new HashMap();
+ private Map milestones = new WeakHashMap();
private String default_branch,language;
- private Map commits = new HashMap();
+ private Map commits = new WeakHashMap();
@SkipFromToString
private GHRepoPermission permissions;
@@ -393,6 +394,10 @@ public boolean isFork() {
return fork;
}
+ public boolean isArchived() {
+ return archived;
+ }
+
/**
* Returns the number of all forks of this repository.
* This not only counts direct forks, but also forks of forks, and so on.
diff --git a/src/test/java/org/kohsuke/github/UserTest.java b/src/test/java/org/kohsuke/github/UserTest.java
index d35632fda2..9d1cfcbbac 100644
--- a/src/test/java/org/kohsuke/github/UserTest.java
+++ b/src/test/java/org/kohsuke/github/UserTest.java
@@ -14,17 +14,17 @@ public class UserTest extends AbstractGitHubApiTestBase {
public void listFollowsAndFollowers() throws IOException {
GHUser u = gitHub.getUser("rtyler");
assertNotEquals(
- count50(u.listFollowers()),
- count50(u.listFollows()));
+ count30(u.listFollowers()),
+ count30(u.listFollows()));
}
- private Set count50(PagedIterable l) {
+ private Set count30(PagedIterable l) {
Set users = new HashSet();
PagedIterator 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());
}
- assertEquals(50, users.size());
+ assertEquals(30, users.size());
return users;
}
}