use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.
the class DecoratableResourceAdapterTest method testDecorationAddedFile.
@Test
public void testDecorationAddedFile() throws Exception {
// Create new file
write(new File(project.getLocation().toFile(), TEST_FILE), "Something");
project.refreshLocal(IResource.DEPTH_INFINITE, null);
IResource file = project.findMember(TEST_FILE);
// Add file
git.add().addFilepattern(".").call();
IDecoratableResource[] expectedDRs = new IDecoratableResource[] { new TestDecoratableResource(project).tracked().modified(), new TestDecoratableResource(file).tracked().added() };
waitForIndexDiffUpdate(true);
IndexDiffData indexDiffData = indexDiffCacheEntry.getIndexDiff();
IDecoratableResource[] actualDRs = { new DecoratableResourceAdapter(indexDiffData, project), new DecoratableResourceAdapter(indexDiffData, file) };
assertArrayEquals(expectedDRs, actualDRs);
}
use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.
the class DecoratableResourceAdapterTest method testDecorationDeletedFile.
@Test
public void testDecorationDeletedFile() throws Exception {
// Create new file
File f = new File(project.getLocation().toFile(), TEST_FILE);
write(f, "Something");
project.refreshLocal(IResource.DEPTH_INFINITE, null);
// Add and commit file
git.add().addFilepattern(".").call();
git.commit().setMessage("First commit").call();
// Delete file
FileUtils.delete(f);
IDecoratableResource expectedDR = new TestDecoratableResource(project).tracked().dirty();
waitForIndexDiffUpdate(true);
IndexDiffData indexDiffData = indexDiffCacheEntry.getIndexDiff();
IDecoratableResource actualDR = new DecoratableResourceAdapter(indexDiffData, project);
assertEquals(expectedDR, actualDR);
assertHasUnstagedChanges(true, actualDR);
}
use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.
the class DecoratableResourceAdapterTest method testDecorationCommittedFile.
@Test
public void testDecorationCommittedFile() throws Exception {
// Create new file
write(new File(project.getLocation().toFile(), TEST_FILE), "Something");
project.refreshLocal(IResource.DEPTH_INFINITE, null);
IResource file = project.findMember(TEST_FILE);
// Add and commit file
git.add().addFilepattern(".").call();
git.commit().setMessage("First commit").call();
IDecoratableResource[] expectedDRs = new IDecoratableResource[] { new TestDecoratableResource(project).tracked(), new TestDecoratableResource(file).tracked() };
waitForIndexDiffUpdate(true);
IndexDiffData indexDiffData = indexDiffCacheEntry.getIndexDiff();
IDecoratableResource[] actualDRs = { new DecoratableResourceAdapter(indexDiffData, project), new DecoratableResourceAdapter(indexDiffData, file) };
assertArrayEquals(expectedDRs, actualDRs);
assertHasUnstagedChanges(false, actualDRs);
}
use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.
the class DecoratableResourceAdapterTest method testDecorationFileInIgnoredFolder.
@Test
public void testDecorationFileInIgnoredFolder() throws Exception {
// Create new file
FileUtils.mkdir(new File(project.getLocation().toFile(), "dir"));
write(new File(project.getLocation().toFile(), "dir/file"), "Something");
write(new File(project.getLocation().toFile(), ".gitignore"), "dir");
project.refreshLocal(IResource.DEPTH_INFINITE, null);
IResource dir = project.findMember("dir");
IResource file = project.findMember("dir/file");
IResource gitignore = project.findMember(".gitignore");
IDecoratableResource[] expectedDRs = new IDecoratableResource[] { new TestDecoratableResource(project).tracked().dirty(), new TestDecoratableResource(gitignore), new TestDecoratableResource(file).ignored(), new TestDecoratableResource(dir).ignored() };
waitForIndexDiffUpdate(true);
IndexDiffData indexDiffData = indexDiffCacheEntry.getIndexDiff();
IDecoratableResource[] actualDRs = { new DecoratableResourceAdapter(indexDiffData, project), new DecoratableResourceAdapter(indexDiffData, gitignore), new DecoratableResourceAdapter(indexDiffData, file), new DecoratableResourceAdapter(indexDiffData, dir) };
assertArrayEquals(expectedDRs, actualDRs);
}
use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.
the class DecoratableResourceAdapterTest method testDecorationConflictingFile.
@Test
public void testDecorationConflictingFile() throws Exception {
// Create new file
File f = new File(project.getLocation().toFile(), TEST_FILE);
write(f, "Something");
project.refreshLocal(IResource.DEPTH_INFINITE, null);
IResource file = project.findMember(TEST_FILE);
// Add and commit file
git.add().addFilepattern(".").call();
git.commit().setMessage("Commit on master branch").call();
// Create and checkout new branch, change file content, add and commit
// file
git.checkout().setCreateBranch(true).setName("first_topic").call();
write(f, "SomethingElse");
project.refreshLocal(IResource.DEPTH_INFINITE, null);
git.add().addFilepattern(".").call();
RevCommit commitOnFirstTopicBranch = git.commit().setMessage("Commit on first topic branch").call();
// Create and checkout new branch (from master), change file content,
// add and commit file
git.checkout().setName("master").call();
git.checkout().setCreateBranch(true).setName("second_topic").call();
write(f, "SomethingDifferent");
project.refreshLocal(IResource.DEPTH_INFINITE, null);
git.add().addFilepattern(".").call();
git.commit().setMessage("Commit on second topic branch").call();
// Merge HEAD ('Commit on second topic branch') with 'Commit on first
// topic branch' to create a conflict
assertTrue(git.merge().include(commitOnFirstTopicBranch).call().getMergeStatus() == MergeStatus.CONFLICTING);
IDecoratableResource[] expectedDRs = new IDecoratableResource[] { new TestDecoratableResource(project).tracked().conflicts(), new TestDecoratableResource(file).tracked().conflicts() };
waitForIndexDiffUpdate(true);
IndexDiffData indexDiffData = indexDiffCacheEntry.getIndexDiff();
IDecoratableResource[] actualDRs = { new DecoratableResourceAdapter(indexDiffData, project), new DecoratableResourceAdapter(indexDiffData, file) };
assertArrayEquals(expectedDRs, actualDRs);
assertHasUnstagedChanges(true, actualDRs);
}
Aggregations