Search in sources :

Example 1 with CommitInfo

use of de.catma.project.CommitInfo in project catma by forTEXT.

the class UnsychronizedCommitsDialog method initComponents.

private void initComponents(List<CommitInfo> unsynchronizedChanges) {
    setHeight("400px");
    setWidth("600px");
    setModal(true);
    center();
    VerticalLayout content = new VerticalLayout();
    setContent(content);
    if (unsynchronizedChanges.isEmpty()) {
        content.addComponent(new Label("All your commits are synchronized!"));
    } else {
        content.addComponent(new Label(String.format("You have %1$d unsynchronized commit%2$s:", unsynchronizedChanges.size(), unsynchronizedChanges.size() == 1 ? "" : "s")));
    }
    for (CommitInfo ci : unsynchronizedChanges) {
        Label l = new Label(ci.getCommitId() + "<br/><b>" + Cleaner.clean(ci.getCommitMsg().replaceAll(Pattern.quote("with") + "\\s+" + Pattern.quote("ID") + "\\s+\\S+\\s?", "")) + "</b>");
        l.setContentMode(ContentMode.HTML);
        content.addComponent(l);
    }
    btSynchNow = new Button("Synchronize with the team now");
    // $NON-NLS-1$
    btSynchNow.addStyleName("primary-button");
    content.addComponent(btSynchNow);
    content.setExpandRatio(btSynchNow, 1.0f);
    content.setComponentAlignment(btSynchNow, Alignment.BOTTOM_RIGHT);
}
Also used : Button(com.vaadin.ui.Button) Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout) CommitInfo(de.catma.project.CommitInfo)

Example 2 with CommitInfo

use of de.catma.project.CommitInfo in project catma by forTEXT.

the class JGitRepoManager method getUnsynchronizedChanges.

@Override
public List<CommitInfo> getUnsynchronizedChanges() throws Exception {
    List<CommitInfo> result = new ArrayList<>();
    if (!isAttached()) {
        throw new IllegalStateException("Can't call `hasUnsynchronizedChanges` on a detached instance");
    }
    try {
        if (this.gitApi.getRepository().resolve(Constants.HEAD) == null) {
            // no HEAD -> new empty Project, no commits yet
            return result;
        }
        List<Ref> refs = this.gitApi.branchList().setListMode(ListMode.REMOTE).call();
        Iterable<RevCommit> commits = null;
        if (refs.isEmpty()) {
            // project never synchronized
            commits = this.gitApi.log().call();
        } else {
            commits = this.gitApi.log().addRange(this.gitApi.getRepository().resolve("refs/remotes/origin/master"), this.gitApi.getRepository().resolve("refs/heads/master")).call();
        }
        for (RevCommit c : commits) {
            result.add(new CommitInfo(c.getId().getName(), c.getFullMessage()));
        }
    } catch (GitAPIException e) {
        throw new IOException("Cannot check for unsynchronized changes!", e);
    }
    return result;
}
Also used : GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) Ref(org.eclipse.jgit.lib.Ref) ArrayList(java.util.ArrayList) CommitInfo(de.catma.project.CommitInfo) IOException(java.io.IOException) RevCommit(org.eclipse.jgit.revwalk.RevCommit)

Aggregations

CommitInfo (de.catma.project.CommitInfo)2 Button (com.vaadin.ui.Button)1 Label (com.vaadin.ui.Label)1 VerticalLayout (com.vaadin.ui.VerticalLayout)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)1 Ref (org.eclipse.jgit.lib.Ref)1 RevCommit (org.eclipse.jgit.revwalk.RevCommit)1