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