mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-15 08:21:23 +00:00
135 lines
6.2 KiB
HTML
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> > <a href="index.source.html" class="el_package">org.kohsuke.github</a> > <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<GHCreateRepositoryBuilder> {
|
|
|
|
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("POST").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("gitignore_template", 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("license_template", 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("auto_init", 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("team_id", 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("owner", owner);</span>
|
|
}
|
|
|
|
/**
|
|
* Create repository from template repository
|
|
*
|
|
* @param templateOwner
|
|
* template repository owner
|
|
* @param templateRepo
|
|
* template repository
|
|
* @return a builder to continue with building
|
|
* @see <a href="https://developer.github.com/v3/previews/">GitHub API Previews</a>
|
|
*/
|
|
@Preview(BAPTISTE)
|
|
@Deprecated
|
|
public GHCreateRepositoryBuilder fromTemplateRepository(String templateOwner, String templateRepo) {
|
|
<span class="fc" id="L120"> requester.withPreview(BAPTISTE).withUrlPath("/repos/" + templateOwner + "/" + templateRepo + "/generate");</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> |