Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.RepositoryBuilder


  }

  @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


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

      }
    } 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

      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

   *             if the repository can't be created
   * @return the newly created {@code Git} object with associated repository
   */
  public Git call() throws JGitInternalException {
    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 (!bare)
          d = new File(d, Constants.DOT_GIT);
        builder.setGitDir(d);
      }
      Repository repository = builder.build();
      repository.create(bare);
      return new Git(repository);
    } catch (IOException e) {
      throw new JGitInternalException(e.getMessage(), e);
    }
View Full Code Here

     */
    public static JGitFlow get(File projectDir) throws JGitFlowIOException
    {
        try
        {
            RepositoryBuilder rb = new RepositoryBuilder()
                    .readEnvironment()
                    .findGitDir(projectDir);

            File gitDir = rb.getGitDir();
            Git gitRepo = Git.open(gitDir);
            GitFlowConfiguration gfConfig = new GitFlowConfiguration(gitRepo);
            return new JGitFlow(gitRepo, gfConfig);
        }
        catch (IOException e)
View Full Code Here

    public static boolean isInitialized(File dir)
    {
        boolean inited = false;
        try
        {
            RepositoryBuilder rb = new RepositoryBuilder()
                    .readEnvironment()
                    .findGitDir(dir);
           
            File gitDir = rb.getGitDir();
            if (gitDir != null)
            {
                Git gitRepo = Git.open(gitDir);
                GitFlowConfiguration gfConfig = new GitFlowConfiguration(gitRepo);
                inited = gfConfig.gitFlowIsInitialized();
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

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.