Examples of FileBasedConfig


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

  public void addSubmoduleWithExistingSubmoduleDefined() throws Exception {
    String path1 = "sub1";
    String url1 = "git://server/repo1.git";
    String path2 = "sub2";

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

    Git git = new Git(db);
    writeTrashFile("file.txt", "content");
    git.add().addFilepattern("file.txt").call();
    assertNotNull(git.commit().setMessage("create file").call());

    SubmoduleAddCommand command = new SubmoduleAddCommand(db);
    command.setPath(path2);
    String url2 = db.getDirectory().toURI().toString();
    command.setURI(url2);
    Repository r = command.call();
    assertNotNull(r);
    addRepoToClose(r);

    modulesConfig.load();
    assertEquals(path1, modulesConfig.getString(
        ConfigConstants.CONFIG_SUBMODULE_SECTION, path1,
        ConfigConstants.CONFIG_KEY_PATH));
    assertEquals(url1, modulesConfig.getString(
        ConfigConstants.CONFIG_SUBMODULE_SECTION, path1,
        ConfigConstants.CONFIG_KEY_URL));
    assertEquals(path2, modulesConfig.getString(
        ConfigConstants.CONFIG_SUBMODULE_SECTION, path2,
        ConfigConstants.CONFIG_KEY_PATH));
    assertEquals(url2, modulesConfig.getString(
        ConfigConstants.CONFIG_SUBMODULE_SECTION, path2,
        ConfigConstants.CONFIG_KEY_URL));
  }
View Full Code Here

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