getLabels() throws IOException {
if(labels == null){
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
return Collections.unmodifiableList(labels);
}
@@ -237,7 +225,15 @@ public GHUser getAssignee() {
public GHUser getUser() {
return user;
}
-
+
+ /**
+ * Reports who has closed the issue.
+ *
+ *
+ * Note that GitHub doesn't always seem to report this information
+ * even for an issue that's already closed. See
+ * https://github.com/kohsuke/github-api/issues/60.
+ */
public GHUser getClosedBy() {
if(!"closed".equals(state)) return null;
if(closed_by != null) return closed_by;
@@ -250,10 +246,17 @@ public int getCommentsCount(){
return comments;
}
+ /**
+ * Returns non-null if this issue is a shadow of a pull request.
+ */
public PullRequest getPullRequest() {
return pull_request;
}
+ public boolean isPullRequest() {
+ return pull_request!=null;
+ }
+
public GHMilestone getMilestone() {
return milestone;
}
diff --git a/src/main/java/org/kohsuke/github/GHLabel.java b/src/main/java/org/kohsuke/github/GHLabel.java
new file mode 100644
index 0000000000..5d1b3b48a2
--- /dev/null
+++ b/src/main/java/org/kohsuke/github/GHLabel.java
@@ -0,0 +1,37 @@
+package org.kohsuke.github;
+
+import java.io.IOException;
+
+/**
+ * @author Kohsuke Kawaguchi
+ * @see GHIssue#getLabels()
+ * @see GHRepository#listLabels()
+ */
+public class GHLabel {
+ private String url, name, color;
+ private GHRepository repo;
+
+ public String getUrl() {
+ return url;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Color code without leading '#', such as 'f29513'
+ */
+ public String getColor() {
+ return color;
+ }
+
+ /*package*/ GHLabel wrapUp(GHRepository repo) {
+ this.repo = repo;
+ return this;
+ }
+
+ public void delete() throws IOException {
+ repo.root.retrieve().method("DELETE").to(url);
+ }
+}
diff --git a/src/main/java/org/kohsuke/github/GHPerson.java b/src/main/java/org/kohsuke/github/GHPerson.java
index 7984d6d2cc..fa651bb681 100644
--- a/src/main/java/org/kohsuke/github/GHPerson.java
+++ b/src/main/java/org/kohsuke/github/GHPerson.java
@@ -36,7 +36,7 @@ public abstract class GHPerson extends GHObject {
*
* Depending on the original API call where this object is created, it may not contain everything.
*/
- protected void populate() throws IOException {
+ protected synchronized void populate() throws IOException {
if (created_at!=null) return; // already populated
root.retrieve().to(url, this);
diff --git a/src/main/java/org/kohsuke/github/GHPullRequest.java b/src/main/java/org/kohsuke/github/GHPullRequest.java
index b961a83654..7510cdf6c5 100644
--- a/src/main/java/org/kohsuke/github/GHPullRequest.java
+++ b/src/main/java/org/kohsuke/github/GHPullRequest.java
@@ -127,7 +127,7 @@ public Date getMergedAt() {
}
@Override
- public Collection