mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-14 08:21:22 +00:00
762 lines
28 KiB
HTML
762 lines
28 KiB
HTML
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>GHIssue.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">GitHub API for Java</a> > <a href="index.source.html" class="el_package">org.kohsuke.github</a> > <span class="el_source">GHIssue.java</span></div><h1>GHIssue.java</h1><pre class="source lang-java linenums">/*
|
|
* The MIT License
|
|
*
|
|
* Copyright (c) 2011, Eric Maupin, Kohsuke Kawaguchi
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
* THE SOFTWARE.
|
|
*/
|
|
|
|
package org.kohsuke.github;
|
|
|
|
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
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.List;
|
|
import java.util.Locale;
|
|
import java.util.Objects;
|
|
|
|
import static org.kohsuke.github.internal.Previews.SQUIRREL_GIRL;
|
|
|
|
/**
|
|
* Represents an issue on GitHub.
|
|
*
|
|
* @author Eric Maupin
|
|
* @author Kohsuke Kawaguchi
|
|
* @see GHRepository#getIssue(int) GHRepository#getIssue(int)
|
|
* @see GitHub#searchIssues() GitHub#searchIssues()
|
|
* @see GHIssueSearchBuilder
|
|
*/
|
|
<span class="fc" id="L53">public class GHIssue extends GHObject implements Reactable {</span>
|
|
private static final String ASSIGNEES = "assignees";
|
|
|
|
GHRepository owner;
|
|
|
|
// API v3
|
|
protected GHUser assignee; // not sure what this field is now that 'assignees' exist
|
|
protected GHUser[] assignees;
|
|
protected String state;
|
|
protected int number;
|
|
protected String closed_at;
|
|
protected int comments;
|
|
@SkipFromToString
|
|
protected String body;
|
|
protected List<GHLabel> labels;
|
|
protected GHUser user;
|
|
protected String title, html_url;
|
|
protected GHIssue.PullRequest pull_request;
|
|
protected GHMilestone milestone;
|
|
protected GHUser closed_by;
|
|
protected boolean locked;
|
|
|
|
GHIssue wrap(GHRepository owner) {
|
|
<span class="fc" id="L76"> this.owner = owner;</span>
|
|
<span class="fc bfc" id="L77" title="All 2 branches covered."> if (milestone != null)</span>
|
|
<span class="fc" id="L78"> milestone.wrap(owner);</span>
|
|
<span class="fc" id="L79"> return wrap(owner.root);</span>
|
|
}
|
|
|
|
GHIssue wrap(GitHub root) {
|
|
<span class="fc" id="L83"> this.root = root;</span>
|
|
<span class="fc bfc" id="L84" title="All 2 branches covered."> if (assignee != null)</span>
|
|
<span class="fc" id="L85"> assignee.wrapUp(root);</span>
|
|
<span class="fc bfc" id="L86" title="All 2 branches covered."> if (assignees != null)</span>
|
|
<span class="fc" id="L87"> GHUser.wrap(assignees, root);</span>
|
|
<span class="fc bfc" id="L88" title="All 2 branches covered."> if (user != null)</span>
|
|
<span class="fc" id="L89"> user.wrapUp(root);</span>
|
|
<span class="fc bfc" id="L90" title="All 2 branches covered."> if (closed_by != null)</span>
|
|
<span class="fc" id="L91"> closed_by.wrapUp(root);</span>
|
|
<span class="fc" id="L92"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Repository to which the issue belongs.
|
|
*
|
|
* @return the repository
|
|
*/
|
|
public GHRepository getRepository() {
|
|
<span class="fc" id="L101"> return owner;</span>
|
|
}
|
|
|
|
/**
|
|
* The description of this pull request.
|
|
*
|
|
* @return the body
|
|
*/
|
|
public String getBody() {
|
|
<span class="fc" id="L110"> return body;</span>
|
|
}
|
|
|
|
/**
|
|
* ID.
|
|
*
|
|
* @return the number
|
|
*/
|
|
public int getNumber() {
|
|
<span class="fc" id="L119"> return number;</span>
|
|
}
|
|
|
|
/**
|
|
* The HTML page of this issue, like https://github.com/jenkinsci/jenkins/issues/100
|
|
*/
|
|
public URL getHtmlUrl() {
|
|
<span class="nc" id="L126"> return GitHubClient.parseURL(html_url);</span>
|
|
}
|
|
|
|
/**
|
|
* Gets title.
|
|
*
|
|
* @return the title
|
|
*/
|
|
public String getTitle() {
|
|
<span class="fc" id="L135"> return title;</span>
|
|
}
|
|
|
|
/**
|
|
* Is locked boolean.
|
|
*
|
|
* @return the boolean
|
|
*/
|
|
public boolean isLocked() {
|
|
<span class="nc" id="L144"> return locked;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets state.
|
|
*
|
|
* @return the state
|
|
*/
|
|
public GHIssueState getState() {
|
|
<span class="fc" id="L153"> return Enum.valueOf(GHIssueState.class, state.toUpperCase(Locale.ENGLISH));</span>
|
|
}
|
|
|
|
/**
|
|
* Gets labels.
|
|
*
|
|
* @return the labels
|
|
*/
|
|
public Collection<GHLabel> getLabels() {
|
|
<span class="pc bpc" id="L162" title="1 of 2 branches missed."> if (labels == null) {</span>
|
|
<span class="nc" id="L163"> return Collections.emptyList();</span>
|
|
}
|
|
<span class="fc" id="L165"> return Collections.unmodifiableList(labels);</span>
|
|
}
|
|
|
|
/**
|
|
* Gets closed at.
|
|
*
|
|
* @return the closed at
|
|
*/
|
|
public Date getClosedAt() {
|
|
<span class="nc" id="L174"> return GitHubClient.parseDate(closed_at);</span>
|
|
}
|
|
|
|
/**
|
|
* Gets api url.
|
|
*
|
|
* @return API URL of this object.
|
|
* @deprecated use {@link #getUrl()}
|
|
*/
|
|
@Deprecated
|
|
public URL getApiURL() {
|
|
<span class="nc" id="L185"> return getUrl();</span>
|
|
}
|
|
|
|
/**
|
|
* Lock.
|
|
*
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public void lock() throws IOException {
|
|
<span class="nc" id="L195"> root.createRequest().method("PUT").withUrlPath(getApiRoute() + "/lock").send();</span>
|
|
<span class="nc" id="L196"> }</span>
|
|
|
|
/**
|
|
* Unlock.
|
|
*
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public void unlock() throws IOException {
|
|
<span class="nc" id="L205"> root.createRequest().method("PUT").withUrlPath(getApiRoute() + "/lock").send();</span>
|
|
<span class="nc" id="L206"> }</span>
|
|
|
|
/**
|
|
* Updates the issue by adding a comment.
|
|
*
|
|
* @param message
|
|
* the message
|
|
* @return Newly posted comment.
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
@WithBridgeMethods(void.class)
|
|
public GHIssueComment comment(String message) throws IOException {
|
|
<span class="fc" id="L219"> GHIssueComment r = root.createRequest()</span>
|
|
<span class="fc" id="L220"> .method("POST")</span>
|
|
<span class="fc" id="L221"> .with("body", message)</span>
|
|
<span class="fc" id="L222"> .withUrlPath(getIssuesApiRoute() + "/comments")</span>
|
|
<span class="fc" id="L223"> .fetch(GHIssueComment.class);</span>
|
|
<span class="fc" id="L224"> return r.wrapUp(this);</span>
|
|
}
|
|
|
|
private void edit(String key, Object value) throws IOException {
|
|
<span class="fc" id="L228"> root.createRequest().with(key, value).method("PATCH").withUrlPath(getApiRoute()).send();</span>
|
|
<span class="fc" id="L229"> }</span>
|
|
|
|
/**
|
|
* Identical to edit(), but allows null for the value.
|
|
*/
|
|
private void editNullable(String key, Object value) throws IOException {
|
|
<span class="nc" id="L235"> root.createRequest().withNullable(key, value).method("PATCH").withUrlPath(getApiRoute()).send();</span>
|
|
<span class="nc" id="L236"> }</span>
|
|
|
|
private void editIssue(String key, Object value) throws IOException {
|
|
<span class="fc" id="L239"> root.createRequest().withNullable(key, value).method("PATCH").withUrlPath(getIssuesApiRoute()).send();</span>
|
|
<span class="fc" id="L240"> }</span>
|
|
|
|
/**
|
|
* Closes this issue.
|
|
*
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public void close() throws IOException {
|
|
<span class="fc" id="L249"> edit("state", "closed");</span>
|
|
<span class="fc" id="L250"> }</span>
|
|
|
|
/**
|
|
* Reopens this issue.
|
|
*
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public void reopen() throws IOException {
|
|
<span class="nc" id="L259"> edit("state", "open");</span>
|
|
<span class="nc" id="L260"> }</span>
|
|
|
|
/**
|
|
* Sets title.
|
|
*
|
|
* @param title
|
|
* the title
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public void setTitle(String title) throws IOException {
|
|
<span class="nc" id="L271"> edit("title", title);</span>
|
|
<span class="nc" id="L272"> }</span>
|
|
|
|
/**
|
|
* Sets body.
|
|
*
|
|
* @param body
|
|
* the body
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public void setBody(String body) throws IOException {
|
|
<span class="nc" id="L283"> edit("body", body);</span>
|
|
<span class="nc" id="L284"> }</span>
|
|
|
|
/**
|
|
* Sets the milestone for this issue.
|
|
*
|
|
* @param milestone
|
|
* The milestone to assign this issue to. Use null to remove the milestone for this issue.
|
|
* @throws IOException
|
|
* The io exception
|
|
*/
|
|
public void setMilestone(GHMilestone milestone) throws IOException {
|
|
<span class="fc bfc" id="L295" title="All 2 branches covered."> if (milestone == null) {</span>
|
|
<span class="fc" id="L296"> editIssue("milestone", null);</span>
|
|
} else {
|
|
<span class="fc" id="L298"> editIssue("milestone", milestone.getNumber());</span>
|
|
}
|
|
<span class="fc" id="L300"> }</span>
|
|
|
|
/**
|
|
* Assign to.
|
|
*
|
|
* @param user
|
|
* the user
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public void assignTo(GHUser user) throws IOException {
|
|
<span class="fc" id="L311"> setAssignees(user);</span>
|
|
<span class="fc" id="L312"> }</span>
|
|
|
|
/**
|
|
* Sets labels on the target to a specific list.
|
|
*
|
|
* @param labels
|
|
* the labels
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public void setLabels(String... labels) throws IOException {
|
|
<span class="fc" id="L323"> editIssue("labels", labels);</span>
|
|
<span class="fc" id="L324"> }</span>
|
|
|
|
/**
|
|
* Adds labels to the issue.
|
|
*
|
|
* Labels that are already present on the target are ignored.
|
|
*
|
|
* @return the complete list of labels including the new additions
|
|
* @param names
|
|
* Names of the label
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
@WithBridgeMethods(void.class)
|
|
public List<GHLabel> addLabels(String... names) throws IOException {
|
|
<span class="fc" id="L339"> return _addLabels(Arrays.asList(names));</span>
|
|
}
|
|
|
|
/**
|
|
* Add labels.
|
|
*
|
|
* Labels that are already present on the target are ignored.
|
|
*
|
|
* @return the complete list of labels including the new additions
|
|
* @param labels
|
|
* the labels
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
@WithBridgeMethods(void.class)
|
|
public List<GHLabel> addLabels(GHLabel... labels) throws IOException {
|
|
<span class="fc" id="L355"> return addLabels(Arrays.asList(labels));</span>
|
|
}
|
|
|
|
/**
|
|
* Add labels.
|
|
*
|
|
* Labels that are already present on the target are ignored.
|
|
*
|
|
* @return the complete list of labels including the new additions
|
|
* @param labels
|
|
* the labels
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
@WithBridgeMethods(void.class)
|
|
public List<GHLabel> addLabels(Collection<GHLabel> labels) throws IOException {
|
|
<span class="fc" id="L371"> return _addLabels(GHLabel.toNames(labels));</span>
|
|
}
|
|
|
|
private List<GHLabel> _addLabels(Collection<String> names) throws IOException {
|
|
<span class="fc" id="L375"> return Arrays.asList(root.createRequest()</span>
|
|
<span class="fc" id="L376"> .with("labels", names)</span>
|
|
<span class="fc" id="L377"> .method("POST")</span>
|
|
<span class="fc" id="L378"> .withUrlPath(getIssuesApiRoute() + "/labels")</span>
|
|
<span class="fc" id="L379"> .fetch(GHLabel[].class));</span>
|
|
}
|
|
|
|
/**
|
|
* Remove a single label.
|
|
*
|
|
* Attempting to remove a label that is not present throws {@link GHFileNotFoundException}.
|
|
*
|
|
* @return the remaining list of labels
|
|
* @param name
|
|
* the name
|
|
* @throws IOException
|
|
* the io exception, throws {@link GHFileNotFoundException} if label was not present.
|
|
*/
|
|
@WithBridgeMethods(void.class)
|
|
public List<GHLabel> removeLabel(String name) throws IOException {
|
|
<span class="fc" id="L395"> return Arrays.asList(root.createRequest()</span>
|
|
<span class="fc" id="L396"> .method("DELETE")</span>
|
|
<span class="fc" id="L397"> .withUrlPath(getIssuesApiRoute() + "/labels", name)</span>
|
|
<span class="fc" id="L398"> .fetch(GHLabel[].class));</span>
|
|
}
|
|
|
|
/**
|
|
* Remove a collection of labels.
|
|
*
|
|
* Attempting to remove labels that are not present on the target are ignored.
|
|
*
|
|
* @return the remaining list of labels
|
|
* @param names
|
|
* the names
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
@WithBridgeMethods(void.class)
|
|
public List<GHLabel> removeLabels(String... names) throws IOException {
|
|
<span class="fc" id="L414"> return _removeLabels(Arrays.asList(names));</span>
|
|
}
|
|
|
|
/**
|
|
* Remove a collection of labels.
|
|
*
|
|
* Attempting to remove labels that are not present on the target are ignored.
|
|
*
|
|
* @return the remaining list of labels
|
|
* @param labels
|
|
* the labels
|
|
* @throws IOException
|
|
* the io exception
|
|
* @see #removeLabels(String...) #removeLabels(String...)
|
|
*/
|
|
@WithBridgeMethods(void.class)
|
|
public List<GHLabel> removeLabels(GHLabel... labels) throws IOException {
|
|
<span class="fc" id="L431"> return removeLabels(Arrays.asList(labels));</span>
|
|
}
|
|
|
|
/**
|
|
* Remove a collection of labels.
|
|
*
|
|
* Attempting to remove labels that are not present on the target are ignored.
|
|
*
|
|
* @return the remaining list of labels
|
|
* @param labels
|
|
* the labels
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
@WithBridgeMethods(void.class)
|
|
public List<GHLabel> removeLabels(Collection<GHLabel> labels) throws IOException {
|
|
<span class="fc" id="L447"> return _removeLabels(GHLabel.toNames(labels));</span>
|
|
}
|
|
|
|
private List<GHLabel> _removeLabels(Collection<String> names) throws IOException {
|
|
<span class="fc" id="L451"> List<GHLabel> remainingLabels = Collections.emptyList();</span>
|
|
<span class="fc bfc" id="L452" title="All 2 branches covered."> for (String name : names) {</span>
|
|
try {
|
|
<span class="fc" id="L454"> remainingLabels = removeLabel(name);</span>
|
|
<span class="fc" id="L455"> } catch (GHFileNotFoundException e) {</span>
|
|
// when trying to remove multiple labels, we ignore already removed
|
|
<span class="fc" id="L457"> }</span>
|
|
<span class="fc" id="L458"> }</span>
|
|
<span class="fc" id="L459"> return remainingLabels;</span>
|
|
}
|
|
|
|
/**
|
|
* Obtains all the comments associated with this issue.
|
|
*
|
|
* @return the comments
|
|
* @throws IOException
|
|
* the io exception
|
|
* @see #listComments() #listComments()
|
|
*/
|
|
public List<GHIssueComment> getComments() throws IOException {
|
|
<span class="fc" id="L471"> return listComments().toList();</span>
|
|
}
|
|
|
|
/**
|
|
* Obtains all the comments associated with this issue.
|
|
*
|
|
* @return the paged iterable
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public PagedIterable<GHIssueComment> listComments() throws IOException {
|
|
<span class="fc" id="L482"> return root.createRequest()</span>
|
|
<span class="fc" id="L483"> .withUrlPath(getIssuesApiRoute() + "/comments")</span>
|
|
<span class="fc" id="L484"> .toIterable(GHIssueComment[].class, item -> item.wrapUp(this));</span>
|
|
}
|
|
|
|
@Preview(SQUIRREL_GIRL)
|
|
@Deprecated
|
|
public GHReaction createReaction(ReactionContent content) throws IOException {
|
|
<span class="fc" id="L490"> return root.createRequest()</span>
|
|
<span class="fc" id="L491"> .method("POST")</span>
|
|
<span class="fc" id="L492"> .withPreview(SQUIRREL_GIRL)</span>
|
|
<span class="fc" id="L493"> .with("content", content.getContent())</span>
|
|
<span class="fc" id="L494"> .withUrlPath(getApiRoute() + "/reactions")</span>
|
|
<span class="fc" id="L495"> .fetch(GHReaction.class)</span>
|
|
<span class="fc" id="L496"> .wrap(root);</span>
|
|
}
|
|
|
|
@Preview(SQUIRREL_GIRL)
|
|
@Deprecated
|
|
public PagedIterable<GHReaction> listReactions() {
|
|
<span class="fc" id="L502"> return root.createRequest()</span>
|
|
<span class="fc" id="L503"> .withPreview(SQUIRREL_GIRL)</span>
|
|
<span class="fc" id="L504"> .withUrlPath(getApiRoute() + "/reactions")</span>
|
|
<span class="fc" id="L505"> .toIterable(GHReaction[].class, item -> item.wrap(root));</span>
|
|
}
|
|
|
|
/**
|
|
* Add assignees.
|
|
*
|
|
* @param assignees
|
|
* the assignees
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public void addAssignees(GHUser... assignees) throws IOException {
|
|
<span class="nc" id="L517"> addAssignees(Arrays.asList(assignees));</span>
|
|
<span class="nc" id="L518"> }</span>
|
|
|
|
/**
|
|
* Add assignees.
|
|
*
|
|
* @param assignees
|
|
* the assignees
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public void addAssignees(Collection<GHUser> assignees) throws IOException {
|
|
<span class="nc" id="L529"> root.createRequest()</span>
|
|
<span class="nc" id="L530"> .method("POST")</span>
|
|
<span class="nc" id="L531"> .with(ASSIGNEES, getLogins(assignees))</span>
|
|
<span class="nc" id="L532"> .withUrlPath(getIssuesApiRoute() + "/assignees")</span>
|
|
<span class="nc" id="L533"> .fetchInto(this);</span>
|
|
<span class="nc" id="L534"> }</span>
|
|
|
|
/**
|
|
* Sets assignees.
|
|
*
|
|
* @param assignees
|
|
* the assignees
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public void setAssignees(GHUser... assignees) throws IOException {
|
|
<span class="fc" id="L545"> setAssignees(Arrays.asList(assignees));</span>
|
|
<span class="fc" id="L546"> }</span>
|
|
|
|
/**
|
|
* Sets assignees.
|
|
*
|
|
* @param assignees
|
|
* the assignees
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public void setAssignees(Collection<GHUser> assignees) throws IOException {
|
|
<span class="fc" id="L557"> root.createRequest()</span>
|
|
<span class="fc" id="L558"> .method("PATCH")</span>
|
|
<span class="fc" id="L559"> .with(ASSIGNEES, getLogins(assignees))</span>
|
|
<span class="fc" id="L560"> .withUrlPath(getIssuesApiRoute())</span>
|
|
<span class="fc" id="L561"> .send();</span>
|
|
<span class="fc" id="L562"> }</span>
|
|
|
|
/**
|
|
* Remove assignees.
|
|
*
|
|
* @param assignees
|
|
* the assignees
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public void removeAssignees(GHUser... assignees) throws IOException {
|
|
<span class="nc" id="L573"> removeAssignees(Arrays.asList(assignees));</span>
|
|
<span class="nc" id="L574"> }</span>
|
|
|
|
/**
|
|
* Remove assignees.
|
|
*
|
|
* @param assignees
|
|
* the assignees
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public void removeAssignees(Collection<GHUser> assignees) throws IOException {
|
|
<span class="nc" id="L585"> root.createRequest()</span>
|
|
<span class="nc" id="L586"> .method("DELETE")</span>
|
|
<span class="nc" id="L587"> .with(ASSIGNEES, getLogins(assignees))</span>
|
|
<span class="nc" id="L588"> .inBody()</span>
|
|
<span class="nc" id="L589"> .withUrlPath(getIssuesApiRoute() + "/assignees")</span>
|
|
<span class="nc" id="L590"> .fetchInto(this);</span>
|
|
<span class="nc" id="L591"> }</span>
|
|
|
|
/**
|
|
* Gets api route.
|
|
*
|
|
* @return the api route
|
|
*/
|
|
protected String getApiRoute() {
|
|
<span class="fc" id="L599"> return getIssuesApiRoute();</span>
|
|
}
|
|
|
|
/**
|
|
* Gets issues api route.
|
|
*
|
|
* @return the issues api route
|
|
*/
|
|
protected String getIssuesApiRoute() {
|
|
<span class="fc bfc" id="L608" title="All 2 branches covered."> if (owner == null) {</span>
|
|
// Issues returned from search to do not have an owner. Attempt to use url.
|
|
<span class="fc" id="L610"> final URL url = Objects.requireNonNull(getUrl(), "Missing instance URL!");</span>
|
|
<span class="fc" id="L611"> return StringUtils.prependIfMissing(url.toString().replace(root.getApiUrl(), ""), "/");</span>
|
|
}
|
|
<span class="fc" id="L613"> return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/issues/" + number;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets assignee.
|
|
*
|
|
* @return the assignee
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public GHUser getAssignee() throws IOException {
|
|
<span class="fc" id="L624"> return root.intern(assignee);</span>
|
|
}
|
|
|
|
/**
|
|
* Gets assignees.
|
|
*
|
|
* @return the assignees
|
|
*/
|
|
public List<GHUser> getAssignees() {
|
|
<span class="nc" id="L633"> return Collections.unmodifiableList(Arrays.asList(assignees));</span>
|
|
}
|
|
|
|
/**
|
|
* User who submitted the issue.
|
|
*
|
|
* @return the user
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public GHUser getUser() throws IOException {
|
|
<span class="fc" id="L644"> return root.intern(user);</span>
|
|
}
|
|
|
|
/**
|
|
* Reports who has closed the issue.
|
|
*
|
|
* <p>
|
|
* 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.
|
|
*
|
|
* @return the closed by
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public GHUser getClosedBy() throws IOException {
|
|
<span class="nc bnc" id="L659" title="All 2 branches missed."> if (!"closed".equals(state))</span>
|
|
<span class="nc" id="L660"> return null;</span>
|
|
|
|
// TODO
|
|
/*
|
|
* if (closed_by==null) { closed_by = owner.getIssue(number).getClosed_by(); }
|
|
*/
|
|
<span class="nc" id="L666"> return root.intern(closed_by);</span>
|
|
}
|
|
|
|
/**
|
|
* Gets comments count.
|
|
*
|
|
* @return the comments count
|
|
*/
|
|
public int getCommentsCount() {
|
|
<span class="fc" id="L675"> return comments;</span>
|
|
}
|
|
|
|
/**
|
|
* Returns non-null if this issue is a shadow of a pull request.
|
|
*
|
|
* @return the pull request
|
|
*/
|
|
public PullRequest getPullRequest() {
|
|
<span class="nc" id="L684"> return pull_request;</span>
|
|
}
|
|
|
|
/**
|
|
* Is pull request boolean.
|
|
*
|
|
* @return the boolean
|
|
*/
|
|
public boolean isPullRequest() {
|
|
<span class="nc bnc" id="L693" title="All 2 branches missed."> return pull_request != null;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets milestone.
|
|
*
|
|
* @return the milestone
|
|
*/
|
|
public GHMilestone getMilestone() {
|
|
<span class="fc" id="L702"> return milestone;</span>
|
|
}
|
|
|
|
/**
|
|
* The type PullRequest.
|
|
*/
|
|
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD" },
|
|
justification = "JSON API")
|
|
<span class="fc" id="L710"> public static class PullRequest {</span>
|
|
private String diff_url, patch_url, html_url;
|
|
|
|
/**
|
|
* Gets diff url.
|
|
*
|
|
* @return the diff url
|
|
*/
|
|
public URL getDiffUrl() {
|
|
<span class="nc" id="L719"> return GitHubClient.parseURL(diff_url);</span>
|
|
}
|
|
|
|
/**
|
|
* Gets patch url.
|
|
*
|
|
* @return the patch url
|
|
*/
|
|
public URL getPatchUrl() {
|
|
<span class="nc" id="L728"> return GitHubClient.parseURL(patch_url);</span>
|
|
}
|
|
|
|
/**
|
|
* Gets url.
|
|
*
|
|
* @return the url
|
|
*/
|
|
public URL getUrl() {
|
|
<span class="nc" id="L737"> return GitHubClient.parseURL(html_url);</span>
|
|
}
|
|
}
|
|
|
|
protected static List<String> getLogins(Collection<GHUser> users) {
|
|
<span class="fc" id="L742"> List<String> names = new ArrayList<String>(users.size());</span>
|
|
<span class="fc bfc" id="L743" title="All 2 branches covered."> for (GHUser a : users) {</span>
|
|
<span class="fc" id="L744"> names.add(a.getLogin());</span>
|
|
<span class="fc" id="L745"> }</span>
|
|
<span class="fc" id="L746"> return names;</span>
|
|
}
|
|
|
|
/**
|
|
* Lists events for this issue. See https://developer.github.com/v3/issues/events/
|
|
*
|
|
* @return the paged iterable
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public PagedIterable<GHIssueEvent> listEvents() throws IOException {
|
|
<span class="fc" id="L757"> return root.createRequest()</span>
|
|
<span class="fc" id="L758"> .withUrlPath(owner.getApiTailUrl(String.format("/issues/%s/events", number)))</span>
|
|
<span class="fc" id="L759"> .toIterable(GHIssueEvent[].class, item -> item.wrapUp(this));</span>
|
|
}
|
|
}
|
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.7.202105040129</span></div></body></html> |