Search in sources :

Example 1 with LogResponse

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

the class CommitPresenter method setAmendCommitMessage.

/** {@inheritDoc} */
@Override
public void setAmendCommitMessage() {
    service.log(appContext.getDevMachine(), project.getLocation(), null, false).then(new Operation<LogResponse>() {

        @Override
        public void apply(LogResponse log) throws OperationException {
            final List<Revision> commits = log.getCommits();
            String message = "";
            if (commits != null && (!commits.isEmpty())) {
                final Revision tip = commits.get(0);
                if (tip != null) {
                    message = tip.getMessage();
                }
            }
            CommitPresenter.this.view.setMessage(message);
            CommitPresenter.this.view.setEnableCommitButton(!message.isEmpty());
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            if (getErrorCode(error.getCause()) == ErrorCodes.INIT_COMMIT_WAS_NOT_PERFORMED) {
                dialogFactory.createMessageDialog(constant.commitTitle(), constant.initCommitWasNotPerformed(), null).show();
            } else {
                CommitPresenter.this.view.setMessage("");
                notificationManager.notify(constant.logFailed(), FAIL, NOT_EMERGE_MODE);
            }
        }
    });
}
Also used : LogResponse(org.eclipse.che.api.git.shared.LogResponse) Revision(org.eclipse.che.api.git.shared.Revision) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 2 with LogResponse

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

the class HistoryPresenterTest method shouldShowNotificationOnGetDiffError.

@Test
public void shouldShowNotificationOnGetDiffError() throws Exception {
    Revision revisionA = mock(Revision.class);
    Revision revisionB = mock(Revision.class);
    LogResponse logResponse = mock(LogResponse.class);
    List<Revision> revisions = new ArrayList<>();
    revisions.add(revisionA);
    revisions.add(revisionB);
    when(logResponse.getCommits()).thenReturn(revisions);
    when(constant.diffFailed()).thenReturn("error");
    presenter.show();
    presenter.onRevisionSelected(revisionA);
    verify(logPromise).then(logCaptor.capture());
    logCaptor.getValue().apply(logResponse);
    presenter.onCompareClicked();
    verify(stringPromise).catchError(promiseErrorCaptor.capture());
    promiseErrorCaptor.getValue().apply(null);
    verify(notificationManager).notify(eq("error"), eq(FAIL), eq(EMERGE_MODE));
}
Also used : LogResponse(org.eclipse.che.api.git.shared.LogResponse) Revision(org.eclipse.che.api.git.shared.Revision) ArrayList(java.util.ArrayList) BaseTest(org.eclipse.che.ide.ext.git.client.BaseTest) Test(org.junit.Test)

Example 3 with LogResponse

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

the class GitServiceClientImpl method log.

@Override
public Promise<LogResponse> log(DevMachine devMachine, Path project, Path[] fileFilter, int skip, int maxCount, boolean plainText) {
    StringBuilder params = new StringBuilder().append("?projectPath=").append(project.toString());
    if (fileFilter != null) {
        for (Path file : fileFilter) {
            params.append("&fileFilter=").append(file.toString());
        }
    }
    params.append("&skip=").append(skip);
    params.append("&maxCount=").append(maxCount);
    String url = appContext.getDevMachine().getWsAgentBaseUrl() + LOG + params;
    if (plainText) {
        return asyncRequestFactory.createGetRequest(url).send(dtoUnmarshallerFactory.newUnmarshaller(LogResponse.class));
    } else {
        return asyncRequestFactory.createGetRequest(url).header(ACCEPT, APPLICATION_JSON).send(dtoUnmarshallerFactory.newUnmarshaller(LogResponse.class));
    }
}
Also used : Path(org.eclipse.che.ide.resource.Path) LogResponse(org.eclipse.che.api.git.shared.LogResponse)

Example 4 with LogResponse

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

the class HistoryPresenterTest method shouldShowCompareWhenOneFileChangedInCurrentRevision.

@Test
public void shouldShowCompareWhenOneFileChangedInCurrentRevision() throws Exception {
    Revision parentRevision = mock(Revision.class);
    Revision selectedRevision = mock(Revision.class);
    when(parentRevision.getId()).thenReturn("commitA");
    when(selectedRevision.getId()).thenReturn("commitB");
    LogResponse logResponse = mock(LogResponse.class);
    List<Revision> revisions = new ArrayList<>();
    revisions.add(selectedRevision);
    revisions.add(parentRevision);
    when(logResponse.getCommits()).thenReturn(revisions);
    presenter.show();
    presenter.onRevisionSelected(selectedRevision);
    verify(logPromise).then(logCaptor.capture());
    logCaptor.getValue().apply(logResponse);
    presenter.onCompareClicked();
    verify(stringPromise).then(stringCaptor.capture());
    stringCaptor.getValue().apply("M file");
    verify(comparePresenter).showCompareBetweenRevisions(eq(Path.valueOf("file")), eq(MODIFIED), eq("commitA"), eq("commitB"));
}
Also used : LogResponse(org.eclipse.che.api.git.shared.LogResponse) Revision(org.eclipse.che.api.git.shared.Revision) ArrayList(java.util.ArrayList) BaseTest(org.eclipse.che.ide.ext.git.client.BaseTest) Test(org.junit.Test)

Example 5 with LogResponse

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

the class HistoryPresenterTest method shouldShowChangedListWhenSeveralFilesChangedInSelectedRevision.

@Test
public void shouldShowChangedListWhenSeveralFilesChangedInSelectedRevision() throws Exception {
    Revision revisionA = mock(Revision.class);
    Revision revisionB = mock(Revision.class);
    when(revisionA.getId()).thenReturn("commitA");
    when(revisionB.getId()).thenReturn("commitB");
    LogResponse logResponse = mock(LogResponse.class);
    List<Revision> revisions = new ArrayList<>();
    revisions.add(revisionA);
    revisions.add(revisionB);
    when(logResponse.getCommits()).thenReturn(revisions);
    presenter.show();
    presenter.onRevisionSelected(revisionA);
    verify(logPromise).then(logCaptor.capture());
    logCaptor.getValue().apply(logResponse);
    presenter.onCompareClicked();
    verify(stringPromise).then(stringCaptor.capture());
    stringCaptor.getValue().apply("M file1\nM file2");
    verify(changedListPresenter).show(anyMap(), eq("commitB"), eq("commitA"), any(Project.class));
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) LogResponse(org.eclipse.che.api.git.shared.LogResponse) Revision(org.eclipse.che.api.git.shared.Revision) ArrayList(java.util.ArrayList) BaseTest(org.eclipse.che.ide.ext.git.client.BaseTest) Test(org.junit.Test)

Aggregations

LogResponse (org.eclipse.che.api.git.shared.LogResponse)6 Revision (org.eclipse.che.api.git.shared.Revision)5 BaseTest (org.eclipse.che.ide.ext.git.client.BaseTest)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 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 Project (org.eclipse.che.ide.api.resources.Project)1 Path (org.eclipse.che.ide.resource.Path)1