Package org.eclipse.jgit.storage.file

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


  @Test
  public void resolveSameLevelRelativeUrl() throws Exception {
    final String path = addSubmoduleToIndex();

    String base = "git://server/repo.git";
    FileBasedConfig config = db.getConfig();
    config.setString(ConfigConstants.CONFIG_REMOTE_SECTION,
        Constants.DEFAULT_REMOTE_NAME, ConfigConstants.CONFIG_KEY_URL,
        base);
    config.save();

    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 = "./sub.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


  public void resolveOneLevelHigherRelativeUrl() throws IOException,
      ConfigInvalidException, GitAPIException {
    final String path = addSubmoduleToIndex();

    String base = "git://server/repo.git";
    FileBasedConfig config = db.getConfig();
    config.setString(ConfigConstants.CONFIG_REMOTE_SECTION,
        Constants.DEFAULT_REMOTE_NAME, ConfigConstants.CONFIG_KEY_URL,
        base);
    config.save();

    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 = "../sub.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

  public void resolveTwoLevelHigherRelativeUrl() throws IOException,
      ConfigInvalidException, GitAPIException {
    final String path = addSubmoduleToIndex();

    String base = "git://server/repo.git";
    FileBasedConfig config = db.getConfig();
    config.setString(ConfigConstants.CONFIG_REMOTE_SECTION,
        Constants.DEFAULT_REMOTE_NAME, ConfigConstants.CONFIG_KEY_URL,
        base);
    config.save();

    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 = "../../server2/sub.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

    final String path = addSubmoduleToIndex();

    String base = db.getWorkTree().getAbsolutePath();
    if (File.separatorChar == '\\')
      base = base.replace('\\', '/');
    FileBasedConfig config = db.getConfig();
    config.setString(ConfigConstants.CONFIG_REMOTE_SECTION,
        Constants.DEFAULT_REMOTE_NAME, ConfigConstants.CONFIG_KEY_URL,
        null);
    config.save();

    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 = "./sub.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

  public void resolveInvalidParentUrl() throws IOException,
      ConfigInvalidException, GitAPIException {
    final String path = addSubmoduleToIndex();

    String base = "no_slash";
    FileBasedConfig config = db.getConfig();
    config.setString(ConfigConstants.CONFIG_REMOTE_SECTION,
        Constants.DEFAULT_REMOTE_NAME, ConfigConstants.CONFIG_KEY_URL,
        base);
    config.save();

    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 = "../sub.git";
    modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_URL, url);
    modulesConfig.save();

    try {
      new SubmoduleInitCommand(db).call();
      fail("Exception not thrown");
    } catch (JGitInternalException e) {
View Full Code Here

   */
  public SubmoduleWalk loadModulesConfig() throws IOException, ConfigInvalidException {
    if (rootTree == null) {
      File modulesFile = new File(repository.getWorkTree(),
          Constants.DOT_GIT_MODULES);
      FileBasedConfig config = new FileBasedConfig(modulesFile,
          repository.getFS());
      config.load();
      modulesConfig = config;
    } else {
      TreeWalk configWalk = new TreeWalk(repository);
      try {
        configWalk.addTree(rootTree);
View Full Code Here

    config.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_URL, db.getDirectory().toURI()
            .toString());
    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.save();

    SubmoduleUpdateCommand command = new SubmoduleUpdateCommand(db);
    Collection<String> updated = command.call();
    assertNotNull(updated);
    assertEquals(1, updated.size());
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);
    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();

    SubmoduleUpdateCommand command = new SubmoduleUpdateCommand(db);
    Collection<String> updated = command.call();
    assertNotNull(updated);
    assertTrue(updated.isEmpty());
View Full Code Here

        new ConfigChangedListener() {
          public void onConfigChanged(ConfigChangedEvent event) {
            events[0] = event;
          }
        });
    FileBasedConfig config = db.getConfig();
    assertNull(events[0]);

    // set a value to some arbitrary key
    config.setString("test", "section", "event", "value");
    // no changes until we save
    assertNull(events[0]);
    config.save();
    assertNotNull(events[0]);
    // correct repository?
    assertEquals(events[0].getRepository(), db);

    // reset for the next test
    events[0] = null;

    // unset the value we have just set above
    config.unset("test", "section", "event");
    // no changes until we save
    assertNull(events[0]);
    config.save();
    assertNotNull(events[0]);
    // correct repository?
    assertEquals(events[0].getRepository(), db);
  }
View Full Code Here

   */
  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);
      }
      return config;
    } else {
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.