use of org.eclipse.jgit.api.SubmoduleAddCommand in project egit by eclipse.
the class GitRepositoriesViewRepoDeletionTest method testDeleteSubmoduleRepository.
@Test
public void testDeleteSubmoduleRepository() throws Exception {
deleteAllProjects();
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);
subRepo.close();
refreshAndWait();
SWTBotTree tree = getOrOpenView().bot().tree();
SWTBotTreeItem item = TestUtil.expandAndWait(tree.getAllItems()[0]);
item = TestUtil.expandAndWait(item.getNode(UIText.RepositoriesViewLabelProvider_SubmodulesNodeText));
item.getItems()[0].select();
ContextMenuHelper.clickContextMenu(tree, myUtil.getPluginLocalizedValue(DELETE_REPOSITORY_CONTEXT_MENU_LABEL));
SWTBotShell shell = bot.shell(UIText.DeleteRepositoryConfirmDialog_DeleteRepositoryWindowTitle);
shell.activate();
shell.bot().checkBox(UIText.DeleteRepositoryConfirmDialog_DeleteGitDirCheckbox).select();
shell.bot().checkBox(UIText.DeleteRepositoryConfirmDialog_DeleteWorkingDirectoryCheckbox).select();
shell.bot().button(UIText.DeleteRepositoryConfirmDialog_DeleteRepositoryConfirmButton).click();
TestUtil.joinJobs(JobFamilies.REPOSITORY_DELETE);
refreshAndWait();
assertFalse(subRepo.getDirectory().exists());
assertFalse(subRepo.getWorkTree().exists());
}
use of org.eclipse.jgit.api.SubmoduleAddCommand in project egit by eclipse.
the class SubmoduleSyncTest method syncSubmodule.
@Test
public void syncSubmodule() throws Exception {
deleteAllProjects();
assertProjectExistence(PROJ1, false);
clearView();
Activator.getDefault().getRepositoryUtil().addConfiguredRepository(repositoryFile);
shareProjects(repositoryFile);
assertProjectExistence(PROJ1, true);
refreshAndWait();
assertHasRepo(repositoryFile);
Repository 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);
subRepo.close();
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();
TestUtil.expandAndWait(tree.getAllItems()[0]).getNode(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));
}
use of org.eclipse.jgit.api.SubmoduleAddCommand in project egit by eclipse.
the class SubmoduleUpdateTest method updateSubmodule.
@Test
public void updateSubmodule() throws Exception {
deleteAllProjects();
assertProjectExistence(PROJ1, false);
clearView();
Activator.getDefault().getRepositoryUtil().addConfiguredRepository(repositoryFile);
shareProjects(repositoryFile);
assertProjectExistence(PROJ1, true);
refreshAndWait();
assertHasRepo(repositoryFile);
Repository 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);
subRepo.close();
Ref head = subRepo.exactRef(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();
SWTBotTreeItem item = TestUtil.expandAndWait(tree.getAllItems()[0]);
TestUtil.expandAndWait(item.getNode(UIText.RepositoriesViewLabelProvider_SubmodulesNodeText)).select();
ContextMenuHelper.clickContextMenuSync(tree, myUtil.getPluginLocalizedValue(UPDATE_SUBMODULE_CONTEXT_MENU_LABEL));
TestUtil.joinJobs(JobFamilies.SUBMODULE_UPDATE);
refreshAndWait();
head = subRepo.exactRef(Constants.HEAD);
assertNotNull(head);
assertFalse(head.isSymbolic());
assertEquals(repoHead, head.getObjectId());
}
use of org.eclipse.jgit.api.SubmoduleAddCommand in project egit by eclipse.
the class SubmoduleAddOperation method execute.
@Override
public void execute(IProgressMonitor monitor) throws CoreException {
IWorkspaceRunnable action = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor pm) throws CoreException {
final SubmoduleAddCommand add = Git.wrap(repo).submoduleAdd();
add.setProgressMonitor(new EclipseGitProgressTransformer(pm));
add.setPath(path);
add.setURI(uri);
try {
Repository subRepo = add.call();
if (subRepo != null) {
subRepo.close();
repo.notifyIndexChanged();
}
} catch (GitAPIException e) {
throw new TeamException(e.getLocalizedMessage(), e.getCause());
}
}
};
ResourcesPlugin.getWorkspace().run(action, getSchedulingRule(), IWorkspace.AVOID_UPDATE, monitor);
}
Aggregations