use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.
the class DecoratableWorkingSetTest method testAnyConflictsIsConflicts.
@Test
public void testAnyConflictsIsConflicts() throws Exception {
// Create new file and commit
IFile file = createFile(project1, TEST_FILE, "Something");
gitAdd(git, file);
RevCommit masterCommit = gitCommit(git);
// Create and checkout new branch, change file content, add and commit
// file
git.checkout().setCreateBranch(true).setName("first_topic").call();
file = findFile(project1, TEST_FILE);
write(file.getLocation().toFile(), "First Topic Content");
project1.refreshLocal(IResource.DEPTH_INFINITE, null);
gitAdd(git, file);
RevCommit firstTopicCommit = gitCommit(git);
// Create and checkout new branch (from master), change file content,
// add and commit file
git.checkout().setCreateBranch(true).setStartPoint(masterCommit).setName("second_topic").call();
file = findFile(project1, TEST_FILE);
write(file.getLocation().toFile(), "Second Topic Content");
project1.refreshLocal(IResource.DEPTH_INFINITE, null);
gitAdd(git, file);
gitCommit(git);
// merge second_topic with first_topic
MergeResult mergeResult = git.merge().include(firstTopicCommit).call();
assertEquals(MergeStatus.CONFLICTING, mergeResult.getMergeStatus());
IDecoratableResource[] expectedDRs = new IDecoratableResource[] { newExpectedDecoratableResource(project1).tracked().conflicts(), newExpectedDecoratableResource(file).tracked().conflicts(), newExpectedDecoratableWorkingSet(WORKING_SET).tracked().conflicts() };
IndexDiffData indexDiffData = waitForIndexDiff(true);
IDecoratableResource[] actualDRs = { newDecoratableResource(indexDiffData, project1), newDecoratableResource(indexDiffData, file), newDecoratableWorkingSet(resourceMapping) };
assertArrayEquals(expectedDRs, actualDRs);
assertHasUnstagedChanges(true, actualDRs);
assertDecorationConflicts(resourceMapping);
}
use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.
the class IndexDiffCacheTest method testAddingAFile.
@Test
public void testAddingAFile() throws Exception {
new ConnectProviderOperation(project.project, repository.getDirectory()).execute(null);
// create first commit containing a dummy file
testRepository.createInitialCommit("testBranchOperation\n\nfirst commit\n");
prepareCacheEntry();
waitForListenerCalled();
final String fileName = "aFile";
// This call should trigger an indexDiffChanged event (triggered via
// resource changed event)
project.createFile(fileName, "content".getBytes("UTF-8"));
IndexDiffData indexDiffData = waitForListenerCalled();
String path = project.project.getFile(fileName).getFullPath().toString().substring(1);
if (!indexDiffData.getUntracked().contains(path))
fail("IndexDiffData did not contain aFile as untracked");
// This call should trigger an indexDiffChanged event
try (Git git = new Git(repository)) {
git.add().addFilepattern(path).call();
}
IndexDiffData indexDiffData2 = waitForListenerCalled();
if (indexDiffData2.getUntracked().contains(path))
fail("IndexDiffData contains aFile as untracked");
if (!indexDiffData2.getAdded().contains(path))
fail("IndexDiffData does not contain aFile as added");
}
use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.
the class IndexDiffCacheTest method testAddAndRemoveGitIgnoreFileToIgnoredDir.
@Test
public void testAddAndRemoveGitIgnoreFileToIgnoredDir() throws Exception {
testRepository.connect(project.project);
project.createFile(".gitignore", "ignore\n".getBytes("UTF-8"));
project.createFolder("sub");
project.createFile("sub/ignore", new byte[] {});
testRepository.addToIndex(project.project);
testRepository.createInitialCommit("testRemoveIgnoredFile\n\nfirst commit\n");
prepareCacheEntry();
IndexDiffData data1 = waitForListenerCalled();
assertThat(data1.getIgnoredNotInIndex(), hasItem("Project-1/sub/ignore"));
project.createFile("sub/ignored", "Ignored".getBytes("UTF-8"));
// adding this file will trigger a refresh, so no manual refresh must be
// required.
project.createFile("sub/.gitignore", "ignored\n".getBytes("UTF-8"));
IndexDiffData data2 = waitForListenerCalled();
assertThat(data2.getIgnoredNotInIndex(), hasItem("Project-1/sub/ignored"));
// removing must also trigger the listener
project.getProject().getFile("sub/.gitignore").delete(true, null);
IndexDiffData data3 = waitForListenerCalled();
assertThat(data3.getUntracked(), hasItem("Project-1/sub/ignored"));
}
use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.
the class IndexDiffCacheTest method testRemoveIgnoredFile.
@Test
public void testRemoveIgnoredFile() throws Exception {
testRepository.connect(project.project);
project.createFile(".gitignore", "ignore\n".getBytes("UTF-8"));
project.createFolder("sub");
IFile file = project.createFile("sub/ignore", new byte[] {});
testRepository.addToIndex(project.project);
testRepository.createInitialCommit("testRemoveIgnoredFile\n\nfirst commit\n");
IndexDiffCacheEntry entry = prepareCacheEntry();
IndexDiffData data1 = waitForListenerCalled();
assertThat(data1.getIgnoredNotInIndex(), hasItem("Project-1/sub/ignore"));
// Must not change anything (ignored path starts with this string, but
// it's not a prefix path of it)
project.createFile("sub/ignorenot", new byte[] {});
IndexDiffData data2 = waitForListenerCalled();
assertThat(data2.getIgnoredNotInIndex(), hasItem("Project-1/sub/ignore"));
file.delete(false, null);
waitForListenerNotCalled();
// need explicit as ignored file shall not trigger.
entry.refresh();
IndexDiffData data3 = waitForListenerCalled();
assertThat(data3.getIgnoredNotInIndex(), not(hasItem("Project-1/sub/ignore")));
}
use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.
the class IndexDiffCacheTest method testAddAndRemoveFileToIgnoredDir.
@Test
public void testAddAndRemoveFileToIgnoredDir() throws Exception {
testRepository.connect(project.project);
project.createFile(".gitignore", "sub\n".getBytes("UTF-8"));
project.createFolder("sub");
project.createFile("sub/ignore", new byte[] {});
testRepository.addToIndex(project.project);
testRepository.createInitialCommit("testRemoveIgnoredFile\n\nfirst commit\n");
prepareCacheEntry();
IndexDiffData data1 = waitForListenerCalled();
assertThat(data1.getIgnoredNotInIndex(), hasItem("Project-1/sub"));
// creating a file in an ignored directory will not trigger the listener
project.createFile("sub/ignored", "Ignored".getBytes("UTF-8"));
waitForListenerNotCalled();
// removing must also not trigger the listener
project.getProject().getFile("sub/ignored").delete(true, null);
waitForListenerNotCalled();
}
Aggregations