List of usage examples for org.eclipse.jgit.lib StoredConfig save
public abstract void save() throws IOException;
From source file:org.eclipse.egit.ui.internal.push.PushBranchWizard.java
License:Open Source License
private void configureNewRemote(URIish uri) throws URISyntaxException, IOException { StoredConfig config = repository.getConfig(); String remoteName = getRemoteName(); RemoteConfig remoteConfig = new RemoteConfig(config, remoteName); remoteConfig.addURI(uri);/* w w w . j a v a2s . com*/ RefSpec defaultFetchSpec = new RefSpec().setForceUpdate(true).setSourceDestination(Constants.R_HEADS + "*", //$NON-NLS-1$ Constants.R_REMOTES + remoteName + "/*"); //$NON-NLS-1$ remoteConfig.addFetchRefSpec(defaultFetchSpec); remoteConfig.update(config); config.save(); }
From source file:org.eclipse.egit.ui.internal.push.PushBranchWizard.java
License:Open Source License
private void configureUpstream() throws IOException { if (this.ref == null) { // Don't configure upstream for detached HEAD return;//from w w w .j a v a 2s.co m } String remoteName = getRemoteName(); String fullRemoteBranchName = pushBranchPage.getFullRemoteReference(); String localBranchName = Repository.shortenRefName(this.ref.getName()); StoredConfig config = repository.getConfig(); config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, localBranchName, ConfigConstants.CONFIG_KEY_REMOTE, remoteName); config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, localBranchName, ConfigConstants.CONFIG_KEY_MERGE, fullRemoteBranchName); BranchRebaseMode rebaseMode = pushBranchPage.getUpstreamConfig(); if (rebaseMode != null) { config.setEnum(ConfigConstants.CONFIG_BRANCH_SECTION, localBranchName, ConfigConstants.CONFIG_KEY_REBASE, rebaseMode); } config.save(); }
From source file:org.eclipse.egit.ui.internal.push.PushBranchWizardTest.java
License:Open Source License
private void removeExistingRemotes() throws IOException { StoredConfig config = repository.getConfig(); Set<String> remotes = config.getSubsections(ConfigConstants.CONFIG_REMOTE_SECTION); for (String remoteName : remotes) config.unsetSection(ConfigConstants.CONFIG_REMOTE_SECTION, remoteName); config.save(); }
From source file:org.eclipse.egit.ui.internal.push.PushWizard.java
License:Open Source License
private void saveRefSpecs() { final RemoteConfig rc = repoPage.getSelection().getConfig(); rc.setPushRefSpecs(refSpecPage.getRefSpecs()); final StoredConfig config = localDb.getConfig(); rc.update(config);/*ww w . ja v a 2s. c o m*/ try { config.save(); } catch (final IOException e) { ErrorDialog.openError(getShell(), UIText.PushWizard_cantSaveTitle, UIText.PushWizard_cantSaveMessage, new Status(IStatus.WARNING, Activator.getPluginId(), e.getMessage(), e)); // Continue, it's not critical. } }
From source file:org.eclipse.egit.ui.internal.repository.tree.command.DeleteFetchCommand.java
License:Open Source License
public Object execute(ExecutionEvent event) throws ExecutionException { FetchNode node = getSelectedNodes(event).get(0); RemoteNode remote = (RemoteNode) node.getParent(); StoredConfig config = node.getRepository().getConfig(); String fetchUrl = config.getString(REMOTE, remote.getObject(), URL); config.unset(REMOTE, remote.getObject(), FETCH); config.unset(REMOTE, remote.getObject(), URL); // the push URL may still be needed for fetch if (fetchUrl != null) { boolean hasPush = config.getStringList(REMOTE, remote.getObject(), PUSH).length > 0; if (hasPush) { String[] pushurls = config.getStringList(REMOTE, remote.getObject(), PUSHURL); // if there are not specific push urls, // copy the former fetch url into push url if (pushurls.length == 0) config.setString(REMOTE, remote.getObject(), PUSHURL, fetchUrl); }/* w w w . ja va2s . c o m*/ } try { config.save(); } catch (IOException e1) { Activator.handleError(e1.getMessage(), e1, true); } return null; }
From source file:org.eclipse.egit.ui.internal.repository.tree.command.DeletePushCommand.java
License:Open Source License
public Object execute(ExecutionEvent event) throws ExecutionException { PushNode node = getSelectedNodes(event).get(0); RemoteNode remote = (RemoteNode) node.getParent(); StoredConfig config = node.getRepository().getConfig(); config.unset("remote", remote.getObject(), "pushurl"); //$NON-NLS-1$ //$NON-NLS-2$ config.unset("remote", remote.getObject(), "push"); //$NON-NLS-1$ //$NON-NLS-2$ try {//www. j a va2 s. c om config.save(); } catch (IOException e1) { Activator.handleError(e1.getMessage(), e1, true); } return null; }
From source file:org.eclipse.egit.ui.internal.repository.tree.command.RemoveRemoteCommand.java
License:Open Source License
public Object execute(ExecutionEvent event) throws ExecutionException { final RemoteNode node = getSelectedNodes(event).get(0); final String configName = node.getObject(); boolean ok = MessageDialog.openConfirm(getShell(event), UIText.RepositoriesView_ConfirmDeleteRemoteHeader, NLS.bind(UIText.RepositoriesView_ConfirmDeleteRemoteMessage, configName)); if (ok) {/* w w w . ja va 2 s. c om*/ StoredConfig config = node.getRepository().getConfig(); config.unsetSection(RepositoriesView.REMOTE, configName); try { config.save(); } catch (IOException e1) { Activator.handleError(UIText.RepositoriesView_ErrorHeader, e1, true); } } return null; }
From source file:org.eclipse.egit.ui.view.repositories.GitRepositoriesViewRemoteHandlingTest.java
License:Open Source License
/** * Verify that remote configuration is shown correctly; also check error * node display/* ww w . jav a 2 s . c om*/ * * @throws Exception */ @Test public void testExpandRemotes() throws Exception { removeRemotesConfig(repositoryFile); refreshAndWait(); SWTBotTree tree = getOrOpenView().bot().tree(); SWTBotTreeItem remotesItem = myRepoViewUtil.getRemotesItem(tree, repositoryFile).expand(); assertEquals("Wrong number of remotes", 0, remotesItem.getNodes().size()); StoredConfig cfg = lookupRepository(repositoryFile).getConfig(); String remoteUri = "file:///" + remoteRepositoryFile.getPath(); cfg.setString("remote", "test", "url", remoteUri); cfg.setString("remote", "test", "fetch", "somejunk"); cfg.setString("remote", "test2", "url", remoteUri); cfg.setString("remote", "test2", "fetch", "somejunk"); cfg.setString("remote", "test2", "pushurl", remoteUri); cfg.setString("remote", "test2", "push", "somejunk"); cfg.setString("remote", "test3", "pushurl", "somejunk"); cfg.setString("remote", "test3", "push", "somejunk"); cfg.save(); cfg.load(); refreshAndWait(); remotesItem = myRepoViewUtil.getRemotesItem(tree, repositoryFile).expand(); assertEquals("Wrong number of remotes", 3, remotesItem.getNodes().size()); remotesItem = myRepoViewUtil.getRemotesItem(tree, repositoryFile).expand(); List<String> testnodes = remotesItem.getNode("test").expand().getNodes(); assertTrue(testnodes.size() == 1); List<String> test2nodes = remotesItem.getNode("test2").expand().getNodes(); assertTrue(test2nodes.size() == 2); // error node should be shown remotesItem.getNode("test3").expand().getNodes(); assertTrue(remotesItem.getNode("test3").expand().getNodes().size() == 1); // test the properties view on remote remotesItem.getNode("test").select(); ContextMenuHelper.clickContextMenu(tree, myUtil.getPluginLocalizedValue("OpenPropertiesCommand")); waitInUI(); assertEquals("org.eclipse.ui.views.PropertySheet", bot.activeView().getReference().getId()); removeRemotesConfig(repositoryFile); refreshAndWait(); remotesItem = myRepoViewUtil.getRemotesItem(tree, repositoryFile).expand(); assertEquals("Wrong number of remotes", 0, remotesItem.getNodes().size()); }
From source file:org.eclipse.egit.ui.view.repositories.GitRepositoriesViewRemoteHandlingTest.java
License:Open Source License
private void removeRemotesConfig(File file) throws Exception { Repository repo = lookupRepository(file); StoredConfig config = repo.getConfig(); for (String remote : config.getSubsections("remote")) config.unsetSection("remote", remote); config.save(); waitInUI();//from w w w . j av a 2s . c om }
From source file:org.eclipse.mylyn.internal.github.core.pr.PullRequestUtils.java
License:Open Source License
/** * Configure pull request topic branch to use head remote * * @param repo/*from ww w . jav a 2s . c o m*/ * @param request * @throws IOException */ public static void configureTopicBranch(Repository repo, PullRequest request) throws IOException { String branch = getBranchName(request); String remote = request.getHead().getRepo().getOwner().getLogin(); StoredConfig config = repo.getConfig(); config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, branch, ConfigConstants.CONFIG_KEY_MERGE, getHeadBranch(request)); config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, branch, ConfigConstants.CONFIG_KEY_REMOTE, remote); config.save(); }