use of org.eclipse.jgit.transport.RemoteConfig in project egit by eclipse.
the class RemoteSelectionCombo method setItems.
/**
* Set the available items.
*
* @param remoteConfigs
* @return the initially selected remote config, defaults to the origin
* remote if there is one
*/
public RemoteConfig setItems(List<RemoteConfig> remoteConfigs) {
this.remoteConfigs = remoteConfigs;
final String[] items = new String[remoteConfigs.size()];
int i = 0;
for (final RemoteConfig rc : remoteConfigs) items[i++] = getTextForRemoteConfig(rc);
remoteCombo.setItems(items);
RemoteConfig defaultRemoteConfig = getDefaultRemoteConfig();
setSelectedRemote(defaultRemoteConfig);
return defaultRemoteConfig;
}
use of org.eclipse.jgit.transport.RemoteConfig in project egit by eclipse.
the class AbstractConfigureRemoteDialog method buttonPressed.
@Override
protected final void buttonPressed(int buttonId) {
switch(buttonId) {
case DRY_RUN:
try {
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);
}
use of org.eclipse.jgit.transport.RemoteConfig in project egit by eclipse.
the class PushConfiguredRemoteCommand method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
RepositoryTreeNode node = getSelectedNodes(event).get(0);
RemoteConfig config = getRemoteConfig(node);
if (config == null) {
MessageDialog.openInformation(getShell(event), UIText.SimplePushActionHandler_NothingToPushDialogTitle, UIText.SimplePushActionHandler_NothingToPushDialogMessage);
return null;
}
new PushOperationUI(node.getRepository(), config.getName(), false).start();
return null;
}
use of org.eclipse.jgit.transport.RemoteConfig in project egit by eclipse.
the class RepositoriesViewPropertyTester method internalTest.
private boolean internalTest(Object receiver, String property) {
if (!(receiver instanceof RepositoryTreeNode))
return false;
RepositoryTreeNode node = (RepositoryTreeNode) receiver;
Repository repository = node.getRepository();
if (repository == null) {
return false;
}
if (property.equals("isBare")) {
// $NON-NLS-1$
return repository.isBare();
}
if (property.equals("containsHead")) {
// $NON-NLS-1$
return containsHead(repository);
}
if (ResourcePropertyTester.testRepositoryState(repository, property)) {
return true;
}
if (property.equals("isRefCheckedOut")) {
// $NON-NLS-1$
if (node instanceof BranchHierarchyNode) {
try {
for (Ref ref : ((BranchHierarchyNode) node).getChildRefsRecursive()) {
if (isRefCheckedOut(repository, ref)) {
return true;
}
}
} catch (IOException e) {
return false;
}
}
if (!(node.getObject() instanceof Ref))
return false;
Ref ref = (Ref) node.getObject();
return isRefCheckedOut(repository, ref);
}
if (property.equals("isLocalBranch")) {
// $NON-NLS-1$
if (!(node.getObject() instanceof Ref))
return false;
Ref ref = (Ref) node.getObject();
return ref.getName().startsWith(Constants.R_HEADS);
}
if (property.equals("fetchExists")) {
// $NON-NLS-1$
if (node instanceof RemoteNode) {
String configName = ((RemoteNode) node).getObject();
RemoteConfig rconfig;
try {
rconfig = new RemoteConfig(repository.getConfig(), configName);
} catch (URISyntaxException e2) {
return false;
}
// we need to have a fetch ref spec and a fetch URI
return !rconfig.getFetchRefSpecs().isEmpty() && !rconfig.getURIs().isEmpty();
}
}
if (property.equals("pushExists")) {
// $NON-NLS-1$
if (node instanceof RemoteNode) {
String configName = ((RemoteNode) node).getObject();
RemoteConfig rconfig;
try {
rconfig = new RemoteConfig(repository.getConfig(), configName);
} catch (URISyntaxException e2) {
return false;
}
// we need to have at least a push ref spec and any URI
return !rconfig.getPushRefSpecs().isEmpty() && (!rconfig.getPushURIs().isEmpty() || !rconfig.getURIs().isEmpty());
}
}
if (property.equals("canStash")) {
// $NON-NLS-1$
return repository.getRepositoryState().canCommit();
}
if (property.equals("canMerge")) {
// $NON-NLS-1$
if (repository.getRepositoryState() != RepositoryState.SAFE)
return false;
try {
String branch = repository.getFullBranch();
if (branch == null)
// fail gracefully...
return false;
return branch.startsWith(Constants.R_HEADS);
} catch (IOException e) {
return false;
}
}
if ("isSubmodule".equals(property)) {
// $NON-NLS-1$
RepositoryTreeNode<?> parent = node.getParent();
return parent != null && parent.getType() == RepositoryTreeNodeType.SUBMODULES;
}
return false;
}
use of org.eclipse.jgit.transport.RemoteConfig in project egit by eclipse.
the class GitFlowConfig method getDefaultRemoteConfig.
/**
* @return Configured origin.
*/
public RemoteConfig getDefaultRemoteConfig() {
StoredConfig rc = repository.getConfig();
RemoteConfig result;
try {
result = new RemoteConfig(rc, DEFAULT_REMOTE_NAME);
} catch (URISyntaxException e) {
throw new IllegalStateException(e);
}
return result;
}
Aggregations