diff options
author | Christian Halstrick <christian.halstrick@sap.com> | 2016-08-07 09:37:47 -0400 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org <gerrit@eclipse.org> | 2016-08-07 09:37:48 -0400 |
commit | 2c5c035e62d98a8f526f6e3a19dd1494754a6a0b (patch) | |
tree | 4f4a9bda7199b9abe7629225e700f5eb372ab2c0 /org.eclipse.jgit.test | |
parent | cb3bd8ea84054c8bd51b2b4b0c27ef25f6069fce (diff) | |
parent | e1ffab1cac55179011777b9a60bac447b0a62ccf (diff) | |
download | jgit-2c5c035e62d98a8f526f6e3a19dd1494754a6a0b.tar.gz jgit-2c5c035e62d98a8f526f6e3a19dd1494754a6a0b.zip |
Merge "Skip cleaning inner repositories by default in CleanCommand"
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CleanCommandTest.java | 40 |
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 + "/")); + } } |