use of org.eclipse.core.resources.mapping.RemoteResourceMappingContext in project egit by eclipse.
the class GitSubscriberResourceMappingContextTest method hasLocalChangeInNewFolder.
@Test
public void hasLocalChangeInNewFolder() throws Exception {
iProject.getFolder("folder").create(false, true, null);
RemoteResourceMappingContext context = prepareContext(MASTER, MASTER);
// Folder is now known, but not yet file in it
File file = testRepo.createFile(iProject, "folder/b.txt");
IFile iFile = testRepo.getIFile(iProject, file);
refresh(context, iFile);
assertTrue(context.hasLocalChange(iFile, new NullProgressMonitor()));
testRepo.addToIndex(iProject, file);
refresh(context, iFile);
assertTrue(context.hasLocalChange(iFile, new NullProgressMonitor()));
JGitTestUtil.write(file, "changed content b");
refresh(context, iFile);
assertTrue(context.hasLocalChange(iFile, new NullProgressMonitor()));
}
use of org.eclipse.core.resources.mapping.RemoteResourceMappingContext in project egit by eclipse.
the class GitSubscriberResourceMappingContextTest method hasLocalAndRemoteChange.
@Test
public void hasLocalAndRemoteChange() throws Exception {
File file1 = testRepo.createFile(iProject, "file1.sample");
testRepo.appendContentAndCommit(iProject, file1, "initial content", "first commit in master");
IFile iFile1 = testRepo.getIFile(iProject, file1);
testRepo.createAndCheckoutBranch(MASTER, BRANCH);
setContentsAndCommit(iFile1, "changed content in branch", "first commit in BRANCH");
testRepo.checkoutBranch(MASTER);
setContentsAndCommit(iFile1, "changed content in master", "second commit in MASTER");
RemoteResourceMappingContext context = prepareContext(MASTER, BRANCH);
assertTrue(context.hasRemoteChange(iFile1, new NullProgressMonitor()));
assertTrue(context.hasLocalChange(iFile1, new NullProgressMonitor()));
}
use of org.eclipse.core.resources.mapping.RemoteResourceMappingContext in project egit by eclipse.
the class GitSubscriberResourceMappingContextTest method hasLocalChange.
@Test
public void hasLocalChange() throws Exception {
File file1 = testRepo.createFile(iProject, "a.txt");
File file2 = testRepo.createFile(iProject, "b.txt");
testRepo.appendContentAndCommit(iProject, file1, "content a", "commit a");
testRepo.appendContentAndCommit(iProject, file2, "content b", "commit b");
IFile iFile1 = testRepo.getIFile(iProject, file1);
IFile iFile2 = testRepo.getIFile(iProject, file2);
RemoteResourceMappingContext context = prepareContext(MASTER, MASTER);
assertFalse(context.hasLocalChange(iFile1, new NullProgressMonitor()));
assertFalse(context.hasLocalChange(iFile2, new NullProgressMonitor()));
JGitTestUtil.write(file1, "changed content a");
JGitTestUtil.write(file2, "changed content b");
refresh(context, iFile1, iFile2);
assertTrue(context.hasLocalChange(iFile1, new NullProgressMonitor()));
assertTrue(context.hasLocalChange(iFile2, new NullProgressMonitor()));
JGitTestUtil.write(file2, "content b");
refresh(context, iFile2);
assertTrue(context.hasLocalChange(iFile1, new NullProgressMonitor()));
assertFalse(context.hasLocalChange(iFile2, new NullProgressMonitor()));
}
use of org.eclipse.core.resources.mapping.RemoteResourceMappingContext in project egit by eclipse.
the class GitSubscriberResourceMappingContextTest method hasRemoteChangeInNewFile.
@Test
public void hasRemoteChangeInNewFile() throws Exception {
File file1 = testRepo.createFile(iProject, "file1.sample");
String initialContent1 = "some content for the first file";
testRepo.appendContentAndCommit(iProject, file1, initialContent1, "first file - initial commit");
IFile iFile1 = testRepo.getIFile(iProject, file1);
testRepo.createAndCheckoutBranch(MASTER, BRANCH);
File file2 = testRepo.createFile(iProject, "file2.sample");
String initialContent2 = "some content for the second file";
testRepo.appendContentAndCommit(iProject, file2, initialContent2, "second file - initial commit");
IFile iFile2 = testRepo.getIFile(iProject, file2);
testRepo.checkoutBranch(MASTER);
RemoteResourceMappingContext context = prepareContext(MASTER, BRANCH);
assertFalse(context.hasRemoteChange(iFile1, new NullProgressMonitor()));
assertTrue(context.hasRemoteChange(iFile2, new NullProgressMonitor()));
}
use of org.eclipse.core.resources.mapping.RemoteResourceMappingContext in project egit by eclipse.
the class GitSubscriberResourceMappingContextTest method hasNestedDeletion.
@Test
public void hasNestedDeletion() throws Exception {
File file1 = testRepo.createFile(iProject, "sub/subfolder/file1.sample");
testRepo.appendContentAndCommit(iProject, file1, "initial content", "first commit in master");
IFile iFile1 = testRepo.getIFile(iProject, file1);
assertTrue(iFile1.exists());
IContainer subfolder = iFile1.getParent();
assertTrue(subfolder instanceof IFolder);
assertEquals("subfolder", subfolder.getName());
IContainer sub = subfolder.getParent();
assertTrue(sub instanceof IFolder);
assertEquals("sub", sub.getName());
testRepo.createAndCheckoutBranch(MASTER, BRANCH);
iFile1.delete(true, new NullProgressMonitor());
subfolder.delete(true, new NullProgressMonitor());
sub.delete(true, new NullProgressMonitor());
try (Git git = new Git(testRepo.getRepository())) {
git.add().addFilepattern(iProject.getName() + "/sub/subfolder/file1.sample").setUpdate(true).call();
}
testRepo.commit("Deleted sub/subfolder/file1.sample");
assertFalse(iFile1.exists());
assertFalse(subfolder.exists());
assertFalse(sub.exists());
RemoteResourceMappingContext context = prepareContext(BRANCH, MASTER);
boolean hasFile1 = false;
for (IResource member : context.fetchMembers(iProject, new NullProgressMonitor())) {
if (sub.getName().equals(member.getName())) {
for (IResource child : context.fetchMembers(sub, new NullProgressMonitor())) {
if (subfolder.getName().equals(child.getName())) {
for (IResource grandchild : context.fetchMembers(subfolder, new NullProgressMonitor())) {
if (iFile1.getName().equals(grandchild.getName())) {
hasFile1 = true;
break;
}
}
break;
}
}
break;
}
}
assertTrue(hasFile1);
assertFalse(context.hasRemoteChange(iFile1, new NullProgressMonitor()));
assertTrue(context.hasLocalChange(iFile1, new NullProgressMonitor()));
assertFalse(context.hasLocalChange(subfolder, new NullProgressMonitor()));
assertFalse(context.hasLocalChange(sub, new NullProgressMonitor()));
}
Aggregations