use of org.eclipse.egit.core.op.PushOperation in project jbosstools-openshift by jbosstools.
the class EGitUtils method createPushOperation.
private static PushOperation createPushOperation(RemoteConfig remoteConfig, Repository repository, boolean force, OutputStream out) throws CoreException {
Collection<URIish> pushURIs = getPushURIs(remoteConfig);
Collection<RefSpec> fetchRefSpecs = getFetchRefSpec(remoteConfig);
Collection<RefSpec> pushRefSpecs = setForceUpdate(force, getPushRefSpecs(remoteConfig));
PushOperationSpecification pushSpec = createPushSpec(pushURIs, pushRefSpecs, fetchRefSpecs, repository);
PushOperation pushOperation = new PushOperation(repository, pushSpec, false, getEgitTimeout());
pushOperation.setOutputStream(out);
return pushOperation;
}
use of org.eclipse.egit.core.op.PushOperation in project egit by eclipse.
the class PushOperationTest method testInvalidUriDuringPush.
/**
* An invalid URI should yield an operation result with an error message
* and the exception should be logged
*
* @throws Exception
*/
@Test
public void testInvalidUriDuringPush() throws Exception {
ILog log = Activator.getDefault().getLog();
LogListener listener = new LogListener();
log.addLogListener(listener);
PushOperation pop = createInvalidPushOperation();
pop.run(new NullProgressMonitor());
PushOperationResult result = pop.getOperationResult();
String errorMessage = result.getErrorMessage(new URIish(INVALID_URI));
assertNotNull(errorMessage);
assertTrue(errorMessage.contains(INVALID_URI));
assertTrue(listener.loggedSomething());
assertTrue(listener.loggedException());
}
use of org.eclipse.egit.core.op.PushOperation in project egit by eclipse.
the class PushOperationTest method testIllegalStateExceptionOnGetResultWithoutRun.
/**
* We should get an {@link IllegalStateException} if we run
* getOperationResult before run()
*
* @throws Exception
*/
@Test
public void testIllegalStateExceptionOnGetResultWithoutRun() throws Exception {
// push from repository1 to repository2
PushOperation pop = createPushOperation();
try {
pop.getOperationResult();
fail("Expected Exception not thrown");
} catch (IllegalStateException e) {
// expected
}
}
use of org.eclipse.egit.core.op.PushOperation in project egit by eclipse.
the class PushOperationTest method createInvalidPushOperation.
private PushOperation createInvalidPushOperation() throws Exception {
// set up push with invalid URI to provoke an exception
PushOperationSpecification spec = new PushOperationSpecification();
// the remote is invalid
URIish remote = new URIish(INVALID_URI);
// update master upon master
Repository local = repository1.getRepository();
RemoteRefUpdate update = new RemoteRefUpdate(local, "HEAD", "refs/heads/test", false, null, null);
spec.addURIRefUpdates(remote, Collections.singletonList(update));
// now we can construct the push operation
PushOperation pop = new PushOperation(local, spec, false, 0);
return pop;
}
use of org.eclipse.egit.core.op.PushOperation in project egit by eclipse.
the class PushOperationTest method createPushOperation.
private PushOperation createPushOperation() throws Exception {
// set up push from repository1 to repository2
// we cannot re-use the RemoteRefUpdate!!!
PushOperationSpecification spec = new PushOperationSpecification();
// the remote is repo2
URIish remote = new URIish("file:///" + repository2.getRepository().getDirectory().toString());
// update master upon master
List<RemoteRefUpdate> refUpdates = new ArrayList<RemoteRefUpdate>();
RemoteRefUpdate update = new RemoteRefUpdate(repository1.getRepository(), "HEAD", "refs/heads/test", false, null, null);
refUpdates.add(update);
spec.addURIRefUpdates(remote, refUpdates);
// now we can construct the push operation
PushOperation pop = new PushOperation(repository1.getRepository(), spec, false, 0);
return pop;
}
Aggregations