Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.RepositoryBuilder


        String wcPath
                = GitRepository.getRepoForMergingPrefix() + project.owner + "/" + project.name +
                ".git";
        File repoDir = new File(
                GitRepository.getDirectoryForMerging(project.owner, project.name) + "/.git");
        Repository repo = new RepositoryBuilder().setGitDir(repoDir).build();
        repo.create(false);

        // when
        baseCommit = support.Git.commit(repo, wcPath, "a.txt", "read me", "base commit");
        firstCommit = support.Git.commit(repo, wcPath, "a.txt", "hello", "commit 1");
View Full Code Here


   *
   * @return the newly created {@code Git} object with associated repository
   */
  public Git call() throws GitAPIException {
    try {
      RepositoryBuilder builder = new RepositoryBuilder();
      if (bare)
        builder.setBare();
      builder.readEnvironment();
      if (directory != null) {
        File d = directory;
        if (!bare)
          d = new File(d, Constants.DOT_GIT);
        builder.setGitDir(d);
      } else if (builder.getGitDir() == null) {
        File d = new File(".");
        if (d.getParentFile() != null)
          d = d.getParentFile();
        if (!bare)
          d = new File(d, Constants.DOT_GIT);
        builder.setGitDir(d);
      }
      Repository repository = builder.build();
      if (!repository.getObjectDatabase().exists())
        repository.create(bare);
      return new Git(repository);
    } catch (IOException e) {
      throw new JGitInternalException(e.getMessage(), e);
View Full Code Here

   */
  public static Git open(File dir, FS fs) throws IOException {
    RepositoryCache.FileKey key;

    key = RepositoryCache.FileKey.lenient(dir, fs);
    return wrap(new RepositoryBuilder().setFS(fs).setGitDir(key.getFile())
        .setMustExist(true).build());
  }
View Full Code Here

    File subWorkTree = new File(parent, path);
    if (!subWorkTree.isDirectory())
      return null;
    File workTree = new File(parent, path);
    try {
      return new RepositoryBuilder() //
          .setMustExist(true) //
          .setFS(FS.DETECTED) //
          .setWorkTree(workTree) //
          .build();
    } catch (RepositoryNotFoundException e) {
View Full Code Here

      return git;
   }

   public static Git git(final DirectoryResource dir) throws IOException
   {
      RepositoryBuilder db = new RepositoryBuilder().findGitDir(dir.getUnderlyingResourceObject());
      return new Git(db.build());
   }
View Full Code Here

   public static Git init(final DirectoryResource dir) throws IOException
   {
      FileResource<?> gitDir = dir.getChildDirectory(".git").reify(FileResource.class);
      gitDir.mkdirs();

      RepositoryBuilder db = new RepositoryBuilder().setGitDir(gitDir.getUnderlyingResourceObject()).setup();
      Git git = new Git(db.build());
      git.getRepository().create();
      return git;
   }
View Full Code Here

      }
    } else {
      File gitRepo = stagingDirectory;
      Repository r = null;
     
      RepositoryBuilder b = new RepositoryBuilder().setGitDir(stagingDirectory).setWorkTree(sourceDirectory);

      if (!gitRepo.exists()) {
        gitRepo.getParentFile().mkdirs();
       
        r = b.build();
       
        r.create();
      } else {
        r = b.build();
      }
     
      git = Git.wrap(r);
    }
   
View Full Code Here

        treeItem.setText(0, path.toString());
      }
      treeItem.setText(2, relativePath.toOSString());
      try {
        IProject project = m.getContainer().getProject();
        Repository repo = new RepositoryBuilder().setGitDir(
            m.getGitDirAbsolutePath().toFile()).build();
        File workTree = repo.getWorkTree();
        IPath workTreePath = Path.fromOSString(workTree
            .getAbsolutePath());
        if (workTreePath.isPrefixOf(project.getLocation())) {
View Full Code Here

  protected File createProjectAndCommitToRepository(String repoName)
      throws Exception {

    File gitDir = new File(new File(testDirectory, repoName),
        Constants.DOT_GIT);
    Repository myRepository = new RepositoryBuilder().setGitDir(gitDir)
        .build();
    myRepository.create();

    // we need to commit into master first
    IProject firstProject = ResourcesPlugin.getWorkspace().getRoot()
View Full Code Here

  private TestRepository<Repository> createRepository() throws Exception {
    String gitdirName = "test" + System.currentTimeMillis()
        + Constants.DOT_GIT;
    File gitdir = new File(trash, gitdirName).getCanonicalFile();
    Repository db = new RepositoryBuilder().setGitDir(gitdir).build();
    assertFalse(gitdir.exists());
    db.create();
    return new TestRepository<Repository>(db);
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.lib.RepositoryBuilder

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.