/** * Return a command object to execute a {@code init} command * * @see <a href= * "http://www.kernel.org/pub/software/scm/git/docs/git-init.html" >Git * documentation about init</a> * @return a {@link org.eclipse.jgit.api.InitCommand} used to collect all * optional parameters and to finally execute the {@code init} * command */ public static InitCommand init() { return new InitCommand(); }
/** * Returns a command object to execute a {@code init} command * * @see <a * href="http://www.kernel.org/pub/software/scm/git/docs/git-init.html" * >Git documentation about init</a> * @return a {@link InitCommand} used to collect all optional parameters and * to finally execute the {@code init} command */ public static InitCommand init() { return new InitCommand(); }
/** * Return a command object to execute a {@code init} command * * @see <a href= * "http://www.kernel.org/pub/software/scm/git/docs/git-init.html" >Git * documentation about init</a> * @return a {@link org.eclipse.jgit.api.InitCommand} used to collect all * optional parameters and to finally execute the {@code init} * command */ public static InitCommand init() { return new InitCommand(); }
public Repository createCommit(File srcFolder, String applicationName) throws IOException, GitAPIException { Repository repository = repositoryService.createRepository(new Repository().setName(applicationName)); String cloneUrl = repository.getCloneUrl(); InitCommand init = new InitCommand(); init.setDirectory(srcFolder); init.setBare(false); Git git = init.call(); StoredConfig config = git.getRepository().getConfig(); config.setString("remote", "origin", "url", cloneUrl); config.save(); UsernamePasswordCredentialsProvider user = new UsernamePasswordCredentialsProvider(accessToken, ""); git.add().addFilepattern(".").call(); git.commit().setMessage(COMMIT_MESSAGE).call(); git.push().setCredentialsProvider(user).call(); return repository; } }