mirror of
https://github.com/jlengrand/github-api.git
synced 2026-04-04 15:50:52 +00:00
215 lines
8.3 KiB
HTML
215 lines
8.3 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>GHPullRequestReview.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">GHPullRequestReview.java</span></div><h1>GHPullRequestReview.java</h1><pre class="source lang-java linenums">/*
|
|
* The MIT License
|
|
*
|
|
* Copyright (c) 2017, CloudBees, Inc.
|
|
*
|
|
* 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 edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
|
|
import java.io.IOException;
|
|
import java.net.URL;
|
|
import java.util.Date;
|
|
|
|
import javax.annotation.CheckForNull;
|
|
|
|
/**
|
|
* Review to a pull request.
|
|
*
|
|
* @see GHPullRequest#listReviews() GHPullRequest#listReviews()
|
|
* @see GHPullRequestReviewBuilder
|
|
*/
|
|
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API")
|
|
<span class="fc" id="L41">public class GHPullRequestReview extends GHObject {</span>
|
|
GHPullRequest owner;
|
|
|
|
private String body;
|
|
private GHUser user;
|
|
private String commit_id;
|
|
private GHPullRequestReviewState state;
|
|
private String submitted_at;
|
|
private String html_url;
|
|
|
|
GHPullRequestReview wrapUp(GHPullRequest owner) {
|
|
<span class="fc" id="L52"> this.owner = owner;</span>
|
|
<span class="fc" id="L53"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets the pull request to which this review is associated.
|
|
*
|
|
* @return the parent
|
|
*/
|
|
public GHPullRequest getParent() {
|
|
<span class="nc" id="L62"> return owner;</span>
|
|
}
|
|
|
|
/**
|
|
* The comment itself.
|
|
*
|
|
* @return the body
|
|
*/
|
|
public String getBody() {
|
|
<span class="fc" id="L71"> return body;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets the user who posted this review.
|
|
*
|
|
* @return the user
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public GHUser getUser() throws IOException {
|
|
<span class="nc" id="L82"> return owner.root.getUser(user.getLogin());</span>
|
|
}
|
|
|
|
/**
|
|
* Gets commit id.
|
|
*
|
|
* @return the commit id
|
|
*/
|
|
public String getCommitId() {
|
|
<span class="fc" id="L91"> return commit_id;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets state.
|
|
*
|
|
* @return the state
|
|
*/
|
|
@CheckForNull
|
|
public GHPullRequestReviewState getState() {
|
|
<span class="fc" id="L101"> return state;</span>
|
|
}
|
|
|
|
@Override
|
|
public URL getHtmlUrl() {
|
|
<span class="fc" id="L106"> return GitHubClient.parseURL(html_url);</span>
|
|
}
|
|
|
|
/**
|
|
* Gets api route.
|
|
*
|
|
* @return the api route
|
|
*/
|
|
protected String getApiRoute() {
|
|
<span class="fc" id="L115"> return owner.getApiRoute() + "/reviews/" + getId();</span>
|
|
}
|
|
|
|
/**
|
|
* When was this resource created?
|
|
*
|
|
* @return the submitted at
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public Date getSubmittedAt() throws IOException {
|
|
<span class="nc" id="L126"> return GitHubClient.parseDate(submitted_at);</span>
|
|
}
|
|
|
|
/**
|
|
* Since this method does not exist, we forward this value.
|
|
*/
|
|
@Override
|
|
public Date getCreatedAt() throws IOException {
|
|
<span class="nc" id="L134"> return getSubmittedAt();</span>
|
|
}
|
|
|
|
/**
|
|
* Submit.
|
|
*
|
|
* @param body
|
|
* the body
|
|
* @param state
|
|
* the state
|
|
* @throws IOException
|
|
* the io exception
|
|
* @deprecated Former preview method that changed when it got public. Left here for backward compatibility. Use
|
|
* {@link #submit(String, GHPullRequestReviewEvent)}
|
|
*/
|
|
@Deprecated
|
|
public void submit(String body, GHPullRequestReviewState state) throws IOException {
|
|
<span class="nc" id="L151"> submit(body, state.toEvent());</span>
|
|
<span class="nc" id="L152"> }</span>
|
|
|
|
/**
|
|
* Updates the comment.
|
|
*
|
|
* @param body
|
|
* the body
|
|
* @param event
|
|
* the event
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public void submit(String body, GHPullRequestReviewEvent event) throws IOException {
|
|
<span class="fc" id="L165"> owner.root.createRequest()</span>
|
|
<span class="fc" id="L166"> .method("POST")</span>
|
|
<span class="fc" id="L167"> .with("body", body)</span>
|
|
<span class="fc" id="L168"> .with("event", event.action())</span>
|
|
<span class="fc" id="L169"> .withUrlPath(getApiRoute() + "/events")</span>
|
|
<span class="fc" id="L170"> .fetchInto(this);</span>
|
|
<span class="fc" id="L171"> this.body = body;</span>
|
|
<span class="fc" id="L172"> this.state = event.toState();</span>
|
|
<span class="fc" id="L173"> }</span>
|
|
|
|
/**
|
|
* Deletes this review.
|
|
*
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public void delete() throws IOException {
|
|
<span class="fc" id="L182"> owner.root.createRequest().method("DELETE").withUrlPath(getApiRoute()).send();</span>
|
|
<span class="fc" id="L183"> }</span>
|
|
|
|
/**
|
|
* Dismisses this review.
|
|
*
|
|
* @param message
|
|
* the message
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public void dismiss(String message) throws IOException {
|
|
<span class="nc" id="L194"> owner.root.createRequest()</span>
|
|
<span class="nc" id="L195"> .method("PUT")</span>
|
|
<span class="nc" id="L196"> .with("message", message)</span>
|
|
<span class="nc" id="L197"> .withUrlPath(getApiRoute() + "/dismissals")</span>
|
|
<span class="nc" id="L198"> .send();</span>
|
|
<span class="nc" id="L199"> state = GHPullRequestReviewState.DISMISSED;</span>
|
|
<span class="nc" id="L200"> }</span>
|
|
|
|
/**
|
|
* Obtains all the review comments associated with this pull request review.
|
|
*
|
|
* @return the paged iterable
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public PagedIterable<GHPullRequestReviewComment> listReviewComments() throws IOException {
|
|
<span class="fc" id="L210"> return owner.root.createRequest()</span>
|
|
<span class="fc" id="L211"> .withUrlPath(getApiRoute() + "/comments")</span>
|
|
<span class="fc" id="L212"> .toIterable(GHPullRequestReviewComment[].class, item -> item.wrapUp(owner));</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> |