Package org.eclipse.jgit.storage.file

Examples of org.eclipse.jgit.storage.file.FileRepositoryBuilder


public class FetchRepositoryFunction extends MyFunction<Context, Context> {
    private static ESLogger logger = Loggers.getLogger(FetchRepositoryFunction.class);

    @Override
    public Context doApply(Context context) throws Throwable {
        final Repository repository = new FileRepositoryBuilder()
            .setGitDir(context.getProjectPath())
                // scan environment GIT_* variables
            .readEnvironment()
            .findGitDir()
            .setMustExist(true)
View Full Code Here


    private static ESLogger logger = Loggers.getLogger(FetchOrCloneRepositoryPredicate.class);

    @Override
    public boolean apply(Context context) {
        try {
            final Repository repository = new FileRepositoryBuilder()
                .setGitDir(context.getProjectPath())
                .readEnvironment()
                .findGitDir()
                .setMustExist(false)
                .build();
View Full Code Here

  @Override
  public void execute() throws BuildException {
    CheckoutCommand checkout;
    try {
      Repository repo = new FileRepositoryBuilder().readEnvironment()
          .findGitDir(src).build();
      checkout = new Git(repo).checkout();
    } catch (IOException e) {
      throw new BuildException("Could not access repository " + src, e);
    }
View Full Code Here

   *             the repository appears to already exist but cannot be
   *             accessed.
   * @see FileRepositoryBuilder
   */
  public FileRepository(final File gitDir) throws IOException {
    this(new FileRepositoryBuilder().setGitDir(gitDir).setup());
  }
View Full Code Here

            LOG.info("Cloning remote repo " + repo);
            CloneCommand command = Git.cloneRepository().setCredentialsProvider(credentials).
                    setURI(repo).setDirectory(localRepo).setRemote(remoteName);
            git = command.call();
        } else {
            FileRepositoryBuilder builder = new FileRepositoryBuilder();
            Repository repository = builder.setGitDir(gitDir)
                    .readEnvironment() // scan environment GIT_* variables
                    .findGitDir() // scan up the file system tree
                    .build();

            git = new Git(repository);
View Full Code Here

            String branch = git.getRepository().getBranch();
            configureBranch(branch);
        } else {
            getLog().info("Reusing existing git repository at " + getGitBuildPathDescription());

            FileRepositoryBuilder builder = new FileRepositoryBuilder();
            Repository repository = builder.setGitDir(gitDir)
                    .readEnvironment() // scan environment GIT_* variables
                    .findGitDir() // scan up the file system tree
                    .build();

            git = new Git(repository);
View Full Code Here

        this.configDirectory = configDirectory;
    }

    public void initialiseGitRepo() throws IOException, GitAPIException {
        File confDir = getRootGitDirectory();
        FileRepositoryBuilder builder = new FileRepositoryBuilder();
        File gitDir = new File(confDir, ".git");
        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
                }
            } else if (!isCloneRemoteRepoOnStartup()) {
                LOG.info("Clone git repo on startup disabled");
            }
            InitCommand initCommand = Git.init();
            initCommand.setDirectory(confDir);
            git = initCommand.call();
            LOG.info("Initialised an empty git configuration repo at {}", confDir.getCanonicalPath());

            String branch = git.getRepository().getBranch();
            configureBranch(branch);

            importInitialContent(git, confDir, branch);
        } else {
            Repository repository = builder.setGitDir(gitDir)
                    .readEnvironment() // scan environment GIT_* variables
                    .findGitDir() // scan up the file system tree
                    .build();

            git = new Git(repository);
View Full Code Here

    }

    private final Repository buildRepository(final Project project) {
        try {
            final File projectDir = project.getProjectDir();
            final FileRepositoryBuilder repoBuilder = new FileRepositoryBuilder().readEnvironment().findGitDir(projectDir);
            if (repoBuilder.getGitDir() == null) {
                throw new ReleaseException("No git directory found!");
            }
            return repoBuilder.build();
        }
        catch (IOException e) {
            throw new IllegalStateException(e);
        }
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.storage.file.FileRepositoryBuilder

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.