Search in sources :

Example 16 with Revision

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, boolean amend) {
    CommitRequest commitRequest = dtoFactory.createDto(CommitRequest.class).withMessage(message).withAmend(amend).withAll(all);
    String url = devMachine.getWsAgentBaseUrl() + COMMIT + "?projectPath=" + project;
    return asyncRequestFactory.createPostRequest(url, commitRequest).loader(loader).send(dtoUnmarshallerFactory.newUnmarshaller(Revision.class));
}
Also used : CommitRequest(org.eclipse.che.api.git.shared.CommitRequest) Revision(org.eclipse.che.api.git.shared.Revision)

Example 17 with Revision

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

the class RevisionListViewImpl method createRevisionsTable.

private void createRevisionsTable(org.eclipse.che.ide.Resources coreRes) {
    Column<Revision, String> idColumn = new Column<Revision, String>(new TextCell()) {

        @Override
        public String getValue(Revision revision) {
            return revision.getId().substring(0, 8) + "...";
        }
    };
    Column<Revision, String> timeColumn = new Column<Revision, String>(new TextCell()) {

        @Override
        public String getValue(Revision revision) {
            return dateTimeFormatter.getFormattedDate(revision.getCommitTime());
        }
    };
    Column<Revision, String> authorColumn = new Column<Revision, String>(new TextCell()) {

        @Override
        public String getValue(Revision revision) {
            return revision.getCommitter().getName();
        }
    };
    Column<Revision, String> titleColumn = new Column<Revision, String>(new TextCell()) {

        @Override
        public String getValue(Revision revision) {
            return revision.getMessage().substring(0, 50);
        }
    };
    revisions = new CellTable<>(15, coreRes);
    revisions.setWidth("100%");
    revisions.addColumn(idColumn, locale.viewCompareRevisionTableIdTitle());
    revisions.addColumn(timeColumn, locale.viewCompareRevisionTableTimeTitle());
    revisions.addColumn(authorColumn, locale.viewCompareRevisionTableAuthorTitle());
    revisions.addColumn(titleColumn, locale.viewCompareRevisionTableTitleTitle());
    selectionModel = new SingleSelectionModel<Revision>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            description.setText(selectionModel.getSelectedObject().getMessage());
            delegate.onRevisionSelected(selectionModel.getSelectedObject());
        }
    });
    revisions.setSelectionModel(selectionModel);
    revisions.addDomHandler(new DoubleClickHandler() {

        @Override
        public void onDoubleClick(DoubleClickEvent event) {
            delegate.onRevisionDoubleClicked();
        }
    }, DoubleClickEvent.getType());
    this.revisionsPanel.add(revisions);
}
Also used : Revision(org.eclipse.che.api.git.shared.Revision) Column(com.google.gwt.user.cellview.client.Column) DoubleClickHandler(com.google.gwt.event.dom.client.DoubleClickHandler) DoubleClickEvent(com.google.gwt.event.dom.client.DoubleClickEvent) TextCell(com.google.gwt.cell.client.TextCell) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent)

Example 18 with Revision

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

the class HistoryViewImpl method createRevisionsTable.

private void createRevisionsTable(org.eclipse.che.ide.Resources coreRes) {
    Column<Revision, String> idColumn = new Column<Revision, String>(new TextCell()) {

        @Override
        public String getValue(Revision revision) {
            return revision.getId().substring(0, 8) + "...";
        }
    };
    Column<Revision, String> timeColumn = new Column<Revision, String>(new TextCell()) {

        @Override
        public String getValue(Revision revision) {
            return dateTimeFormatter.getFormattedDate(revision.getCommitTime());
        }
    };
    Column<Revision, String> authorColumn = new Column<Revision, String>(new TextCell()) {

        @Override
        public String getValue(Revision revision) {
            return revision.getCommitter().getName();
        }
    };
    Column<Revision, String> titleColumn = new Column<Revision, String>(new TextCell()) {

        @Override
        public String getValue(Revision revision) {
            return revision.getMessage().substring(0, 50);
        }
    };
    revisions = new CellTable<>(15, coreRes);
    revisions.setWidth("100%");
    revisions.addColumn(idColumn, locale.viewCompareRevisionTableIdTitle());
    revisions.addColumn(timeColumn, locale.viewCompareRevisionTableTimeTitle());
    revisions.addColumn(authorColumn, locale.viewCompareRevisionTableAuthorTitle());
    revisions.addColumn(titleColumn, locale.viewCompareRevisionTableTitleTitle());
    selectionModel = new SingleSelectionModel<Revision>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            description.setText(selectionModel.getSelectedObject().getMessage());
            delegate.onRevisionSelected(selectionModel.getSelectedObject());
        }
    });
    revisions.setSelectionModel(selectionModel);
    revisions.addDomHandler(new DoubleClickHandler() {

        @Override
        public void onDoubleClick(DoubleClickEvent event) {
            delegate.onRevisionDoubleClicked();
        }
    }, DoubleClickEvent.getType());
    this.revisionsPanel.add(revisions);
}
Also used : Revision(org.eclipse.che.api.git.shared.Revision) Column(com.google.gwt.user.cellview.client.Column) DoubleClickHandler(com.google.gwt.event.dom.client.DoubleClickHandler) DoubleClickEvent(com.google.gwt.event.dom.client.DoubleClickEvent) TextCell(com.google.gwt.cell.client.TextCell) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent)

