Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.RepositoryBuilder


      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 IllegalArgumentException, 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

    InternalLocalFetchConnection() throws TransportException {
      super(TransportLocal.this);

      final Repository dst;
      try {
        dst = new RepositoryBuilder().setGitDir(remoteGitDir).build();
      } catch (IOException err) {
        throw new TransportException(uri, JGitText.get().notAGitDirectory);
      }

      final PipedInputStream in_r;
View Full Code Here

    InternalLocalPushConnection() throws TransportException {
      super(TransportLocal.this);

      final Repository dst;
      try {
        dst = new RepositoryBuilder().setGitDir(remoteGitDir).build();
      } catch (IOException err) {
        throw new TransportException(uri, JGitText.get().notAGitDirectory);
      }

      final PipedInputStream in_r;
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("."); //$NON-NLS-1$
        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

   * @return the repository to operate on.
   * @throws IOException
   *             the repository cannot be opened.
   */
  protected Repository openGitDir(String aGitdir) throws IOException {
    RepositoryBuilder rb = new RepositoryBuilder() //
        .setGitDir(aGitdir != null ? new File(aGitdir) : null) //
        .readEnvironment() //
        .findGitDir();
    if (rb.getGitDir() == null)
      throw new Die(CLIText.get().cantFindGitDirectory);
    return rb.build();
  }
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

    mxBean = ManagementFactory.getThreadMXBean();
    if (!mxBean.isCurrentThreadCpuTimeSupported())
      throw die("Current thread CPU time not supported on this JRE");

    if (gitDirs.isEmpty()) {
      RepositoryBuilder rb = new RepositoryBuilder() //
          .setGitDir(new File(gitdir)) //
          .readEnvironment() //
          .findGitDir();
      if (rb.getGitDir() == null)
        throw die(CLIText.get().cantFindGitDirectory);
      gitDirs.add(rb.getGitDir());
    }

    for (File dir : gitDirs) {
      RepositoryBuilder rb = new RepositoryBuilder();
      if (RepositoryCache.FileKey.isGitRepository(dir, FS.DETECTED))
        rb.setGitDir(dir);
      else
        rb.findGitDir(dir);

      Repository db = rb.build();
      try {
        run(db);
      } finally {
        db.close();
      }
View Full Code Here

  }

  @Override
  protected void run() throws Exception {
    if (gitDirs.isEmpty()) {
      RepositoryBuilder rb = new RepositoryBuilder() //
          .setGitDir(new File(gitdir)) //
          .readEnvironment() //
          .findGitDir();
      if (rb.getGitDir() == null)
        throw die(CLIText.get().cantFindGitDirectory);
      gitDirs.add(rb.getGitDir());
    }

    for (File dir : gitDirs) {
      RepositoryBuilder rb = new RepositoryBuilder();
      if (RepositoryCache.FileKey.isGitRepository(dir, FS.DETECTED))
        rb.setGitDir(dir);
      else
        rb.findGitDir(dir);

      Repository db = rb.build();
      try {
        run(db);
      } finally {
        db.close();
      }
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.