Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.egit.core.test/src')
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitSubscriberResourceMappingContextTest.java100
1 files changed, 100 insertions, 0 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitSubscriberResourceMappingContextTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitSubscriberResourceMappingContextTest.java
index c8a5107d9..6e090f2b0 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitSubscriberResourceMappingContextTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitSubscriberResourceMappingContextTest.java
@@ -7,6 +7,7 @@
*******************************************************************************/
package org.eclipse.egit.core.synchronize;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -14,6 +15,7 @@ import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.UnsupportedEncodingException;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
@@ -292,6 +294,104 @@ public class GitSubscriberResourceMappingContextTest extends GitTestCase {
assertFalse(context.hasLocalChange(file, new NullProgressMonitor()));
}
+ @Test
+ public void hasDeletion() 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);
+ iFile1.delete(true, new NullProgressMonitor());
+ try (Git git = new Git(testRepo.getRepository())) {
+ git.add()
+ .addFilepattern(iProject.getName() + '/' + iFile1.getName())
+ .setUpdate(true)
+ .call();
+ }
+ testRepo.commit("Deleted file1.sample");
+
+ RemoteResourceMappingContext context = prepareContext(BRANCH, MASTER);
+ boolean hasFile1 = false;
+ for (IResource member : context.fetchMembers(iProject,
+ new NullProgressMonitor())) {
+ if (iFile1.getName().equals(member.getName())) {
+ hasFile1 = true;
+ break;
+ }
+ }
+ assertTrue(hasFile1);
+ assertFalse(context.hasRemoteChange(iFile1, new NullProgressMonitor()));
+ assertTrue(context.hasLocalChange(iFile1, new NullProgressMonitor()));
+ }
+
+ @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()));
+ assertTrue(
+ context.hasLocalChange(subfolder, new NullProgressMonitor()));
+ assertTrue(context.hasLocalChange(sub, new NullProgressMonitor()));
+ }
+
private RevCommit setContentsAndCommit(IFile targetFile,
String newContents, String commitMessage)
throws Exception {

Back to the top