List of usage examples for org.eclipse.jgit.api SubmoduleAddCommand call
@Override public Repository call() throws GitAPIException
Executes the SubmoduleAddCommand The Repository instance returned by this command needs to be closed by the caller to free resources held by the Repository instance.
From source file:com.googlesource.gerrit.plugins.uploadvalidator.SubmoduleValidatorTest.java
License:Apache License
private RevCommit makeCommitWithSubmodule(RevWalk rw) throws IOException, GitAPIException { try (Git git = new Git(repo)) { SubmoduleAddCommand addCommand = git.submoduleAdd(); addCommand.setURI(repo.getDirectory().getCanonicalPath()); addCommand.setPath("modules/library"); addCommand.call().close(); git.add().addFilepattern(".").call(); return rw.parseCommit(git.commit().setMessage("Commit with submodule.").call()); }// w w w.j a va 2 s .c o m }
From source file:org.eclipse.egit.core.op.SubmoduleAddOperation.java
License:Open Source License
public void execute(IProgressMonitor monitor) throws CoreException { IWorkspaceRunnable action = new IWorkspaceRunnable() { public void run(IProgressMonitor pm) throws CoreException { final SubmoduleAddCommand add = Git.wrap(repo).submoduleAdd(); add.setProgressMonitor(new EclipseGitProgressTransformer(pm)); add.setPath(path);//w ww . jav a 2 s . co m add.setURI(uri); try { if (add.call() != null) repo.notifyIndexChanged(); } catch (GitAPIException e) { throw new TeamException(e.getLocalizedMessage(), e.getCause()); } } }; ResourcesPlugin.getWorkspace().run(action, monitor != null ? monitor : new NullProgressMonitor()); }
From source file:org.eclipse.egit.ui.submodule.SubmoduleSyncTest.java
License:Open Source License
@Test public void syncSubmodule() throws Exception { deleteAllProjects();/*from www. 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();/*from w w w .ja va 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); 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 w w w .jav a 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);// www . ja va 2 s. com addCommand.setPath(targetPath); Repository repository = addCommand.call(); repository.close(); }