mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-23 00:11:24 +00:00
103 lines
4.7 KiB
HTML
103 lines
4.7 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>GHIssueBuilder.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">GHIssueBuilder.java</span></div><h1>GHIssueBuilder.java</h1><pre class="source lang-java linenums">package org.kohsuke.github;
|
|
|
|
import java.io.IOException;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* The type GHIssueBuilder.
|
|
*
|
|
* @author Kohsuke Kawaguchi
|
|
*/
|
|
public class GHIssueBuilder {
|
|
private final GHRepository repo;
|
|
private final Requester builder;
|
|
<span class="fc" id="L15"> private List<String> labels = new ArrayList<String>();</span>
|
|
<span class="fc" id="L16"> private List<String> assignees = new ArrayList<String>();</span>
|
|
|
|
<span class="fc" id="L18"> GHIssueBuilder(GHRepository repo, String title) {</span>
|
|
<span class="fc" id="L19"> this.repo = repo;</span>
|
|
<span class="fc" id="L20"> this.builder = repo.root.createRequest().method("POST");</span>
|
|
<span class="fc" id="L21"> builder.with("title", title);</span>
|
|
<span class="fc" id="L22"> }</span>
|
|
|
|
/**
|
|
* Sets the main text of an issue, which is arbitrary multi-line text.
|
|
*
|
|
* @param str
|
|
* the str
|
|
* @return the gh issue builder
|
|
*/
|
|
public GHIssueBuilder body(String str) {
|
|
<span class="fc" id="L32"> builder.with("body", str);</span>
|
|
<span class="fc" id="L33"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Assignee gh issue builder.
|
|
*
|
|
* @param user
|
|
* the user
|
|
* @return the gh issue builder
|
|
*/
|
|
public GHIssueBuilder assignee(GHUser user) {
|
|
<span class="pc bpc" id="L44" title="1 of 2 branches missed."> if (user != null)</span>
|
|
<span class="fc" id="L45"> assignees.add(user.getLogin());</span>
|
|
<span class="fc" id="L46"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Assignee gh issue builder.
|
|
*
|
|
* @param user
|
|
* the user
|
|
* @return the gh issue builder
|
|
*/
|
|
public GHIssueBuilder assignee(String user) {
|
|
<span class="nc bnc" id="L57" title="All 2 branches missed."> if (user != null)</span>
|
|
<span class="nc" id="L58"> assignees.add(user);</span>
|
|
<span class="nc" id="L59"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Milestone gh issue builder.
|
|
*
|
|
* @param milestone
|
|
* the milestone
|
|
* @return the gh issue builder
|
|
*/
|
|
public GHIssueBuilder milestone(GHMilestone milestone) {
|
|
<span class="pc bpc" id="L70" title="1 of 2 branches missed."> if (milestone != null)</span>
|
|
<span class="fc" id="L71"> builder.with("milestone", milestone.getNumber());</span>
|
|
<span class="fc" id="L72"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Label gh issue builder.
|
|
*
|
|
* @param label
|
|
* the label
|
|
* @return the gh issue builder
|
|
*/
|
|
public GHIssueBuilder label(String label) {
|
|
<span class="pc bpc" id="L83" title="1 of 2 branches missed."> if (label != null)</span>
|
|
<span class="fc" id="L84"> labels.add(label);</span>
|
|
<span class="fc" id="L85"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Creates a new issue.
|
|
*
|
|
* @return the gh issue
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public GHIssue create() throws IOException {
|
|
<span class="fc" id="L96"> return builder.with("labels", labels)</span>
|
|
<span class="fc" id="L97"> .with("assignees", assignees)</span>
|
|
<span class="fc" id="L98"> .withUrlPath(repo.getApiTailUrl("issues"))</span>
|
|
<span class="fc" id="L99"> .fetch(GHIssue.class)</span>
|
|
<span class="fc" id="L100"> .wrap(repo);</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> |