Examples of FileRepository


Examples of org.eclipse.jgit.internal.storage.file.FileRepository

   * @throws IOException
   *             the repository could not be created in the temporary area
   */
  private FileRepository createRepository(boolean bare) throws IOException {
    File gitdir = createUniqueTestGitDir(bare);
    FileRepository db = new FileRepository(gitdir);
    assertFalse(gitdir.exists());
    db.create();
    toClose.add(db);
    return db;
  }
View Full Code Here

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

            dotGit = gitRoot;
        } else {
            dotGit = new File(gitRoot, Constants.DOT_GIT);
        }

        FileRepository repository = localRepos.get(dotGit);
        if (repository != null && dotGit.exists()) {
            return repository;
        }

        if (!dotGit.exists()) {
            Git.cloneRepository().setDirectory(gitRoot).setCloneAllBranches(true).setURI(gitUrl).call();
            FileBasedConfig config = new FileBasedConfig(new File(dotGit, "config"), FS.DETECTED);
            config.load();
            if (gitPushUrl != null) {
                config.setString(ConfigConstants.CONFIG_REMOTE_SECTION, "origin", "pushurl", gitPushUrl);
            }
            config.save();
        }

        FileRepositoryBuilder builder = new FileRepositoryBuilder();
        repository = builder.setGitDir(dotGit).readEnvironment().findGitDir().build();
        localRepos.put(dotGit, repository);
        try {
            repository.incrementOpen();
            Git git = Git.wrap(repository);

            // Check branch
            boolean pull = true;
            String currentBranch = repository.getBranch();
            if (branch != null && !branch.equals(currentBranch)) {
                CheckoutCommand checkout = git.checkout();
                if (!branchExists(git, branch)) {
                    checkout.setCreateBranch(true);
                    pull = false;
                }
                checkout.setName(branch);
                checkout.call();
            }
            if (pull) {
                git.pull().call();
            } else {
                git.fetch().call();
            }
        } catch (Exception e) {
            if (!(e.getCause() instanceof TransportException)) {
                throw new RuntimeException(e);
            }
        } finally {
            if (repository != null) {
                repository.close();
            }
        }

        return repository;
    }
View Full Code Here

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

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

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

      final PipedInputStream in_r;
View Full Code Here

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

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

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

      final PipedInputStream in_r;
View Full Code Here

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

   *             the repository could not be accessed to configure the rest of
   *             the builder's parameters.
   */
  @SuppressWarnings("unchecked")
  public R build() throws IOException {
    R repo = (R) new FileRepository(setup());
    if (isMustExist() && !repo.getObjectDatabase().exists())
      throw new RepositoryNotFoundException(getGitDir());
    return repo;
  }
View Full Code Here

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

   {
      try
      {
         final URIish uri = new URIish(sourceUri);
         File gitdir = new File(projectDir, Constants.DOT_GIT);
         db = new FileRepository(gitdir);
         db.create();
         final FileBasedConfig dstcfg = db.getConfig();
         dstcfg.setBoolean("core", null, "bare", false);
         dstcfg.save();
View Full Code Here

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

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

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

      final PipedInputStream in_r;
View Full Code Here

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

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

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

      final PipedInputStream in_r;
View Full Code Here

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

   *             the repository could not be accessed to configure the rest of
   *             the builder's parameters.
   */
  @SuppressWarnings("unchecked")
  public R build() throws IOException {
    R repo = (R) new FileRepository(setup());
    if (isMustExist() && !repo.getObjectDatabase().exists())
      throw new RepositoryNotFoundException(getGitDir());
    return repo;
  }
View Full Code Here

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

                                              new UsernamePasswordCredentialsProvider(
                                                                                      System.getProperty(CartridgeConstants.INTERNAL_GIT_USERNAME),
                                                                                      System.getProperty(CartridgeConstants.INTERNAL_GIT_PASSWORD).toCharArray());
    // Clone
    // --------------------------
    FileRepository localRepo = null;
    try {
      localRepo = new FileRepository(new File(parentDirName + "/.git"));
    } catch (IOException e) {
      log.error("Exception occurred in creating a new file repository. Reason: " + e.getMessage());
      throw e;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.