Package org.eclipse.jgit.internal.storage.file

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


    }

    public Repository open(final boolean mustExist) throws IOException {
      if (mustExist && !isGitRepository(path, fs))
        throw new RepositoryNotFoundException(path);
      return new FileRepository(path);
    }
View Full Code Here

   *             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

   * @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

   *
   * @throws Exception
   */
  public void updateServerInfo() throws Exception {
    if (db instanceof FileRepository) {
      final FileRepository fr = (FileRepository) db;
      RefWriter rw = new RefWriter(fr.getAllRefs().values()) {
        @Override
        protected void writeFile(final String name, final byte[] bin)
            throws IOException {
          File path = new File(fr.getDirectory(), name);
          TestRepository.this.writeFile(path, bin);
        }
      };
      rw.writePackedRefs();
      rw.writeInfoRefs();

      final StringBuilder w = new StringBuilder();
      for (PackFile p : fr.getObjectDatabase().getPacks()) {
        w.append("P ");
        w.append(p.getPackFile().getName());
        w.append('\n');
      }
      writeFile(new File(new File(fr.getObjectDatabase().getDirectory(),
          "info"), "packs"), Constants.encodeASCII(w.toString()));
    }
  }
View Full Code Here

  @Override
  @Before
  public void setUp() throws Exception {
    super.setUp();
    FileRepository submoduleStandalone = createWorkRepository();
    JGitTestUtil.writeTrashFile(submoduleStandalone, "fileInSubmodule",
        "submodule");
    Git submoduleStandaloneGit = Git.wrap(submoduleStandalone);
    submoduleStandaloneGit.add().addFilepattern("fileInSubmodule").call();
    submoduleStandaloneGit.commit().setMessage("add file to submodule")
        .call();

    submodule_db = (FileRepository) Git.wrap(db).submoduleAdd()
        .setPath("submodule")
        .setURI(submoduleStandalone.getDirectory().toURI().toString())
        .call();
    submodule_trash = submodule_db.getWorkTree();
    writeTrashFile("fileInRoot", "root");
    Git rootGit = Git.wrap(db);
    rootGit.add().addFilepattern("fileInRoot").call();
View Full Code Here

      File file = new File(db.getDirectory(), "index");
      if (!file.exists())
        return;
      db.close();
      file.delete();
      db = new FileRepository(db.getDirectory());
      db_t = new TestRepository<FileRepository>(db);
      break;
    }
  }
View Full Code Here

        if (db.isBare())
          return;
        File workTreeFile = db.getWorkTree();
        db.getConfig().setBoolean("core", null, "bare", true);
        db.getDirectory().renameTo(new File(workTreeFile, "test.git"));
        db = new FileRepository(new File(workTreeFile, "test.git"));
        db_t = new TestRepository<FileRepository>(db);
      }
    } finally {
      if (fos != null)
        fos.close();
View Full Code Here

   *             the builder's parameters.
   * @since 3.0
   */
  @Override
  public Repository build() throws IOException {
    FileRepository repo = new FileRepository(setup());
    if (isMustExist() && !repo.getObjectDatabase().exists())
      throw new RepositoryNotFoundException(getGitDir());
    return repo;
  }
View Full Code Here

   * Retrieves local config without any base config.
   */
  private FileBasedConfig getLocalConfig() throws IOException {
    // TODO: remove usage of internal type
    if (db instanceof FileRepository) {
      FileRepository fr = (FileRepository) db;
      FileBasedConfig config = new FileBasedConfig(fr.getConfig().getFile(), FS.detect());
      try {
        config.load();
      } catch (ConfigInvalidException e) {
        throw new IOException(e);
      }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.internal.storage.file.FileRepository

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.