use of org.eclipse.egit.core.synchronize.GitCommitsModelCache.Commit in project egit by eclipse.
the class GitCommitsModelCacheTest method shouldListAllTypeOfChangesInsideFolderInOneCommit.
@Test
public void shouldListAllTypeOfChangesInsideFolderInOneCommit() throws Exception {
// given
Git git = new Git(db);
writeTrashFile(db, "folder/a.txt", "a content");
writeTrashFile(db, "folder/c.txt", "c content");
git.add().addFilepattern("folder/a.txt").call();
git.add().addFilepattern("folder/c.txt").call();
RevCommit c1 = commit(git, "first commit");
deleteTrashFile(db, "folder/a.txt");
writeTrashFile(db, "folder/b.txt", "b content");
writeTrashFile(db, "folder/c.txt", "new c content");
git.add().addFilepattern("folder/b.txt").call();
RevCommit c2 = commit(git, "second commit");
// when
List<Commit> leftResult = GitCommitsModelCache.build(db, c1, c2, null);
List<Commit> rightResult = GitCommitsModelCache.build(db, c2, c1, null);
// then
// left assertions
assertThat(leftResult, notNullValue());
assertCommit(leftResult.get(0), c2, 3);
assertFileDeletion(c2, c1, leftResult.get(0).getChildren().get("folder/a.txt"), "a.txt", LEFT);
assertFileAddition(c2, c1, leftResult.get(0).getChildren().get("folder/b.txt"), "b.txt", LEFT);
assertFileChange(c2, c1, leftResult.get(0).getChildren().get("folder/c.txt"), "c.txt", LEFT);
// right asserts
assertThat(rightResult, notNullValue());
assertCommit(rightResult.get(0), c2, 3);
assertFileDeletion(c2, c1, rightResult.get(0).getChildren().get("folder/a.txt"), "a.txt", RIGHT);
assertFileAddition(c2, c1, rightResult.get(0).getChildren().get("folder/b.txt"), "b.txt", RIGHT);
assertFileChange(c2, c1, rightResult.get(0).getChildren().get("folder/c.txt"), "c.txt", RIGHT);
}
use of org.eclipse.egit.core.synchronize.GitCommitsModelCache.Commit in project egit by eclipse.
the class GitCommitsModelCacheTest method shouldListAllTypeOfChangesInOneCommit.
@Test
public void shouldListAllTypeOfChangesInOneCommit() throws Exception {
// given
Git git = new Git(db);
writeTrashFile(db, "a.txt", "a content");
writeTrashFile(db, "c.txt", "c content");
git.add().addFilepattern("a.txt").call();
git.add().addFilepattern("c.txt").call();
RevCommit c1 = commit(git, "first commit");
deleteTrashFile(db, "a.txt");
writeTrashFile(db, "b.txt", "b content");
writeTrashFile(db, "c.txt", "new c content");
git.add().addFilepattern("b.txt").call();
RevCommit c2 = commit(git, "second commit");
// when
List<Commit> leftResult = GitCommitsModelCache.build(db, c1, c2, null);
List<Commit> rightResult = GitCommitsModelCache.build(db, c2, c1, null);
// then
// left asserts
assertThat(leftResult, notNullValue());
assertCommit(leftResult.get(0), c2, 3);
assertFileDeletion(c2, c1, leftResult.get(0).getChildren().get("a.txt"), "a.txt", LEFT);
assertFileAddition(c2, c1, leftResult.get(0).getChildren().get("b.txt"), "b.txt", LEFT);
assertFileChange(c2, c1, leftResult.get(0).getChildren().get("c.txt"), "c.txt", LEFT);
// right asserts
assertThat(rightResult, notNullValue());
assertCommit(rightResult.get(0), c2, 3);
assertFileDeletion(c2, c1, rightResult.get(0).getChildren().get("a.txt"), "a.txt", RIGHT);
assertFileAddition(c2, c1, rightResult.get(0).getChildren().get("b.txt"), "b.txt", RIGHT);
assertFileChange(c2, c1, rightResult.get(0).getChildren().get("c.txt"), "c.txt", RIGHT);
}
use of org.eclipse.egit.core.synchronize.GitCommitsModelCache.Commit in project egit by eclipse.
the class GitCommitsModelCacheTest method shouldReturnEmptyListForSameSrcAndDstCommit.
@Test
public void shouldReturnEmptyListForSameSrcAndDstCommit() throws Exception {
// given
Git git = new Git(db);
RevCommit c = commit(git, "second commit");
// when
List<Commit> result = GitCommitsModelCache.build(db, c, c, null);
// then
assertThat(result, notNullValue());
assertThat(result.size(), is(0));
}
use of org.eclipse.egit.core.synchronize.GitCommitsModelCache.Commit in project egit by eclipse.
the class GitCommitsModelCacheTest method shouldListChangesInsideSeparateFoldersInCommit.
@Test
public void shouldListChangesInsideSeparateFoldersInCommit() throws Exception {
// given
Git git = new Git(db);
writeTrashFile(db, "folder/a.txt", "content");
writeTrashFile(db, "folder2/b.txt", "b content");
git.add().addFilepattern("folder/a.txt").call();
git.add().addFilepattern("folder2/b.txt").call();
RevCommit c1 = commit(git, "first commit");
writeTrashFile(db, "folder/a.txt", "new content");
writeTrashFile(db, "folder2/b.txt", "new b content");
RevCommit c2 = commit(git, "second commit");
// when
List<Commit> leftResult = GitCommitsModelCache.build(db, c1, c2, null);
List<Commit> rightResult = GitCommitsModelCache.build(db, c2, c1, null);
// then
// left assertions
assertThat(leftResult, notNullValue());
assertThat(Integer.valueOf(leftResult.size()), is(Integer.valueOf(1)));
assertThat(leftResult.get(0).getShortMessage(), is("second commit"));
assertThat(leftResult.get(0).getChildren(), notNullValue());
assertThat(leftResult.get(0).getChildren().size(), is(2));
assertFileChange(c2, c1, leftResult.get(0).getChildren().get("folder/a.txt"), "a.txt", LEFT);
assertFileChange(c2, c1, leftResult.get(0).getChildren().get("folder2/b.txt"), "b.txt", LEFT);
// right asserts
assertThat(rightResult, notNullValue());
assertThat(Integer.valueOf(rightResult.size()), is(Integer.valueOf(1)));
assertThat(rightResult.get(0).getShortMessage(), is("second commit"));
assertThat(rightResult.get(0).getChildren().size(), is(2));
assertFileChange(c2, c1, rightResult.get(0).getChildren().get("folder/a.txt"), "a.txt", RIGHT);
assertFileChange(c2, c1, rightResult.get(0).getChildren().get("folder2/b.txt"), "b.txt", RIGHT);
}
use of org.eclipse.egit.core.synchronize.GitCommitsModelCache.Commit in project egit by eclipse.
the class GitCommitsModelCacheTest method shouldListAdditionOrDeletionInsideFolderInCommit.
@Test
public void shouldListAdditionOrDeletionInsideFolderInCommit() throws Exception {
// given
Git git = new Git(db);
writeTrashFile(db, "folder/a.txt", "content");
git.add().addFilepattern("folder/a.txt").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());
assertCommit(leftResult.get(0), c, 1);
assertThat(leftResult.get(0).getChildren().size(), is(1));
assertFileAddition(c, leftResult.get(0).getChildren().get("folder/a.txt"), "a.txt", LEFT);
// right asserts, after changing sides addition becomes deletion
assertThat(rightResult, notNullValue());
assertCommit(rightResult.get(0), c, 1);
assertThat(rightResult.get(0).getChildren().size(), is(1));
assertFileAddition(c, rightResult.get(0).getChildren().get("folder/a.txt"), "a.txt", RIGHT);
}
Aggregations