Example usage for org.eclipse.jgit.lib StoredConfig save

List of usage examples for org.eclipse.jgit.lib StoredConfig save

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib StoredConfig save.

Prototype

public abstract void save() throws IOException;

Source Link

Document

Save the configuration to the persistent store.

Usage

From source file:org.eclipse.egit.core.op.ConfigureGerritAfterCloneTask.java

License:Open Source License

private void configureGerrit(Repository repository) throws URISyntaxException, IOException {
    StoredConfig config = repository.getConfig();
    RemoteConfig remoteConfig;/*  ww w. j  a va 2  s . c  o  m*/
    remoteConfig = GerritUtil.findRemoteConfig(config, remoteName);
    if (remoteConfig == null) {
        return;
    }
    GerritUtil.configurePushURI(remoteConfig, new URIish(uri));
    GerritUtil.configurePushRefSpec(remoteConfig, Constants.MASTER);
    GerritUtil.configureFetchNotes(remoteConfig);
    GerritUtil.setCreateChangeId(config);
    remoteConfig.update(config);
    config.save();
}

From source file:org.eclipse.egit.core.test.op.MergeOperationTest.java

License:Open Source License

private void setMergeOptions(String branch, FastForwardMode ffMode) throws IOException {
    StoredConfig config = testRepository.getRepository().getConfig();
    config.setEnum(ConfigConstants.CONFIG_BRANCH_SECTION, branch, ConfigConstants.CONFIG_KEY_MERGEOPTIONS,
            ffMode);//from ww  w  . jav  a 2s.c om
    config.save();
}

From source file:org.eclipse.egit.core.test.op.MergeOperationTest.java

License:Open Source License

private void setMerge(FastForwardMode ffMode) throws IOException {
    StoredConfig config = testRepository.getRepository().getConfig();
    config.setEnum(ConfigConstants.CONFIG_KEY_MERGE, null, ConfigConstants.CONFIG_KEY_FF,
            FastForwardMode.Merge.valueOf(ffMode));
    config.save();
}

From source file:org.eclipse.egit.gitflow.GitFlowConfig.java

License:Open Source License

private void setBranchValue(String featureName, String value, String mergeKey) throws IOException {
    StoredConfig config = repository.getConfig();
    config.setString(BRANCH_SECTION, featureName, mergeKey, value);
    config.save();
}

From source file:org.eclipse.egit.ui.httpauth.PushTest.java

License:Open Source License

private void configurePush() throws Exception {
    StoredConfig config = localRepository.getConfig();
    config.setString("remote", "push", "pushurl", remoteRepository.getUri());
    config.setString("remote", "push", "push", "+refs/heads/*:refs/heads/*");
    config.save();
}

From source file:org.eclipse.egit.ui.internal.dialogs.AbstractConfigureRemoteDialog.java

License:Open Source License

@Override
protected final void buttonPressed(int buttonId) {
    switch (buttonId) {
    case DRY_RUN:
        try {/*from  www.ja  v  a2  s.co  m*/
            new ProgressMonitorDialog(getShell()).run(true, true, (monitor) -> dryRun(monitor));
        } catch (InvocationTargetException e) {
            Activator.showError(e.getMessage(), e);
        } catch (InterruptedException e1) {
            // Ignore cancellation here
        }
        return;
    case REVERT:
        try {
            config = new RemoteConfig(repository.getConfig(), config.getName());
            updateControls();
        } catch (URISyntaxException e) {
            Activator.handleError(e.getMessage(), e, true);
        }
        return;
    case OK:
    case SAVE_ONLY:
        StoredConfig repoConfig = getRepository().getConfig();
        boolean saved = false;
        try {
            config.update(repoConfig);
            repoConfig.save();
            saved = true;
        } catch (IOException e) {
            Activator.handleError(e.getMessage(), e, true);
        }
        if (saved) {
            GerritDialogSettings.updateRemoteConfig(repository, config);
        }
        if (buttonId == OK) {
            performOperation();
        }
        okPressed();
        return;
    default:
        break;
    }
    super.buttonPressed(buttonId);
}

From source file:org.eclipse.egit.ui.internal.fetch.FetchWizard.java

License:Open Source License

private void saveConfig() {
    final RemoteConfig rc = repoPage.getSelection().getConfig();
    rc.setFetchRefSpecs(refSpecPage.getRefSpecs());
    rc.setTagOpt(refSpecPage.getTagOpt());
    final StoredConfig config = localDb.getConfig();
    rc.update(config);/*  www  . j a  v a 2s  . c  o  m*/
    try {
        config.save();
    } catch (final IOException e) {
        ErrorDialog.openError(getShell(), UIText.FetchWizard_cantSaveTitle, UIText.FetchWizard_cantSaveMessage,
                new Status(IStatus.WARNING, Activator.getPluginId(), e.getMessage(), e));
        // Continue, it's not critical.
    }
}

From source file:org.eclipse.egit.ui.internal.pull.PullWizard.java

License:Open Source License

private void configureNewRemote(URIish uri) throws URISyntaxException, IOException {
    StoredConfig config = repository.getConfig();
    String remoteName = this.page.getRemoteConfig().getName();
    RemoteConfig remoteConfig = new RemoteConfig(config, remoteName);
    remoteConfig.addURI(uri);//from  ww w .ja  va  2s .  c o m
    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.pull.PullWizard.java

License:Open Source License

private void configureUpstream() throws IOException {
    String fullBranch = this.repository.getFullBranch();
    if (fullBranch == null || !fullBranch.startsWith(Constants.R_HEADS)) {
        // Don't configure upstream for detached HEAD
        return;//w  ww  .  j a  v  a 2s  . c om
    }
    String remoteName = this.page.getRemoteConfig().getName();
    String fullRemoteBranchName = this.page.getFullRemoteReference();

    String localBranchName = this.repository.getBranch();
    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 = this.page.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.pull.PullWizardPage.java

License:Open Source License

private void showNewRemoteDialog() {
    AddRemoteWizard wizard = new AddRemoteWizard(repository);
    WizardDialog dialog = new WizardDialog(getShell(), wizard);
    int result = dialog.open();
    if (result == Window.OK) {
        URIish uri = wizard.getUri();// w w  w  .  ja v a  2  s  .  com
        String remoteName = wizard.getRemoteName();
        try {
            StoredConfig repoConfig = repository.getConfig();
            RemoteConfig newRemoteConfig = new RemoteConfig(repoConfig, remoteName);
            newRemoteConfig.addURI(uri);
            RefSpec defaultFetchSpec = new RefSpec().setForceUpdate(true).setSourceDestination(
                    Constants.R_HEADS + "*", //$NON-NLS-1$
                    Constants.R_REMOTES + remoteName + "/*"); //$NON-NLS-1$
            newRemoteConfig.addFetchRefSpec(defaultFetchSpec);
            newRemoteConfig.update(repoConfig);
            repoConfig.save();
            List<RemoteConfig> allRemoteConfigs = RemoteConfig.getAllRemoteConfigs(repository.getConfig());
            remoteSelectionCombo.setItems(allRemoteConfigs);
            // find the new remote in the list, as the initial
            // newRemoteConfig object
            // isn't what's stored and returned by getAllRemoteConfigs
            for (RemoteConfig current : allRemoteConfigs) {
                if (newRemoteConfig.getName().equals(current.getName())) {
                    setSelectedRemote(current);
                }
            }
        } catch (URISyntaxException ex) {
            Activator.logError(ex.getMessage(), ex);
        } catch (IOException ex) {
            Activator.logError(ex.getMessage(), ex);
        }
    }
}