Search in sources :

Example 1 with PushResponse

use of org.eclipse.che.api.git.shared.PushResponse in project che by eclipse.

the class PushToRemotePresenter method onPushClicked.

/** {@inheritDoc} */
@Override
public void onPushClicked() {
    final StatusNotification notification = notificationManager.notify(constant.pushProcess(), PROGRESS, FLOAT_MODE);
    final String repository = view.getRepository();
    final GitOutputConsole console = gitOutputConsoleFactory.create(PUSH_COMMAND_NAME);
    service.push(appContext.getDevMachine(), project.getLocation(), getRefs(), repository, false).then(new Operation<PushResponse>() {

        @Override
        public void apply(PushResponse response) throws OperationException {
            console.print(response.getCommandOutput());
            processesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
            notification.setStatus(SUCCESS);
            if (response.getCommandOutput().contains("Everything up-to-date")) {
                notification.setTitle(constant.pushUpToDate());
            } else {
                notification.setTitle(constant.pushSuccess(repository));
            }
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            handleError(error.getCause(), notification, console);
            processesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
        }
    });
    view.close();
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) GitOutputConsole(org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) Operation(org.eclipse.che.api.promises.client.Operation) PushResponse(org.eclipse.che.api.git.shared.PushResponse) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 2 with PushResponse

use of org.eclipse.che.api.git.shared.PushResponse in project che by eclipse.

the class PushTest method testPushWhenLocalRepositoryIsUpToDate.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testPushWhenLocalRepositoryIsUpToDate(GitConnectionFactory connectionFactory) throws IOException, ServerException, URISyntaxException, UnauthorizedException {
    //given
    GitConnection remoteConnection = connectToGitRepositoryWithContent(connectionFactory, repository);
    GitConnection localConnection = connectionFactory.getConnection(remoteRepo.getAbsolutePath());
    localConnection.clone(CloneParams.create(remoteConnection.getWorkingDir().getAbsolutePath()));
    //when
    PushResponse pushResponse = localConnection.push(PushParams.create("origin").withRefSpec(singletonList("refs/heads/master:refs/heads/master")).withTimeout(-1));
    //then
    assertEquals(pushResponse.getCommandOutput(), "Everything up-to-date");
}
Also used : GitConnection(org.eclipse.che.api.git.GitConnection) PushResponse(org.eclipse.che.api.git.shared.PushResponse) Test(org.testng.annotations.Test)

Aggregations

PushResponse (org.eclipse.che.api.git.shared.PushResponse)2 GitConnection (org.eclipse.che.api.git.GitConnection)1 Operation (org.eclipse.che.api.promises.client.Operation)1 OperationException (org.eclipse.che.api.promises.client.OperationException)1 PromiseError (org.eclipse.che.api.promises.client.PromiseError)1 StatusNotification (org.eclipse.che.ide.api.notification.StatusNotification)1 GitOutputConsole (org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole)1 Test (org.testng.annotations.Test)1