Example 19 with Revision

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

the class LogPage method writeTo.

/** @see InfoPage#writeTo(java.io.OutputStream) */
@Override
public void writeTo(OutputStream out) throws IOException {
    PrintWriter writer = new PrintWriter(out);
    DateFormat df = (DateFormat) dateFormat.clone();
    for (Revision commit : commits) {
        writer.format("commit %s\n", commit.getId());
        GitUser commiter = commit.getCommitter();
        if (commiter != null) {
            writer.format("Author: %1$s <%2$s>\n", commiter.getName(), commiter.getEmail());
        }
        long commitTime = commit.getCommitTime();
        if (commitTime > 0) {
            writer.format("Date:   %s\n", df.format(new Date(commitTime)));
        }
        writer.println();
        // Message with indent.
        String[] lines = commit.getMessage().split("\n");
        for (String line : lines) {
            writer.format("    %s\n", line);
        }
        writer.println();
    }
    writer.flush();
}
Also used : Revision(org.eclipse.che.api.git.shared.Revision) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) Date(java.util.Date) PrintWriter(java.io.PrintWriter) GitUser(org.eclipse.che.api.git.shared.GitUser)

Example 20 with Revision

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

the class CommitTest method testSimpleCommit.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testSimpleCommit(GitConnectionFactory connectionFactory) throws GitException, IOException {
    //given
    GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
    //add new File
    addFile(connection, "DONTREADME", "secret");
    //add changes
    connection.add(AddParams.create(AddRequest.DEFAULT_PATTERN));
    //when
    CommitParams commitParams = CommitParams.create("Commit message").withAmend(false).withAll(false);
    Revision revision = connection.commit(commitParams);
    //then
    assertEquals(revision.getMessage(), commitParams.getMessage());
}
Also used : CommitParams(org.eclipse.che.api.git.params.CommitParams) Revision(org.eclipse.che.api.git.shared.Revision) GitConnection(org.eclipse.che.api.git.GitConnection) Test(org.testng.annotations.Test)

Aggregations

Revision (org.eclipse.che.api.git.shared.Revision)23 GitConnection (org.eclipse.che.api.git.GitConnection)10 Test (org.testng.annotations.Test)9 ArrayList (java.util.ArrayList)6 LogResponse (org.eclipse.che.api.git.shared.LogResponse)5 BaseTest (org.eclipse.che.ide.ext.git.client.BaseTest)5 Test (org.junit.Test)5 CommitParams (org.eclipse.che.api.git.params.CommitParams)4 TextCell (com.google.gwt.cell.client.TextCell)3 Column (com.google.gwt.user.cellview.client.Column)3 SelectionChangeEvent (com.google.gwt.view.client.SelectionChangeEvent)3 GitUser (org.eclipse.che.api.git.shared.GitUser)3 DoubleClickEvent (com.google.gwt.event.dom.client.DoubleClickEvent)2 DoubleClickHandler (com.google.gwt.event.dom.client.DoubleClickHandler)2 IOException (java.io.IOException)2 Date (java.util.Date)2 LogPage (org.eclipse.che.api.git.LogPage)2 GitException (org.eclipse.che.api.git.exception.GitException)2 Branch (org.eclipse.che.api.git.shared.Branch)2 CommitRequest (org.eclipse.che.api.git.shared.CommitRequest)2