mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-16 08:21:22 +00:00
234 lines
9.4 KiB
HTML
234 lines
9.4 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>GHPullRequestReviewComment.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">GHPullRequestReviewComment.java</span></div><h1>GHPullRequestReviewComment.java</h1><pre class="source lang-java linenums">/*
|
|
* The MIT License
|
|
*
|
|
* Copyright (c) 2010, 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 java.io.IOException;
|
|
import java.net.URL;
|
|
|
|
import javax.annotation.CheckForNull;
|
|
|
|
import static org.kohsuke.github.internal.Previews.SQUIRREL_GIRL;
|
|
|
|
/**
|
|
* Review comment to the pull request
|
|
*
|
|
* @author Julien Henry
|
|
* @see GHPullRequest#listReviewComments() GHPullRequest#listReviewComments()
|
|
* @see GHPullRequest#createReviewComment(String, String, String, int) GHPullRequest#createReviewComment(String, String,
|
|
* String, int)
|
|
*/
|
|
<span class="fc" id="L41">public class GHPullRequestReviewComment extends GHObject implements Reactable {</span>
|
|
GHPullRequest owner;
|
|
|
|
private String body;
|
|
private GHUser user;
|
|
private String path;
|
|
private String html_url;
|
|
<span class="fc" id="L48"> private int position = -1;</span>
|
|
<span class="fc" id="L49"> private int original_position = -1;</span>
|
|
<span class="fc" id="L50"> private long in_reply_to_id = -1L;</span>
|
|
|
|
/**
|
|
* Draft gh pull request review comment.
|
|
*
|
|
* @param body
|
|
* the body
|
|
* @param path
|
|
* the path
|
|
* @param position
|
|
* the position
|
|
* @return the gh pull request review comment
|
|
* @deprecated You should be using {@link GHPullRequestReviewBuilder#comment(String, String, int)}
|
|
*/
|
|
@Deprecated
|
|
public static GHPullRequestReviewComment draft(String body, String path, int position) {
|
|
<span class="nc" id="L66"> GHPullRequestReviewComment result = new GHPullRequestReviewComment();</span>
|
|
<span class="nc" id="L67"> result.body = body;</span>
|
|
<span class="nc" id="L68"> result.path = path;</span>
|
|
<span class="nc" id="L69"> result.position = position;</span>
|
|
<span class="nc" id="L70"> return result;</span>
|
|
}
|
|
|
|
GHPullRequestReviewComment wrapUp(GHPullRequest owner) {
|
|
<span class="fc" id="L74"> this.owner = owner;</span>
|
|
<span class="fc" id="L75"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets the pull request to which this review comment is associated.
|
|
*
|
|
* @return the parent
|
|
*/
|
|
public GHPullRequest getParent() {
|
|
<span class="nc" id="L84"> return owner;</span>
|
|
}
|
|
|
|
/**
|
|
* The comment itself.
|
|
*
|
|
* @return the body
|
|
*/
|
|
public String getBody() {
|
|
<span class="fc" id="L93"> return body;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets the user who posted this comment.
|
|
*
|
|
* @return the user
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public GHUser getUser() throws IOException {
|
|
<span class="fc" id="L104"> return owner.root.getUser(user.getLogin());</span>
|
|
}
|
|
|
|
/**
|
|
* Gets path.
|
|
*
|
|
* @return the path
|
|
*/
|
|
public String getPath() {
|
|
<span class="fc" id="L113"> return path;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets position.
|
|
*
|
|
* @return the position
|
|
*/
|
|
@CheckForNull
|
|
public int getPosition() {
|
|
<span class="fc" id="L123"> return position;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets original position.
|
|
*
|
|
* @return the original position
|
|
*/
|
|
public int getOriginalPosition() {
|
|
<span class="nc" id="L132"> return original_position;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets in reply to id.
|
|
*
|
|
* @return the in reply to id
|
|
*/
|
|
@CheckForNull
|
|
public long getInReplyToId() {
|
|
<span class="fc" id="L142"> return in_reply_to_id;</span>
|
|
}
|
|
|
|
@Override
|
|
public URL getHtmlUrl() {
|
|
<span class="fc" id="L147"> return GitHubClient.parseURL(html_url);</span>
|
|
}
|
|
|
|
/**
|
|
* Gets api route.
|
|
*
|
|
* @return the api route
|
|
*/
|
|
protected String getApiRoute() {
|
|
<span class="fc" id="L156"> return getApiRoute(false);</span>
|
|
}
|
|
|
|
/**
|
|
* Gets api route.
|
|
*
|
|
* @param includePullNumber
|
|
* if true, includes the owning pull request's number in the route.
|
|
*
|
|
* @return the api route
|
|
*/
|
|
protected String getApiRoute(boolean includePullNumber) {
|
|
<span class="fc" id="L168"> return "/repos/" + owner.getRepository().getFullName() + "/pulls"</span>
|
|
<span class="fc bfc" id="L169" title="All 2 branches covered."> + (includePullNumber ? "/" + owner.getNumber() : "") + "/comments/" + getId();</span>
|
|
}
|
|
|
|
/**
|
|
* Updates the comment.
|
|
*
|
|
* @param body
|
|
* the body
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public void update(String body) throws IOException {
|
|
<span class="fc" id="L181"> owner.root.createRequest().method("PATCH").with("body", body).withUrlPath(getApiRoute()).fetchInto(this);</span>
|
|
<span class="fc" id="L182"> this.body = body;</span>
|
|
<span class="fc" id="L183"> }</span>
|
|
|
|
/**
|
|
* Deletes this review comment.
|
|
*
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public void delete() throws IOException {
|
|
<span class="fc" id="L192"> owner.root.createRequest().method("DELETE").withUrlPath(getApiRoute()).send();</span>
|
|
<span class="fc" id="L193"> }</span>
|
|
|
|
/**
|
|
* Create a new comment that replies to this comment.
|
|
*
|
|
* @param body
|
|
* the body
|
|
* @return the gh pull request review comment
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public GHPullRequestReviewComment reply(String body) throws IOException {
|
|
<span class="fc" id="L205"> return owner.root.createRequest()</span>
|
|
<span class="fc" id="L206"> .method("POST")</span>
|
|
<span class="fc" id="L207"> .with("body", body)</span>
|
|
<span class="fc" id="L208"> .withUrlPath(getApiRoute(true) + "/replies")</span>
|
|
<span class="fc" id="L209"> .fetch(GHPullRequestReviewComment.class)</span>
|
|
<span class="fc" id="L210"> .wrapUp(owner);</span>
|
|
}
|
|
|
|
@Preview(SQUIRREL_GIRL)
|
|
@Deprecated
|
|
public GHReaction createReaction(ReactionContent content) throws IOException {
|
|
<span class="fc" id="L216"> return owner.root.createRequest()</span>
|
|
<span class="fc" id="L217"> .method("POST")</span>
|
|
<span class="fc" id="L218"> .withPreview(SQUIRREL_GIRL)</span>
|
|
<span class="fc" id="L219"> .with("content", content.getContent())</span>
|
|
<span class="fc" id="L220"> .withUrlPath(getApiRoute() + "/reactions")</span>
|
|
<span class="fc" id="L221"> .fetch(GHReaction.class)</span>
|
|
<span class="fc" id="L222"> .wrap(owner.root);</span>
|
|
}
|
|
|
|
@Preview(SQUIRREL_GIRL)
|
|
@Deprecated
|
|
public PagedIterable<GHReaction> listReactions() {
|
|
<span class="fc" id="L228"> return owner.root.createRequest()</span>
|
|
<span class="fc" id="L229"> .withPreview(SQUIRREL_GIRL)</span>
|
|
<span class="fc" id="L230"> .withUrlPath(getApiRoute() + "/reactions")</span>
|
|
<span class="fc" id="L231"> .toIterable(GHReaction[].class, item -> item.wrap(owner.root));</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> |