Files
github-api/jacoco/org.kohsuke.github/GHCreateRepositoryBuilder.java.html
2021-06-02 11:09:28 -07:00

135 lines
6.2 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>GHCreateRepositoryBuilder.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> &gt; <a href="index.source.html" class="el_package">org.kohsuke.github</a> &gt; <span class="el_source">GHCreateRepositoryBuilder.java</span></div><h1>GHCreateRepositoryBuilder.java</h1><pre class="source lang-java linenums">package org.kohsuke.github;
import java.io.IOException;
import static org.kohsuke.github.internal.Previews.BAPTISTE;
/**
* Creates a repository
*
* @author Kohsuke Kawaguchi
*/
public class GHCreateRepositoryBuilder extends GHRepositoryBuilder&lt;GHCreateRepositoryBuilder&gt; {
public GHCreateRepositoryBuilder(String name, GitHub root, String apiTail) {
<span class="fc" id="L15"> super(GHCreateRepositoryBuilder.class, root, null);</span>
<span class="fc" id="L16"> requester.method(&quot;POST&quot;).withUrlPath(apiTail);</span>
try {
<span class="fc" id="L19"> name(name);</span>
<span class="nc" id="L20"> } catch (IOException e) {</span>
// not going to happen here
<span class="fc" id="L22"> }</span>
<span class="fc" id="L23"> }</span>
/**
* Creates a default .gitignore
*
* @param language
* template to base the ignore file on
* @return a builder to continue with building See https://developer.github.com/v3/repos/#create
* @throws IOException
* In case of any networking error or error from the server.
*/
public GHCreateRepositoryBuilder gitignoreTemplate(String language) throws IOException {
<span class="nc" id="L35"> return with(&quot;gitignore_template&quot;, language);</span>
}
/**
* Desired license template to apply
*
* @param license
* template to base the license file on
* @return a builder to continue with building See https://developer.github.com/v3/repos/#create
* @throws IOException
* In case of any networking error or error from the server.
*/
public GHCreateRepositoryBuilder licenseTemplate(String license) throws IOException {
<span class="nc" id="L48"> return with(&quot;license_template&quot;, license);</span>
}
/**
* If true, create an initial commit with empty README.
*
* @param enabled
* true if enabled
* @return a builder to continue with building
* @throws IOException
* In case of any networking error or error from the server.
*/
public GHCreateRepositoryBuilder autoInit(boolean enabled) throws IOException {
<span class="fc" id="L61"> return with(&quot;auto_init&quot;, enabled);</span>
}
/**
* The team that gets granted access to this repository. Only valid for creating a repository in an organization.
*
* @param team
* team to grant access to
* @return a builder to continue with building
* @throws IOException
* In case of any networking error or error from the server.
*/
public GHCreateRepositoryBuilder team(GHTeam team) throws IOException {
<span class="pc bpc" id="L74" title="1 of 2 branches missed."> if (team != null)</span>
<span class="fc" id="L75"> return with(&quot;team_id&quot;, team.getId());</span>
<span class="nc" id="L76"> return this;</span>
}
/**
* Specifies whether the repository is a template.
*
* @param enabled
* true if enabled
* @return a builder to continue with building
* @throws IOException
* In case of any networking error or error from the server.
* @deprecated Use {@link #isTemplate(boolean)} method instead
*/
@Deprecated
public GHCreateRepositoryBuilder templateRepository(boolean enabled) throws IOException {
<span class="nc" id="L91"> return isTemplate(enabled);</span>
}
/**
* Specifies the ownership of the repository.
*
* @param owner
* organization or personage
* @return a builder to continue with building
* @throws IOException
* In case of any networking error or error from the server.
*/
public GHCreateRepositoryBuilder owner(String owner) throws IOException {
<span class="fc" id="L104"> return with(&quot;owner&quot;, owner);</span>
}
/**
* Create repository from template repository
*
* @param templateOwner
* template repository owner
* @param templateRepo
* template repository
* @return a builder to continue with building
* @see &lt;a href=&quot;https://developer.github.com/v3/previews/&quot;&gt;GitHub API Previews&lt;/a&gt;
*/
@Preview(BAPTISTE)
@Deprecated
public GHCreateRepositoryBuilder fromTemplateRepository(String templateOwner, String templateRepo) {
<span class="fc" id="L120"> requester.withPreview(BAPTISTE).withUrlPath(&quot;/repos/&quot; + templateOwner + &quot;/&quot; + templateRepo + &quot;/generate&quot;);</span>
<span class="fc" id="L121"> return this;</span>
}
/**
* Creates a repository with all the parameters.
*
* @return the gh repository
* @throws IOException
* if repository cannot be created
*/
public GHRepository create() throws IOException {
<span class="fc" id="L132"> return done();</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>