List of usage examples for org.eclipse.jgit.api SubmoduleAddCommand SubmoduleAddCommand
public SubmoduleAddCommand(Repository repo)
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 v a 2 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); 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();/* ww w . ja va2s . c o 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.repositories.GitRepositoriesViewRepoDeletionTest.java
License:Open Source License
@Test public void testDeleteSubmoduleRepository() throws Exception { deleteAllProjects();//from www.j ava 2 s.c o m assertProjectExistence(PROJ1, false); clearView(); Activator.getDefault().getRepositoryUtil().addConfiguredRepository(repositoryFile); shareProjects(repositoryFile); assertProjectExistence(PROJ1, true); refreshAndWait(); assertHasRepo(repositoryFile); Repository db = lookupRepository(repositoryFile); SubmoduleAddCommand command = new SubmoduleAddCommand(db); String path = "sub"; command.setPath(path); String uri = db.getDirectory().toURI().toString(); command.setURI(uri); Repository subRepo = command.call(); assertNotNull(subRepo); refreshAndWait(); SWTBotTree tree = getOrOpenView().bot().tree(); tree.getAllItems()[0].expand().expandNode(UIText.RepositoriesViewLabelProvider_SubmodulesNodeText) .getItems()[0].select(); ContextMenuHelper.clickContextMenu(tree, myUtil.getPluginLocalizedValue(DELETE_REPOSITORY_CONTEXT_MENU_LABEL)); SWTBotShell shell = bot.shell(UIText.DeleteRepositoryConfirmDialog_DeleteRepositoryWindowTitle); shell.activate(); String workDir = subRepo.getWorkTree().getPath(); String checkboxLabel = NLS.bind(UIText.DeleteRepositoryConfirmDialog_DeleteWorkingDirectoryCheckbox, workDir); shell.bot().checkBox(checkboxLabel).select(); shell.bot().button(IDialogConstants.OK_LABEL).click(); TestUtil.joinJobs(JobFamilies.REPOSITORY_DELETE); refreshAndWait(); assertFalse(subRepo.getDirectory().exists()); assertFalse(subRepo.getWorkTree().exists()); }
From source file:org.eclipse.orion.server.git.servlets.GitSubmoduleHandlerV1.java
License:Open Source License
public static void addSubmodules(Repository repo, String targetUrl, String targetPath) throws GitAPIException { SubmoduleAddCommand addCommand = new SubmoduleAddCommand(repo); addCommand.setURI(targetUrl);//from ww w.j a v a 2 s.c o m addCommand.setPath(targetPath); Repository repository = addCommand.call(); repository.close(); }