Package org.eclipse.jgit.storage.file

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


    } catch (Exception e) {
      e.printStackTrace();
    }
    this.branchName = branchName;
    // Setting up the Git Repo
    FileRepositoryBuilder builder = new FileRepositoryBuilder();
    this.repository = builder
        .setGitDir(new File(prop.getProperty("path").trim()))
        .readEnvironment() // scan environment GIT_* variables
        .findGitDir() // scan up the file system tree
        .build();
    this.git = new Git(repository);
View Full Code Here


    private Map<ObjectId, Status> fetched = new HashMap<ObjectId, Status>();

    public Status getStatus(File sourceDirectory) throws IOException {

        final FileRepository repository = new FileRepositoryBuilder()
                .readEnvironment()
                .findGitDir(sourceDirectory)
                .build();

        ObjectId head = repository.resolve("HEAD");
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

    return treeParser;
  }

  private static Repository openGitRepository() throws IOException {

    FileRepositoryBuilder repoBuilder = new FileRepositoryBuilder();
    Repository repo = repoBuilder.readEnvironment().findGitDir().build();

    return repo;
  }
View Full Code Here

    @Before
    public void setup() throws Exception {
        this.repo = mock(Repository.class, RETURNS_DEEP_STUBS);

        FileRepositoryBuilder repoBuilder = mock(FileRepositoryBuilder.class);
        whenNew(FileRepositoryBuilder.class).withNoArguments().thenReturn(repoBuilder);
        when(repoBuilder.build()).thenReturn(this.repo);

        File someDir = mock(File.class);
        when(someDir.exists()).thenReturn(true);

        this.repository = new JGitRepository(someDir, someDir);
View Full Code Here

     * @param workTree The worktree of the repository or {@code null}
     * @param gitDir The GIT_DIR of the repository or {@code null}
     */
    public JGitRepository(File workTree, File gitDir)
            throws GitRepositoryException {
        FileRepositoryBuilder repositoryBuilder = new FileRepositoryBuilder();
        repositoryBuilder.readEnvironment();

        if (gitDir == null && workTree == null) {
            throw new GitRepositoryException("Neither worktree nor GIT_DIR is set.");
        } else {
            if (workTree != null && !workTree.exists()) {
                throw new GitRepositoryException("The worktree " + workTree + " does not exist");
            }
            if (gitDir != null && !gitDir.exists()) {
                throw new GitRepositoryException("The GIT_DIR " + gitDir + " does not exist");
            }
        }

        repositoryBuilder.setWorkTree(workTree);
        if (gitDir != null) {
            repositoryBuilder.setGitDir(gitDir);
        } else {
            repositoryBuilder.findGitDir(workTree);

            if (repositoryBuilder.getGitDir() == null) {
                throw new GitRepositoryException(workTree + " is not inside a Git repository. Please specify the GIT_DIR separately.");
            }
        }

        try {
            this.repository = repositoryBuilder.build();
        } catch (IOException e) {
            throw new GitRepositoryException("Could not initialize repository", e);
        }

        this.commitCache = new HashMap<ObjectId, RevCommit>();
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

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

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

   
  @Override
    public Repository openRepository() throws IOException {
        File rd = getRepositoryDir();
        // TODO 7: should we cache r here?  Who will be closing r?
        FileRepository r = new FileRepositoryBuilder().setWorkTree(rd).build();

        if (!r.getObjectDatabase().exists()){
          r.create();
         
          try {
View Full Code Here

      GitTraceLocation.getTrace().trace(
          GitTraceLocation.CORE.getLocation(),
          "Looking at candidate dir: " //$NON-NLS-1$
              + path);

    FileRepositoryBuilder builder = new FileRepositoryBuilder();
    File parent = path.getParentFile();
    if (parent != null)
      builder.addCeilingDirectory(parent);
    builder.findGitDir(path);
    File gitDir = builder.getGitDir();
    if (gitDir != null)
      register(container, gitDir);
  }
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.