use of org.eclipse.che.api.git.shared.Revision in project che by eclipse.
the class ResetToCommitViewImpl method createCommitsTable.
/** Creates table what contains list of available commits. */
private void createCommitsTable() {
commits = new CellTable<Revision>(15, tableRes);
Column<Revision, String> dateColumn = new Column<Revision, String>(new TextCell()) {
@Override
public String getValue(Revision revision) {
return DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_MEDIUM).format(new Date((long) revision.getCommitTime()));
}
@Override
public void render(Cell.Context context, Revision revision, SafeHtmlBuilder sb) {
sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "git-reset-cellTable-" + context.getIndex() + "\">");
super.render(context, revision, sb);
}
};
Column<Revision, String> commiterColumn = new Column<Revision, String>(new TextCell()) {
@Override
public String getValue(Revision revision) {
if (revision.getCommitter() == null) {
return "";
}
return revision.getCommitter().getName();
}
};
Column<Revision, String> commentColumn = new Column<Revision, String>(new TextCell()) {
@Override
public String getValue(Revision revision) {
return revision.getMessage();
}
};
commits.addColumn(dateColumn, locale.commitGridDate());
commits.setColumnWidth(dateColumn, "20%");
commits.addColumn(commiterColumn, locale.commitGridCommiter());
commits.setColumnWidth(commiterColumn, "20%");
commits.addColumn(commentColumn, locale.commitGridComment());
commits.setColumnWidth(commentColumn, "60%");
final SingleSelectionModel<Revision> selectionModel = new SingleSelectionModel<Revision>();
selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
@Override
public void onSelectionChange(SelectionChangeEvent event) {
Revision selectedObject = selectionModel.getSelectedObject();
delegate.onRevisionSelected(selectedObject);
}
});
commits.setSelectionModel(selectionModel);
}
use of org.eclipse.che.api.git.shared.Revision 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.Revision 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));
}
use of org.eclipse.che.api.git.shared.Revision in project che by eclipse.
the class HistoryPresenterTest method shouldGetCommitsAndShowDialog.
@Test
public void shouldGetCommitsAndShowDialog() throws Exception {
LogResponse response = mock(LogResponse.class);
List<Revision> revisions = singletonList(mock(Revision.class));
when(response.getCommits()).thenReturn(revisions);
presenter.show();
verify(logPromise).then(logCaptor.capture());
logCaptor.getValue().apply(response);
verify(view).setRevisions(revisions);
verify(view).showDialog();
}
use of org.eclipse.che.api.git.shared.Revision in project che by eclipse.
the class GitServiceClientImpl method commit.
@Override
public Promise<Revision> commit(DevMachine devMachine, Path project, String message, boolean all, Path[] files, boolean amend) {
List<String> paths = new ArrayList<>(files.length);
for (Path file : files) {
if (!file.isEmpty()) {
paths.add(file.toString());
}
}
CommitRequest commitRequest = dtoFactory.createDto(CommitRequest.class).withMessage(message).withAmend(amend).withAll(all).withFiles(paths);
String url = devMachine.getWsAgentBaseUrl() + COMMIT + "?projectPath=" + project;
return asyncRequestFactory.createPostRequest(url, commitRequest).loader(loader).send(dtoUnmarshallerFactory.newUnmarshaller(Revision.class));
}
Aggregations