mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-15 00:11:22 +00:00
155 lines
6.9 KiB
HTML
155 lines
6.9 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>GHIssueComment.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">GHIssueComment.java</span></div><h1>GHIssueComment.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 static org.kohsuke.github.internal.Previews.SQUIRREL_GIRL;
|
|
|
|
/**
|
|
* Comment to the issue
|
|
*
|
|
* @author Kohsuke Kawaguchi
|
|
* @see GHIssue#comment(String) GHIssue#comment(String)
|
|
* @see GHIssue#listComments() GHIssue#listComments()
|
|
*/
|
|
<span class="fc" id="L38">public class GHIssueComment extends GHObject implements Reactable {</span>
|
|
GHIssue owner;
|
|
|
|
private String body, gravatar_id, html_url, author_association;
|
|
private GHUser user; // not fully populated. beware.
|
|
|
|
GHIssueComment wrapUp(GHIssue owner) {
|
|
<span class="fc" id="L45"> this.owner = owner;</span>
|
|
<span class="fc" id="L46"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets the issue to which this comment is associated.
|
|
*
|
|
* @return the parent
|
|
*/
|
|
public GHIssue getParent() {
|
|
<span class="fc" id="L55"> return owner;</span>
|
|
}
|
|
|
|
/**
|
|
* The comment itself.
|
|
*
|
|
* @return the body
|
|
*/
|
|
public String getBody() {
|
|
<span class="fc" id="L64"> return body;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets the ID of the user who posted this comment.
|
|
*
|
|
* @return the user name
|
|
*/
|
|
@Deprecated
|
|
public String getUserName() {
|
|
<span class="nc" id="L74"> return user.getLogin();</span>
|
|
}
|
|
|
|
/**
|
|
* Gets the user who posted this comment.
|
|
*
|
|
* @return the user
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public GHUser getUser() throws IOException {
|
|
<span class="pc bpc" id="L85" title="1 of 4 branches missed."> return owner == null || owner.root.isOffline() ? user : owner.root.getUser(user.getLogin());</span>
|
|
}
|
|
|
|
@Override
|
|
public URL getHtmlUrl() {
|
|
<span class="fc" id="L90"> return GitHubClient.parseURL(html_url);</span>
|
|
}
|
|
|
|
/**
|
|
* Gets author association.
|
|
*
|
|
* @return the author association
|
|
*/
|
|
public GHCommentAuthorAssociation getAuthorAssociation() {
|
|
<span class="nc" id="L99"> return GHCommentAuthorAssociation.valueOf(author_association);</span>
|
|
}
|
|
|
|
/**
|
|
* Updates the body of the issue comment.
|
|
*
|
|
* @param body
|
|
* the body
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public void update(String body) throws IOException {
|
|
<span class="nc" id="L111"> owner.root.createRequest()</span>
|
|
<span class="nc" id="L112"> .method("PATCH")</span>
|
|
<span class="nc" id="L113"> .with("body", body)</span>
|
|
<span class="nc" id="L114"> .withUrlPath(getApiRoute())</span>
|
|
<span class="nc" id="L115"> .fetch(GHIssueComment.class);</span>
|
|
<span class="nc" id="L116"> this.body = body;</span>
|
|
<span class="nc" id="L117"> }</span>
|
|
|
|
/**
|
|
* Deletes this issue comment.
|
|
*
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public void delete() throws IOException {
|
|
<span class="nc" id="L126"> owner.root.createRequest().method("DELETE").withUrlPath(getApiRoute()).send();</span>
|
|
<span class="nc" id="L127"> }</span>
|
|
|
|
@Preview(SQUIRREL_GIRL)
|
|
@Deprecated
|
|
public GHReaction createReaction(ReactionContent content) throws IOException {
|
|
<span class="nc" id="L132"> return owner.root.createRequest()</span>
|
|
<span class="nc" id="L133"> .method("POST")</span>
|
|
<span class="nc" id="L134"> .withPreview(SQUIRREL_GIRL)</span>
|
|
<span class="nc" id="L135"> .with("content", content.getContent())</span>
|
|
<span class="nc" id="L136"> .withUrlPath(getApiRoute() + "/reactions")</span>
|
|
<span class="nc" id="L137"> .fetch(GHReaction.class)</span>
|
|
<span class="nc" id="L138"> .wrap(owner.root);</span>
|
|
}
|
|
|
|
@Preview(SQUIRREL_GIRL)
|
|
@Deprecated
|
|
public PagedIterable<GHReaction> listReactions() {
|
|
<span class="fc" id="L144"> return owner.root.createRequest()</span>
|
|
<span class="fc" id="L145"> .withPreview(SQUIRREL_GIRL)</span>
|
|
<span class="fc" id="L146"> .withUrlPath(getApiRoute() + "/reactions")</span>
|
|
<span class="fc" id="L147"> .toIterable(GHReaction[].class, item -> item.wrap(owner.root));</span>
|
|
}
|
|
|
|
private String getApiRoute() {
|
|
<span class="fc" id="L151"> return "/repos/" + owner.getRepository().getOwnerName() + "/" + owner.getRepository().getName()</span>
|
|
<span class="fc" id="L152"> + "/issues/comments/" + getId();</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> |