Search in sources :

Example 1 with PushOperation

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;
}
Also used : URIish(org.eclipse.jgit.transport.URIish) RefSpec(org.eclipse.jgit.transport.RefSpec) PushOperationSpecification(org.eclipse.egit.core.op.PushOperationSpecification) PushOperation(org.eclipse.egit.core.op.PushOperation)

Example 2 with 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());
}
Also used : PushOperationResult(org.eclipse.egit.core.op.PushOperationResult) URIish(org.eclipse.jgit.transport.URIish) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ILogListener(org.eclipse.core.runtime.ILogListener) ILog(org.eclipse.core.runtime.ILog) PushOperation(org.eclipse.egit.core.op.PushOperation) Test(org.junit.Test)

Example 3 with PushOperation

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
    }
}
Also used : PushOperation(org.eclipse.egit.core.op.PushOperation) Test(org.junit.Test)

Example 4 with PushOperation

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;
}
Also used : URIish(org.eclipse.jgit.transport.URIish) RemoteRefUpdate(org.eclipse.jgit.transport.RemoteRefUpdate) TestRepository(org.eclipse.egit.core.test.TestRepository) Repository(org.eclipse.jgit.lib.Repository) PushOperationSpecification(org.eclipse.egit.core.op.PushOperationSpecification) PushOperation(org.eclipse.egit.core.op.PushOperation)

Example 5 with PushOperation

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;
}
Also used : URIish(org.eclipse.jgit.transport.URIish) RemoteRefUpdate(org.eclipse.jgit.transport.RemoteRefUpdate) ArrayList(java.util.ArrayList) PushOperationSpecification(org.eclipse.egit.core.op.PushOperationSpecification) PushOperation(org.eclipse.egit.core.op.PushOperation)

Aggregations

PushOperation (org.eclipse.egit.core.op.PushOperation)14 URIish (org.eclipse.jgit.transport.URIish)9 PushOperationSpecification (org.eclipse.egit.core.op.PushOperationSpecification)8 RemoteRefUpdate (org.eclipse.jgit.transport.RemoteRefUpdate)7 PushOperationResult (org.eclipse.egit.core.op.PushOperationResult)6 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 RefSpec (org.eclipse.jgit.transport.RefSpec)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 CoreException (org.eclipse.core.runtime.CoreException)3 File (java.io.File)2 IFile (org.eclipse.core.resources.IFile)2 IProject (org.eclipse.core.resources.IProject)2 IStatus (org.eclipse.core.runtime.IStatus)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 Status (org.eclipse.core.runtime.Status)2 EGitCredentialsProvider (org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider)2 NotSupportedException (org.eclipse.jgit.errors.NotSupportedException)2 MalformedURLException (java.net.MalformedURLException)1