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 "";
}
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);
}
}
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);
}
}
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);
}
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 "";
}
}
Aggregations