Package org.eclipse.jgit.storage.file

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


    File workdir = new File(trash.getParentFile(), "rw");
    FileUtils.mkdir(workdir);
    FileRepository repo1initial = new FileRepository(new File(repo1Parent,
        Constants.DOT_GIT));
    repo1initial.create();
    final FileBasedConfig cfg = repo1initial.getConfig();
    cfg.setString("core", null, "worktree", workdir.getAbsolutePath());
    cfg.save();
    repo1initial.close();

    File theDir = new File(repo1Parent, Constants.DOT_GIT);
    FileRepository r = (FileRepository) new FileRepositoryBuilder()
        .setGitDir(theDir).build();
View Full Code Here


    File workdir = new File(trash.getParentFile(), "rw");
    FileUtils.mkdir(workdir);
    FileRepository repo1initial = new FileRepository(new File(repo1Parent,
        Constants.DOT_GIT));
    repo1initial.create();
    final FileBasedConfig cfg = repo1initial.getConfig();
    cfg.setString("core", null, "worktree", "../../rw");
    cfg.save();
    repo1initial.close();

    File theDir = new File(repo1Parent, Constants.DOT_GIT);
    FileRepository r = (FileRepository) new FileRepositoryBuilder()
        .setGitDir(theDir).build();
View Full Code Here

  @Test
  public void test006_ReadUglyConfig() throws IOException,
      ConfigInvalidException {
    final File cfg = new File(db.getDirectory(), Constants.CONFIG);
    final FileBasedConfig c = new FileBasedConfig(cfg, db.getFS());
    final String configStr = "  [core];comment\n\tfilemode = yes\n"
        + "[user]\n"
        + "  email = A U Thor <thor@example.com> # Just an example...\n"
        + " name = \"A  Thor \\\\ \\\"\\t \"\n"
        + "    defaultCheckInComment = a many line\\n\\\ncomment\\n\\\n"
        + " to test\n";
    write(cfg, configStr);
    c.load();
    assertEquals("yes", c.getString("core", null, "filemode"));
    assertEquals("A U Thor <thor@example.com>", c.getString("user", null,
        "email"));
    assertEquals("A  Thor \\ \"\t ", c.getString("user", null, "name"));
    assertEquals("a many line\ncomment\n to test", c.getString("user",
        null, "defaultCheckInComment"));
    c.save();
    final FileReader fr = new FileReader(cfg);
    final char[] cbuf = new char[configStr.length()];
    fr.read(cbuf);
    fr.close();
    assertEquals(configStr, new String(cbuf));
View Full Code Here

    int tz = -4 * 60;

    // check that there are no entries in the reflog and turn off writing
    // reflogs
    assertEquals(0, db.getReflogReader(Constants.HEAD).getReverseEntries().size());
    final FileBasedConfig cfg = db.getConfig();
    cfg.setBoolean("core", null, "logallrefupdates", false);
    cfg.save();

    // do one commit and check that reflog size is 0: no reflogs should be
    // written
    commit("A Commit\n", new PersonIdent(author, commitTime, tz),
        new PersonIdent(committer, commitTime, tz));
    commitTime += 60 * 1000;
    assertTrue(
        "Reflog for HEAD still contain no entry",
        db.getReflogReader(Constants.HEAD).getReverseEntries().size() == 0);

    // set the logAllRefUpdates parameter to true and check it
    cfg.setBoolean("core", null, "logallrefupdates", true);
    cfg.save();
    assertTrue(cfg.get(CoreConfig.KEY).isLogAllRefUpdates());

    // do one commit and check that reflog size is increased to 1
    commit("A Commit\n", new PersonIdent(author, commitTime, tz),
        new PersonIdent(committer, commitTime, tz));
    commitTime += 60 * 1000;
    assertTrue(
        "Reflog for HEAD should contain one entry",
        db.getReflogReader(Constants.HEAD).getReverseEntries().size() == 1);

    // set the logAllRefUpdates parameter to false and check it
    cfg.setBoolean("core", null, "logallrefupdates", false);
    cfg.save();
    assertFalse(cfg.get(CoreConfig.KEY).isLogAllRefUpdates());

    // do one commit and check that reflog size is 2
    commit("A Commit\n", new PersonIdent(author, commitTime, tz),
        new PersonIdent(committer, commitTime, tz));
    assertTrue(
View Full Code Here

        ent.setObjectId(id);
      }
    });
    editor.commit();

    FileBasedConfig modulesConfig = new FileBasedConfig(new File(
        db.getWorkTree(), Constants.DOT_GIT_MODULES), db.getFS());
    modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_PATH, path);
    modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_URL, "git://server/repo.git");
    modulesConfig.save();

    SubmoduleStatusCommand command = new SubmoduleStatusCommand(db);
    Map<String, SubmoduleStatus> statuses = command.call();
    assertNotNull(statuses);
    assertEquals(1, statuses.size());
