use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.
the class IndexDiffCacheTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
testRepository = new TestRepository(gitDir);
repository = testRepository.getRepository();
listenerCalled = new AtomicBoolean(false);
indexDiffDataResult = new AtomicReference<>(null);
indexDiffListener = new IndexDiffChangedListener() {
@Override
public void indexDiffChanged(Repository repo, IndexDiffData indexDiffData) {
listenerCalled.set(true);
indexDiffDataResult.set(indexDiffData);
}
};
}
use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.
the class IndexDiffCacheTest method testAddIgnoredFolder.
@Test
public void testAddIgnoredFolder() throws Exception {
testRepository.connect(project.project);
project.createFile(".gitignore", "ignore\n".getBytes("UTF-8"));
project.createFolder("ignore");
project.createFile("ignore/file.txt", new byte[] {});
project.createFolder("sub");
testRepository.addToIndex(project.project);
testRepository.createInitialCommit("testAddFileInIgnoredFolder\n\nfirst commit\n");
prepareCacheEntry();
IndexDiffData data1 = waitForListenerCalled();
assertThat(data1.getIgnoredNotInIndex(), hasItem("Project-1/ignore"));
project.createFolder("sub/ignore");
IndexDiffData data2 = waitForListenerCalled();
assertThat(data2.getIgnoredNotInIndex(), hasItem("Project-1/ignore"));
assertThat(data2.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 data3 = waitForListenerCalled();
assertThat(data3.getUntracked(), hasItem("Project-1/sub/ignorenot"));
assertThat(data3.getIgnoredNotInIndex(), hasItem("Project-1/ignore"));
assertThat(data3.getIgnoredNotInIndex(), hasItem("Project-1/sub/ignore"));
}
use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.
the class LabelEventJob method decorateResource.
/**
* Decorates a single resource (i.e. a project).
*
* @param resource the resource to decorate
* @param decoration the decoration
* @throws CoreException
*/
private void decorateResource(@NonNull IResource resource, IDecoration decoration) throws CoreException {
if (resource.getType() == IResource.ROOT || !resource.isAccessible()) {
return;
}
IndexDiffData indexDiffData = ResourceStateFactory.getInstance().getIndexDiffDataOrNull(resource);
if (indexDiffData == null) {
return;
}
IDecoratableResource decoratableResource = null;
try {
decoratableResource = new DecoratableResourceAdapter(indexDiffData, resource);
} catch (IOException e) {
throw new CoreException(Activator.createErrorStatus(NLS.bind(UIText.Decorator_exceptionMessage, resource), e));
}
helper.decorate(decoration, decoratableResource);
}
use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.
the class DecoratableResourceAdapterTest method testDecorationModifiedFile.
@Test
public void testDecorationModifiedFile() 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("First commit").call();
// Change file content
write(f, "SomethingElse");
IDecoratableResource[] expectedDRs = new IDecoratableResource[] { new TestDecoratableResource(project).tracked().dirty(), new TestDecoratableResource(file).tracked().dirty() };
waitForIndexDiffUpdate(true);
IndexDiffData indexDiffData = indexDiffCacheEntry.getIndexDiff();
IDecoratableResource[] actualDRs = { new DecoratableResourceAdapter(indexDiffData, project), new DecoratableResourceAdapter(indexDiffData, file) };
assertArrayEquals(expectedDRs, actualDRs);
assertHasUnstagedChanges(true, actualDRs);
}
use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.
the class DecoratableResourceAdapterTest method testDecorationNewFileInOneSubfolder.
@Test
public void testDecorationNewFileInOneSubfolder() throws Exception {
IFolder folder = project.getFolder(TEST_FOLDER);
folder.create(true, true, null);
IFolder subFolder = folder.getFolder(SUB_FOLDER);
subFolder.create(true, true, null);
IFolder subFolder2 = folder.getFolder(SUB_FOLDER2);
subFolder2.create(true, true, null);
write(new File(subFolder2.getLocation().toFile().getAbsolutePath(), TEST_FILE), "Something");
project.refreshLocal(IResource.DEPTH_INFINITE, null);
IResource file = subFolder2.findMember(TEST_FILE);
IDecoratableResource[] expectedDRs = new IDecoratableResource[] { new TestDecoratableResource(project).tracked().dirty(), new TestDecoratableResource(folder).dirty(), new TestDecoratableResource(subFolder).ignored(), new TestDecoratableResource(subFolder2).dirty(), new TestDecoratableResource(file) };
waitForIndexDiffUpdate(true);
IndexDiffData indexDiffData = indexDiffCacheEntry.getIndexDiff();
IDecoratableResource[] actualDRs = { new DecoratableResourceAdapter(indexDiffData, project), new DecoratableResourceAdapter(indexDiffData, folder), new DecoratableResourceAdapter(indexDiffData, subFolder), new DecoratableResourceAdapter(indexDiffData, subFolder2), new DecoratableResourceAdapter(indexDiffData, file) };
assertArrayEquals(expectedDRs, actualDRs);
}
Aggregations