Package org.eclipse.jgit.api

Examples of org.eclipse.jgit.api.CloneCommand


        if (!gitDir.exists()) {
            String repo = getRemoteRepository();
            if (Strings.isNotBlank(repo) && isCloneRemoteRepoOnStartup()) {
                boolean cloneAll = isCloneAllBranches();
                LOG.info("Cloning git repo " + repo + " into directory " + confDir.getCanonicalPath() + " cloneAllBranches: " + cloneAll);
                CloneCommand command = Git.cloneRepository().setCredentialsProvider(getCredentials()).
                        setCloneAllBranches(cloneAll).setURI(repo).setDirectory(confDir).setRemote(remote);
                try {
                    git = command.call();
                    return;
                } catch (Throwable e) {
                    LOG.error("Failed to command remote repo " + repo + " due: " + e.getMessage(), e);
                    // lets just use an empty repo instead
                }
View Full Code Here


  }

    private Git clone(Application application, File fileLocation) {
        Git git = null;
        try {
            CloneCommand clone = Git.cloneRepository();
            clone.setURI(application.getRepositoryUrl())
                    .setDirectory(fileLocation);
            if (application.getRepositoryEncryptedUserName() != null
                    && application.getRepositoryEncryptedPassword() != null) {
                decryptRepositoryCredentials(application);
                UsernamePasswordCredentialsProvider credentials = new UsernamePasswordCredentialsProvider(application.getRepositoryUserName(),
                        application.getRepositoryPassword());
                clone.setCredentialsProvider(credentials);
            }

            if (application.getRepositoryBranch() != null) {
                application.setRepositoryDBBranch(application.getRepositoryBranch());
                clone.call()
                        .checkout()
                        .setCreateBranch(true)
                        .setName(application.getRepositoryBranch())
                        .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK)
                        .setStartPoint(application.getRepositoryBranch()).call();
            } else {
                git = clone.call();
            }
        } catch (WrongRepositoryStateException | InvalidConfigurationException | DetachedHeadException |
                InvalidRemoteException | CanceledException | RefNotFoundException | NoHeadException |
                RefAlreadyExistsException | CheckoutConflictException | InvalidRefNameException |
                TransportException e) {
View Full Code Here

        if (log.isLoggable(Level.FINE)) {
            log.fine("Preparing to clone " + configuration.getRemoteRepositoryUri() + " to " + repository.getAbsolutePath());
        }

        CloneCommand cloneCmd = Git.cloneRepository();
        cloneCmd.setDirectory(repository).setURI(configuration.getRemoteRepositoryUri());
        cloneCmd.setCredentialsProvider(credentialsProvider);

        this.git = new GitUtil(cloneCmd.call());
        this.markingUtil = new MarkingUtil(git);

        if (log.isLoggable(Level.FINE)) {
            log.fine("Cloned remote repository from " + configuration.getRemoteRepositoryUri() + " to "
                    + repository.getAbsolutePath());
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.api.CloneCommand

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.