Exemplo n.º 1
0
 /**
  * Gets org.eclipse.jgit.lib.Repository object for existing Git Repository.
  *
  * @param repositoryPath the path to an existing Git Repository
  * @return {@link org.eclipse.jgit.lib.Repository} object
  * @throws IOException
  */
 public static Repository getRepository(String repositoryPath) throws IOException {
   RepositoryBuilder repositoryBuilder = new RepositoryBuilder();
   repositoryBuilder.findGitDir(new File(repositoryPath));
   Repository repository = repositoryBuilder.build();
   repository.getConfig().setString(BRANCH, MASTER, MERGE, REFS_HEADS_MASTER);
   return repository;
 }
Exemplo n.º 2
0
  /**
   * Initialize a new git repository.
   *
   * @param dir The directory in which to create a new .git/ folder and repository.
   */
  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;
  }
Exemplo n.º 3
0
 public static Git git(final DirectoryResource dir) throws IOException {
   RepositoryBuilder db = new RepositoryBuilder().findGitDir(dir.getUnderlyingResourceObject());
   return new Git(db.build());
 }
Exemplo n.º 4
0
 public Repository createRepository(File fullPath) throws IOException {
   RepositoryBuilder builder = new RepositoryBuilder();
   builder.setGitDir(fullPath);
   return builder.build();
 }