List of usage examples for org.eclipse.jgit.internal.storage.file FileRepository getDirectory
public File getDirectory()
From source file:org.eclipse.egit.ui.submodule.SubmoduleAddTest.java
License:Open Source License
@Test public void addAtRoot() throws Exception { deleteAllProjects();//w w w .j a va2 s . c o m assertProjectExistence(PROJ1, false); clearView(); Activator.getDefault().getRepositoryUtil().addConfiguredRepository(repositoryFile); shareProjects(repositoryFile); assertProjectExistence(PROJ1, true); refreshAndWait(); assertHasRepo(repositoryFile); FileRepository repo = lookupRepository(repositoryFile); SWTBotTree tree = getOrOpenView().bot().tree(); tree.getAllItems()[0].select(); ContextMenuHelper.clickContextMenu(tree, myUtil.getPluginLocalizedValue(ADD_SUBMODULE_CONTEXT_MENU_LABEL)); SWTBotShell shell = bot.shell(UIText.AddSubmoduleWizard_WindowTitle); shell.activate(); shell.bot().textWithLabel(UIText.SubmodulePathWizardPage_PathLabel).setText("sub"); shell.bot().button(IDialogConstants.NEXT_LABEL).click(); shell.bot().textWithLabel(UIText.RepositorySelectionPage_promptURI + ":") .setText(repo.getDirectory().toURI().toString()); shell.bot().button(IDialogConstants.FINISH_LABEL).click(); waitInUI(); TestUtil.joinJobs(JobFamilies.SUBMODULE_ADD); refreshAndWait(); tree = getOrOpenView().bot().tree(); SWTBotTreeItem submodules = tree.getAllItems()[0].select().expand() .getNode(UIText.RepositoriesViewLabelProvider_SubmodulesNodeText); assertNotNull(submodules); submodules.expand(); assertEquals(1, submodules.rowCount()); }
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 . ja va 2 s .com*/ 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)); }
From source file:org.eclipse.egit.ui.submodule.SubmoduleUpdateTest.java
License:Open Source License
@Test public void updateSubmodule() throws Exception { deleteAllProjects();/* w w w. j a va2 s .co m*/ assertProjectExistence(PROJ1, false); clearView(); Activator.getDefault().getRepositoryUtil().addConfiguredRepository(repositoryFile); shareProjects(repositoryFile); assertProjectExistence(PROJ1, true); refreshAndWait(); assertHasRepo(repositoryFile); FileRepository repo = lookupRepository(repositoryFile); ObjectId repoHead = repo.resolve(Constants.HEAD); 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); Ref head = subRepo.getRef(Constants.HEAD); assertNotNull(head); assertTrue(head.isSymbolic()); assertEquals(Constants.R_HEADS + Constants.MASTER, head.getLeaf().getName()); assertEquals(repoHead, head.getObjectId()); refreshAndWait(); SWTBotTree tree = getOrOpenView().bot().tree(); tree.getAllItems()[0].expand().expandNode(UIText.RepositoriesViewLabelProvider_SubmodulesNodeText).select(); ContextMenuHelper.clickContextMenuSync(tree, myUtil.getPluginLocalizedValue(UPDATE_SUBMODULE_CONTEXT_MENU_LABEL)); TestUtil.joinJobs(JobFamilies.SUBMODULE_UPDATE); refreshAndWait(); head = subRepo.getRef(Constants.HEAD); assertNotNull(head); assertFalse(head.isSymbolic()); assertEquals(repoHead, head.getObjectId()); }
From source file:org.eclipse.egit.ui.view.synchronize.SynchronizeViewPushTest.java
License:Open Source License
@Before public void prepare() throws Exception { FileRepository childRepository = lookupRepository(childRepositoryFile); FileRepository repository = lookupRepository(repositoryFile); FileBasedConfig config = repository.getConfig(); RemoteConfig remoteConfig = new RemoteConfig(config, "origin"); remoteConfig.addURI(new URIish(childRepository.getDirectory().getParentFile().toURI().toURL())); remoteConfig.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*")); remoteConfig.update(config);//from w w w . ja v a 2 s . c o m config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, "master", ConfigConstants.CONFIG_KEY_REMOTE, "origin"); config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, "master", ConfigConstants.CONFIG_KEY_MERGE, "refs/heads/master"); config.save(); FetchOperation fetchOperation = new FetchOperation(repository, remoteConfig, 60, false); fetchOperation.run(null); }