mirror of
https://github.com/jlengrand/github-api.git
synced 2026-04-01 08:21:24 +00:00
262 lines
10 KiB
HTML
262 lines
10 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 java.net.URL;
|
|
|
|
import static org.kohsuke.github.Previews.BAPTISE;
|
|
|
|
/**
|
|
* Creates a repository
|
|
*
|
|
* @author Kohsuke Kawaguchi
|
|
*/
|
|
public class GHCreateRepositoryBuilder {
|
|
private final GitHub root;
|
|
protected final Requester builder;
|
|
private String apiUrlTail;
|
|
|
|
<span class="fc" id="L18"> GHCreateRepositoryBuilder(GitHub root, String apiUrlTail, String name) {</span>
|
|
<span class="fc" id="L19"> this.root = root;</span>
|
|
<span class="fc" id="L20"> this.apiUrlTail = apiUrlTail;</span>
|
|
<span class="fc" id="L21"> this.builder = root.createRequest();</span>
|
|
<span class="fc" id="L22"> this.builder.with("name", name);</span>
|
|
<span class="fc" id="L23"> }</span>
|
|
|
|
/**
|
|
* Description for repository
|
|
*
|
|
* @param description
|
|
* description of repository
|
|
* @return a builder to continue with building
|
|
*/
|
|
public GHCreateRepositoryBuilder description(String description) {
|
|
<span class="fc" id="L33"> this.builder.with("description", description);</span>
|
|
<span class="fc" id="L34"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Homepage for repository
|
|
*
|
|
* @param homepage
|
|
* homepage of repository
|
|
* @return a builder to continue with building
|
|
*/
|
|
public GHCreateRepositoryBuilder homepage(URL homepage) {
|
|
<span class="nc" id="L45"> return homepage(homepage.toExternalForm());</span>
|
|
}
|
|
|
|
/**
|
|
* Homepage for repository
|
|
*
|
|
* @param homepage
|
|
* homepage of repository
|
|
* @return a builder to continue with building
|
|
*/
|
|
public GHCreateRepositoryBuilder homepage(String homepage) {
|
|
<span class="fc" id="L56"> this.builder.with("homepage", homepage);</span>
|
|
<span class="fc" id="L57"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Creates a private repository
|
|
*
|
|
* @param enabled
|
|
* private if true
|
|
* @return a builder to continue with building
|
|
*/
|
|
public GHCreateRepositoryBuilder private_(boolean enabled) {
|
|
<span class="fc" id="L68"> this.builder.with("private", enabled);</span>
|
|
<span class="fc" id="L69"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Enables issue tracker
|
|
*
|
|
* @param enabled
|
|
* true if enabled
|
|
* @return a builder to continue with building
|
|
*/
|
|
public GHCreateRepositoryBuilder issues(boolean enabled) {
|
|
<span class="nc" id="L80"> this.builder.with("has_issues", enabled);</span>
|
|
<span class="nc" id="L81"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Enables projects
|
|
*
|
|
* @param enabled
|
|
* true if enabled
|
|
* @return a builder to continue with building
|
|
*/
|
|
public GHCreateRepositoryBuilder projects(boolean enabled) {
|
|
<span class="nc" id="L92"> this.builder.with("has_projects", enabled);</span>
|
|
<span class="nc" id="L93"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Enables wiki
|
|
*
|
|
* @param enabled
|
|
* true if enabled
|
|
* @return a builder to continue with building
|
|
*/
|
|
public GHCreateRepositoryBuilder wiki(boolean enabled) {
|
|
<span class="nc" id="L104"> this.builder.with("has_wiki", enabled);</span>
|
|
<span class="nc" id="L105"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Enables downloads
|
|
*
|
|
* @param enabled
|
|
* true if enabled
|
|
* @return a builder to continue with building
|
|
*/
|
|
public GHCreateRepositoryBuilder downloads(boolean enabled) {
|
|
<span class="nc" id="L116"> this.builder.with("has_downloads", enabled);</span>
|
|
<span class="nc" id="L117"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* If true, create an initial commit with empty README.
|
|
*
|
|
* @param enabled
|
|
* true if enabled
|
|
* @return a builder to continue with building
|
|
*/
|
|
public GHCreateRepositoryBuilder autoInit(boolean enabled) {
|
|
<span class="fc" id="L128"> this.builder.with("auto_init", enabled);</span>
|
|
<span class="fc" id="L129"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Allow or disallow squash-merging pull requests.
|
|
*
|
|
* @param enabled
|
|
* true if enabled
|
|
* @return a builder to continue with building
|
|
*/
|
|
public GHCreateRepositoryBuilder allowSquashMerge(boolean enabled) {
|
|
<span class="nc" id="L140"> this.builder.with("allow_squash_merge", enabled);</span>
|
|
<span class="nc" id="L141"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Allow or disallow merging pull requests with a merge commit.
|
|
*
|
|
* @param enabled
|
|
* true if enabled
|
|
* @return a builder to continue with building
|
|
*/
|
|
public GHCreateRepositoryBuilder allowMergeCommit(boolean enabled) {
|
|
<span class="nc" id="L152"> this.builder.with("allow_merge_commit", enabled);</span>
|
|
<span class="nc" id="L153"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Allow or disallow rebase-merging pull requests.
|
|
*
|
|
* @param enabled
|
|
* true if enabled
|
|
* @return a builder to continue with building
|
|
*/
|
|
public GHCreateRepositoryBuilder allowRebaseMerge(boolean enabled) {
|
|
<span class="nc" id="L164"> this.builder.with("allow_rebase_merge", enabled);</span>
|
|
<span class="nc" id="L165"> return this;</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
|
|
*/
|
|
public GHCreateRepositoryBuilder gitignoreTemplate(String language) {
|
|
<span class="nc" id="L176"> this.builder.with("gitignore_template", language);</span>
|
|
<span class="nc" id="L177"> return this;</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
|
|
*/
|
|
public GHCreateRepositoryBuilder licenseTemplate(String license) {
|
|
<span class="nc" id="L188"> this.builder.with("license_template", license);</span>
|
|
<span class="nc" id="L189"> return this;</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
|
|
*/
|
|
public GHCreateRepositoryBuilder team(GHTeam team) {
|
|
<span class="pc bpc" id="L200" title="1 of 2 branches missed."> if (team != null)</span>
|
|
<span class="fc" id="L201"> this.builder.with("team_id", team.getId());</span>
|
|
<span class="fc" id="L202"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Specifies whether the repository is a template.
|
|
*
|
|
* @param enabled
|
|
* true if enabled
|
|
* @return a builder to continue with building
|
|
*/
|
|
@Preview
|
|
@Deprecated
|
|
public GHCreateRepositoryBuilder templateRepository(boolean enabled) {
|
|
<span class="fc" id="L215"> this.builder.withPreview(BAPTISE);</span>
|
|
<span class="fc" id="L216"> this.builder.with("is_template", enabled);</span>
|
|
<span class="fc" id="L217"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Specifies the ownership of the repository.
|
|
*
|
|
* @param owner
|
|
* organization or personage
|
|
* @return a builder to continue with building
|
|
*/
|
|
public GHCreateRepositoryBuilder owner(String owner) {
|
|
<span class="fc" id="L228"> this.builder.with("owner", owner);</span>
|
|
<span class="fc" id="L229"> return this;</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
|
|
@Deprecated
|
|
public GHCreateRepositoryBuilder fromTemplateRepository(String templateOwner, String templateRepo) {
|
|
<span class="fc" id="L245"> this.builder.withPreview(BAPTISE);</span>
|
|
<span class="fc" id="L246"> this.apiUrlTail = "/repos/" + templateOwner + "/" + templateRepo + "/generate";</span>
|
|
<span class="fc" id="L247"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Creates a repository with all the parameters.
|
|
*
|
|
* @return the gh repository
|
|
* @throws IOException
|
|
* if repsitory cannot be created
|
|
*/
|
|
public GHRepository create() throws IOException {
|
|
<span class="fc" id="L258"> return builder.method("POST").withUrlPath(apiUrlTail).fetch(GHRepository.class).wrap(root);</span>
|
|
}
|
|
|
|
}
|
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.5.201910111838</span></div></body></html> |