Example usage for org.eclipse.jgit.internal.storage.file FileRepository getFS

List of usage examples for org.eclipse.jgit.internal.storage.file FileRepository getFS

Introduction

In this page you can find the example usage for org.eclipse.jgit.internal.storage.file FileRepository getFS.

Prototype


public FS getFS() 

Source Link

Document

Get the used file system abstraction.

Usage

From source file:org.eclipse.egit.ui.submodule.SubmoduleSyncTest.java

License:Open Source License

@Test
public void syncSubmodule() throws Exception {
    deleteAllProjects();/*from  w w  w.  jav a 2 s  .  co m*/
    assertProjectExistence(PROJ1, false);
    clearView();
    Activator.getDefault().getRepositoryUtil().addConfiguredRepository(repositoryFile);
    shareProjects(repositoryFile);
    assertProjectExistence(PROJ1, true);
    refreshAndWait();
    assertHasRepo(repositoryFile);
    FileRepository repo = lookupRepository(repositoryFile);

    SubmoduleAddCommand command = new SubmoduleAddCommand(repo);
    String path = "sub";
    command.setPath(path);
    String uri = new URIish(repo.getDirectory().toURI().toString()).toString();
    command.setURI(uri);
    Repository subRepo = command.call();
    assertNotNull(subRepo);

    String newUri = "git://server/repo.git";
    File modulesFile = new File(repo.getWorkTree(), Constants.DOT_GIT_MODULES);
    FileBasedConfig config = new FileBasedConfig(modulesFile, repo.getFS());
    config.load();
    config.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path, ConfigConstants.CONFIG_KEY_URL, newUri);
    config.save();

    assertEquals(uri, repo.getConfig().getString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
            ConfigConstants.CONFIG_KEY_URL));
    assertEquals(uri, subRepo.getConfig().getString(ConfigConstants.CONFIG_REMOTE_SECTION,
            Constants.DEFAULT_REMOTE_NAME, ConfigConstants.CONFIG_KEY_URL));

    refreshAndWait();
    SWTBotTree tree = getOrOpenView().bot().tree();
    tree.getAllItems()[0].expand().expandNode(UIText.RepositoriesViewLabelProvider_SubmodulesNodeText).select();
    ContextMenuHelper.clickContextMenuSync(tree,
            myUtil.getPluginLocalizedValue(SYNC_SUBMODULE_CONTEXT_MENU_LABEL));
    TestUtil.joinJobs(JobFamilies.SUBMODULE_SYNC);
    refreshAndWait();

    assertEquals(newUri, repo.getConfig().getString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
            ConfigConstants.CONFIG_KEY_URL));
    assertEquals(newUri, subRepo.getConfig().getString(ConfigConstants.CONFIG_REMOTE_SECTION,
            Constants.DEFAULT_REMOTE_NAME, ConfigConstants.CONFIG_KEY_URL));
}