Search in sources :

Example 1 with BranchConfig

use of org.eclipse.jgit.lib.BranchConfig in project egit by eclipse.

the class PullWizardPage method getSuggestedBranchName.

private String getSuggestedBranchName() {
    if (fullBranch != null) {
        String branchName = Repository.shortenRefName(fullBranch);
        StoredConfig config = repository.getConfig();
        BranchConfig branchConfig = new BranchConfig(config, branchName);
        String merge = branchConfig.getMerge();
        if (!branchConfig.isRemoteLocal() && merge != null && merge.startsWith(Constants.R_HEADS)) {
            return Repository.shortenRefName(merge);
        }
    }
    // $NON-NLS-1$
    return "";
}
Also used : StoredConfig(org.eclipse.jgit.lib.StoredConfig) BranchConfig(org.eclipse.jgit.lib.BranchConfig)

Example 2 with BranchConfig

use of org.eclipse.jgit.lib.BranchConfig in project egit by eclipse.

the class PushToGerritPage method setLastUsedBranch.

private void setLastUsedBranch() {
    String lastBranch = settings.get(lastBranchKey);
    try {
        // use upstream if the current branch is tracking a branch
        final BranchConfig branchConfig = new BranchConfig(repository.getConfig(), repository.getBranch());
        final String trackedBranch = branchConfig.getMerge();
        if (trackedBranch != null) {
            // $NON-NLS-1$
            lastBranch = trackedBranch.replace(Constants.R_HEADS, "");
        }
    } catch (final IOException e) {
        throw new RuntimeException(e);
    }
    if (lastBranch != null) {
        branchText.setText(lastBranch);
    }
}
Also used : BranchConfig(org.eclipse.jgit.lib.BranchConfig) IOException(java.io.IOException)

Example 3 with BranchConfig

use of org.eclipse.jgit.lib.BranchConfig in project egit by eclipse.

the class PushBranchPage method setDefaultUpstreamConfig.

private void setDefaultUpstreamConfig() {
    if (this.ref != null) {
        String branchName = Repository.shortenRefName(ref.getName());
        BranchConfig branchConfig = new BranchConfig(repository.getConfig(), branchName);
        boolean alreadyConfigured = branchConfig.getMerge() != null;
        BranchRebaseMode config;
        if (alreadyConfigured) {
            config = PullCommand.getRebaseMode(branchName, repository.getConfig());
        } else {
            config = CreateLocalBranchOperation.getDefaultUpstreamConfig(repository, Constants.R_REMOTES + Constants.DEFAULT_REMOTE_NAME + "/" + // $NON-NLS-1$
            branchName);
        }
        this.upstreamConfig = config;
        this.upstreamConfigComponent.setUpstreamConfig(this.upstreamConfig);
    }
}
Also used : BranchRebaseMode(org.eclipse.jgit.lib.BranchConfig.BranchRebaseMode) BranchConfig(org.eclipse.jgit.lib.BranchConfig)

Example 4 with BranchConfig

use of org.eclipse.jgit.lib.BranchConfig in project egit by eclipse.

the class PushBranchPage method setRemoteConfigs.

private void setRemoteConfigs() {
    remoteSelectionCombo.setItems(remoteConfigs);
    if (this.ref != null) {
        String branchName = Repository.shortenRefName(this.ref.getName());
        BranchConfig branchConfig = new BranchConfig(repository.getConfig(), branchName);
        String remoteName = branchConfig.getRemote();
        if (remoteName != null) {
            for (RemoteConfig rc : remoteConfigs) {
                if (remoteName.equals(rc.getName()))
                    remoteSelectionCombo.setSelectedRemote(rc);
            }
        }
    }
    remoteConfig = remoteSelectionCombo.getSelectedRemote();
    setRefAssist(remoteConfig);
}
Also used : BranchConfig(org.eclipse.jgit.lib.BranchConfig) RemoteConfig(org.eclipse.jgit.transport.RemoteConfig)

Example 5 with BranchConfig

use of org.eclipse.jgit.lib.BranchConfig in project egit by eclipse.

the class PushBranchPage method getSuggestedBranchName.

private String getSuggestedBranchName() {
    if (ref != null && !ref.getName().startsWith(Constants.R_REMOTES)) {
        StoredConfig config = repository.getConfig();
        String branchName = Repository.shortenRefName(ref.getName());
        BranchConfig branchConfig = new BranchConfig(config, branchName);
        String merge = branchConfig.getMerge();
        if (!branchConfig.isRemoteLocal() && merge != null && merge.startsWith(Constants.R_HEADS))
            return Repository.shortenRefName(merge);
        return branchName;
    } else {
        // $NON-NLS-1$
        return "";
    }
}
Also used : StoredConfig(org.eclipse.jgit.lib.StoredConfig) BranchConfig(org.eclipse.jgit.lib.BranchConfig)

Aggregations

BranchConfig (org.eclipse.jgit.lib.BranchConfig)9 BranchRebaseMode (org.eclipse.jgit.lib.BranchConfig.BranchRebaseMode)2 StoredConfig (org.eclipse.jgit.lib.StoredConfig)2 RemoteConfig (org.eclipse.jgit.transport.RemoteConfig)2 IOException (java.io.IOException)1