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);
}
}
});
}
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));
}
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));
}
}
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"));
}
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));
}
Aggregations