View Full Code Here

    StoredConfig config = db.getConfig();
    config.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_URL, url);
    config.save();

    FileBasedConfig modulesConfig = new FileBasedConfig(new File(
        db.getWorkTree(), Constants.DOT_GIT_MODULES), db.getFS());
    modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_PATH, path);
    modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_URL, url);
    modulesConfig.save();

    Repository subRepo = Git.init().setBare(false)
        .setDirectory(new File(db.getWorkTree(), path)).call()
        .getRepository();
    assertNotNull(subRepo);
View Full Code Here

    StoredConfig config = db.getConfig();
    config.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_URL, url);
    config.save();

    FileBasedConfig modulesConfig = new FileBasedConfig(new File(
        db.getWorkTree(), Constants.DOT_GIT_MODULES), db.getFS());
    modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_PATH, path);
    modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_URL, url);
    modulesConfig.save();

    SubmoduleStatusCommand command = new SubmoduleStatusCommand(db);
    Map<String, SubmoduleStatus> statuses = command.call();
    assertNotNull(statuses);
    assertEquals(1, statuses.size());
View Full Code Here

    StoredConfig config = db.getConfig();
    config.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_URL, url);
    config.save();

    FileBasedConfig modulesConfig = new FileBasedConfig(new File(
        db.getWorkTree(), Constants.DOT_GIT_MODULES), db.getFS());
    modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_PATH, path);
    modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_URL, url);
    modulesConfig.save();

    Repository subRepo = Git.init().setBare(false)
        .setDirectory(new File(db.getWorkTree(), path)).call()
        .getRepository();
    assertNotNull(subRepo);
View Full Code Here

    StoredConfig config = db.getConfig();
    config.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_URL, url);
    config.save();

    FileBasedConfig modulesConfig = new FileBasedConfig(new File(
        db.getWorkTree(), Constants.DOT_GIT_MODULES), db.getFS());
    modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_PATH, path);
    modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_URL, url);
    modulesConfig.save();

    Repository subRepo = Git.init().setBare(false)
        .setDirectory(new File(db.getWorkTree(), path)).call()
        .getRepository();
    assertNotNull(subRepo);
View Full Code Here

    SubmoduleWalk generator = SubmoduleWalk.forIndex(db);
    assertTrue(generator.next());
    assertNull(generator.getConfigUrl());
    assertNull(generator.getConfigUpdate());

    FileBasedConfig modulesConfig = new FileBasedConfig(new File(
        db.getWorkTree(), Constants.DOT_GIT_MODULES), db.getFS());
    modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_PATH, path);
    String url = "git://server/repo.git";
    modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_URL, url);
    String update = "rebase";
    modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_UPDATE, update);
    modulesConfig.save();

    SubmoduleInitCommand command = new SubmoduleInitCommand(db);
    Collection<String> modules = command.call();
    assertNotNull(modules);
    assertEquals(1, modules.size());
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.storage.file.FileBasedConfig

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.