summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CleanCommandTest.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CleanCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CleanCommandTest.java
index 7daa9957dc..68f5dd1e0d 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CleanCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CleanCommandTest.java
@@ -47,6 +47,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.eclipse.jgit.lib.Constants.DOT_GIT_MODULES;
+import java.io.File;
import java.util.Set;
import java.util.TreeSet;
@@ -255,4 +256,43 @@ public class CleanCommandTest extends RepositoryTestCase {
assertTrue(cleanedFiles.contains("sub-clean/"));
assertTrue(cleanedFiles.size() == 4);
}
+
+ @Test
+ public void testCleanDirsWithRepository() throws Exception {
+ // Set up a repository inside the outer repository
+ String innerRepoName = "inner-repo";
+ File innerDir = new File(trash, innerRepoName);
+ innerDir.mkdir();
+ InitCommand initRepoCommand = new InitCommand();
+ initRepoCommand.setDirectory(innerDir);
+ initRepoCommand.call();
+
+ Status beforeCleanStatus = git.status().call();
+ Set<String> untrackedFolders = beforeCleanStatus.getUntrackedFolders();
+ Set<String> untrackedFiles = beforeCleanStatus.getUntracked();
+
+ // The inner repository should be listed as an untracked file
+ assertTrue(untrackedFiles.contains(innerRepoName));
+
+ // The inner repository should not be listed as an untracked folder
+ assertTrue(!untrackedFolders.contains(innerRepoName));
+
+ Set<String> cleanedFiles = git.clean().setCleanDirectories(true).call();
+
+ // The inner repository should not be cleaned.
+ assertTrue(!cleanedFiles.contains(innerRepoName + "/"));
+
+ assertTrue(cleanedFiles.contains("File2.txt"));
+ assertTrue(cleanedFiles.contains("File3.txt"));
+ assertTrue(!cleanedFiles.contains("sub-noclean/File1.txt"));
+ assertTrue(cleanedFiles.contains("sub-noclean/File2.txt"));
+ assertTrue(cleanedFiles.contains("sub-clean/"));
+ assertTrue(cleanedFiles.size() == 4);
+
+ Set<String> forceCleanedFiles = git.clean().setCleanDirectories(true)
+ .setForce(true).call();
+
+ // The inner repository should be cleaned this time
+ assertTrue(forceCleanedFiles.contains(innerRepoName + "/"));
+ }
}