use of org.eclipse.egit.core.op.ListRemoteOperation in project egit by eclipse.
the class FetchSourcePage method getRemoteRefs.
private List<Ref> getRemoteRefs() {
if (remoteRefs == null) {
URIish uriToCheck;
List<Ref> proposals = new ArrayList<>();
uriToCheck = config.getURIs().get(0);
final ListRemoteOperation lop = new ListRemoteOperation(repository, uriToCheck, Activator.getDefault().getPreferenceStore().getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT));
try {
new ProgressMonitorDialog(getShell()).run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask(UIText.FetchSourcePage_GettingRemoteRefsTaskname, IProgressMonitor.UNKNOWN);
lop.run(monitor);
monitor.done();
}
});
for (Ref ref : lop.getRemoteRefs()) {
if (ref.getName().startsWith(Constants.R_HEADS) || ref.getName().startsWith(Constants.R_TAGS))
proposals.add(ref);
}
Collections.sort(proposals, new Comparator<Ref>() {
@Override
public int compare(Ref o1, Ref o2) {
return o1.getName().compareTo(o2.getName());
}
});
this.remoteRefs = proposals;
} catch (IllegalStateException e) {
setErrorMessage(e.getMessage());
} catch (InvocationTargetException e) {
setErrorMessage(e.getMessage());
} catch (InterruptedException e) {
setErrorMessage(e.getMessage());
}
}
return remoteRefs;
}
use of org.eclipse.egit.core.op.ListRemoteOperation in project egit by eclipse.
the class ListRemoteOperationTest method testIllegalURI.
/**
* Test with illegal URI
*
* @throws Exception
*/
@Test
public void testIllegalURI() throws Exception {
URIish uri = new URIish("file:///" + "no/path");
ListRemoteOperation lrop = new ListRemoteOperation(repository1.getRepository(), uri, 0);
try {
lrop.run(new NullProgressMonitor());
fail("Expected Exception not thrown");
} catch (InvocationTargetException e) {
// expected
}
}
use of org.eclipse.egit.core.op.ListRemoteOperation in project egit by eclipse.
the class ListRemoteOperationTest method testIllegalStateException.
/**
* Call getRemoteRefs without having run the op
*
* @throws Exception
*/
@Test
public void testIllegalStateException() throws Exception {
URIish uri = new URIish("file:///" + repository2.getRepository().getDirectory().getPath());
ListRemoteOperation lrop = new ListRemoteOperation(repository1.getRepository(), uri, 0);
try {
lrop.getRemoteRefs();
fail("Expected Exception not thrown");
} catch (IllegalStateException e) {
// expected
}
}
use of org.eclipse.egit.core.op.ListRemoteOperation in project egit by eclipse.
the class ListRemoteOperationTest method testListRemote.
/**
* List the refs both ways
*
* @throws Exception
*/
@Test
public void testListRemote() throws Exception {
URIish uri = new URIish("file:///" + repository2.getRepository().getDirectory().getPath());
ListRemoteOperation lrop = new ListRemoteOperation(repository1.getRepository(), uri, 0);
lrop.run(null);
assertEquals(4, lrop.getRemoteRefs().size());
assertNotNull(lrop.getRemoteRef("refs/heads/test"));
uri = new URIish("file:///" + repository1.getRepository().getDirectory().getPath());
lrop = new ListRemoteOperation(repository2.getRepository(), uri, 0);
lrop.run(new NullProgressMonitor());
assertEquals(2, lrop.getRemoteRefs().size());
assertNotNull(lrop.getRemoteRef("refs/heads/master"));
}
use of org.eclipse.egit.core.op.ListRemoteOperation in project egit by eclipse.
the class RefSpecPage method revalidateImpl.
private void revalidateImpl(final RepositorySelection newRepoSelection) {
final ListRemoteOperation listRemotesOp;
try {
final URIish uri;
uri = newRepoSelection.getURI(pushPage);
int timeout = Activator.getDefault().getPreferenceStore().getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT);
listRemotesOp = new ListRemoteOperation(local, uri, timeout);
if (credentials != null)
listRemotesOp.setCredentialsProvider(new EGitCredentialsProvider(credentials.getUser(), credentials.getPassword()));
getContainer().run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
listRemotesOp.run(monitor);
}
});
} catch (InvocationTargetException e) {
final Throwable cause = e.getCause();
transportError(cause.getMessage());
Activator.handleError(UIText.RefSpecPage_errorTransportDialogMessage, cause, true);
return;
} catch (InterruptedException e) {
transportError(UIText.RefSpecPage_operationCancelled);
return;
}
this.validatedRepoSelection = newRepoSelection;
specsPanel.setAssistanceData(local, listRemotesOp.getRemoteRefs(), currentRepoSelection.getConfig());
if (newRepoSelection.isConfigSelected()) {
saveButton.setVisible(true);
saveButton.setText(NLS.bind(UIText.RefSpecPage_saveSpecifications, currentRepoSelection.getConfigName()));
saveButton.getParent().layout();
if (!pushPage) {
tagsAutoFollowButton.setSelection(false);
tagsFetchTagsButton.setSelection(false);
tagsNoTagsButton.setSelection(false);
final TagOpt tagOpt = newRepoSelection.getConfig().getTagOpt();
switch(tagOpt) {
case AUTO_FOLLOW:
tagsAutoFollowButton.setSelection(true);
break;
case FETCH_TAGS:
tagsFetchTagsButton.setSelection(true);
break;
case NO_TAGS:
tagsNoTagsButton.setSelection(true);
break;
}
}
} else if (!pushPage)
tagsAutoFollowButton.setSelection(true);
checkPage();
}
Aggregations