use of org.eclipse.egit.core.synchronize.GitCommitsModelCache.Commit in project egit by eclipse.
the class GitCommitsModelCacheTest method shouldListAdditionsOrDeletionsInsideFolderInCommit.
@Test
public void shouldListAdditionsOrDeletionsInsideFolderInCommit() throws Exception {
// given
Git git = new Git(db);
writeTrashFile(db, "folder/a.txt", "content");
writeTrashFile(db, "folder/b.txt", "b content");
git.add().addFilepattern("folder").call();
RevCommit c = commit(git, "first commit");
// when
List<Commit> leftResult = GitCommitsModelCache.build(db, initialTagId(), c, null);
List<Commit> rightResult = GitCommitsModelCache.build(db, c, initialTagId(), null);
// then
// left assertions
assertThat(leftResult, notNullValue());
assertThat(Integer.valueOf(leftResult.size()), is(Integer.valueOf(1)));
assertCommit(leftResult.get(0), c, 2);
assertThat(leftResult.get(0).getChildren().size(), is(2));
assertFileAddition(c, leftResult.get(0).getChildren().get("folder/a.txt"), "a.txt", LEFT);
assertFileAddition(c, leftResult.get(0).getChildren().get("folder/b.txt"), "b.txt", LEFT);
// right asserts, after changing sides addition becomes deletion
assertThat(rightResult, notNullValue());
assertThat(Integer.valueOf(rightResult.size()), is(Integer.valueOf(1)));
assertCommit(rightResult.get(0), c, 2);
assertThat(rightResult.get(0).getChildren().size(), is(2));
assertFileAddition(c, rightResult.get(0).getChildren().get("folder/a.txt"), "a.txt", RIGHT);
assertFileAddition(c, rightResult.get(0).getChildren().get("folder/b.txt"), "b.txt", RIGHT);
}
use of org.eclipse.egit.core.synchronize.GitCommitsModelCache.Commit in project egit by eclipse.
the class GitModelTestCase method getCommit.
protected Commit getCommit(File repoFile, String rev) throws Exception {
Repository repo = lookupRepository(repoFile);
ObjectId revId = repo.resolve(rev);
Commit commit = mock(Commit.class);
Mockito.when(commit.getId()).thenReturn(AbbreviatedObjectId.fromObjectId(revId));
return commit;
}
use of org.eclipse.egit.core.synchronize.GitCommitsModelCache.Commit in project egit by eclipse.
the class GitChangeSetLabelProvider method createChangeSetLabel.
private String createChangeSetLabel(GitModelCommit commitModel) {
String format = store.getString(UIPreferences.SYNC_VIEW_CHANGESET_LABEL_FORMAT);
Commit commit = commitModel.getCachedCommitObj();
Map<String, String> bindings = new HashMap<>();
bindings.put(BINDING_CHANGESET_DATE, dateFormatter.formatDate(commit.getCommitDate()));
bindings.put(BINDING_CHANGESET_AUTHOR, commit.getAuthorName());
bindings.put(BINDING_CHANGESET_COMMITTER, commit.getCommitterName());
bindings.put(BINDING_CHANGESET_SHORT_MESSAGE, commit.getShortMessage());
return formatName(format, bindings);
}
use of org.eclipse.egit.core.synchronize.GitCommitsModelCache.Commit in project egit by eclipse.
the class GitModelRepository method getListOfCommit.
private List<GitModelObjectContainer> getListOfCommit(List<Commit> commitCache) {
Repository repo = gsd.getRepository();
Set<IProject> projectsSet = gsd.getProjects();
IProject[] projects = projectsSet.toArray(new IProject[projectsSet.size()]);
List<GitModelObjectContainer> result = new ArrayList<>();
for (Commit commit : commitCache) result.add(new GitModelCommit(this, repo, commit, projects));
return result;
}
use of org.eclipse.egit.core.synchronize.GitCommitsModelCache.Commit in project egit by eclipse.
the class GitModelRepository method getChildren.
@Override
public GitModelObject[] getChildren() {
List<GitModelObjectContainer> result = new ArrayList<>();
Repository repo = gsd.getRepository();
RevCommit srcRevCommit = gsd.getSrcRevCommit();
RevCommit dstRevCommit = gsd.getDstRevCommit();
TreeFilter pathFilter = gsd.getPathFilter();
List<Commit> commitCache;
if (srcRevCommit != null && dstRevCommit != null)
try {
commitCache = GitCommitsModelCache.build(repo, srcRevCommit, dstRevCommit, pathFilter);
} catch (IOException e) {
Activator.logError(e.getMessage(), e);
commitCache = null;
}
else
commitCache = null;
if (commitCache != null && !commitCache.isEmpty())
result.addAll(getListOfCommit(commitCache));
result.addAll(getWorkingChanges());
disposeOldChildren();
children = result.toArray(new GitModelObjectContainer[result.size()]);
return children;
}
Aggregations