diff options
author | Matthaus Owens <matthaus@puppetlabs.com> | 2016-07-29 09:52:04 -0700 |
---|---|---|
committer | Christian Halstrick <christian.halstrick@sap.com> | 2016-08-04 13:04:17 +0100 |
commit | 0ee89f01be7174d61ac3ac6af9805936b18818e5 (patch) | |
tree | 1ecf083db5b7bfccab88b374e5726cac00e58d6a /org.eclipse.jgit.test/tst | |
parent | 23b1405484eb8dea10d1a6870b28e865d04d9f63 (diff) | |
download | jgit-0ee89f01be7174d61ac3ac6af9805936b18818e5.tar.gz jgit-0ee89f01be7174d61ac3ac6af9805936b18818e5.zip |
Add testCleanDirsWithSubmodule test to CleanCommandTest
This commit adds some test coverage to cleaning a repository with a
submodule, which did not previously exist.
Bug: 498367
Change-Id: Ia5c4e4cc53488800dd486f8556dc57656783f1c4
Signed-off-by: Matthaus Owens <matthaus@puppetlabs.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CleanCommandTest.java | 28 |
1 files changed, 28 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 7cca4b9e4b..7daa9957dc 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 @@ -45,6 +45,7 @@ package org.eclipse.jgit.api; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import static org.eclipse.jgit.lib.Constants.DOT_GIT_MODULES; import java.util.Set; import java.util.TreeSet; @@ -52,6 +53,7 @@ import java.util.TreeSet; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.errors.NoWorkTreeException; import org.eclipse.jgit.junit.RepositoryTestCase; +import org.eclipse.jgit.lib.Repository; import org.junit.Before; import org.junit.Test; @@ -227,4 +229,30 @@ public class CleanCommandTest extends RepositoryTestCase { assertTrue(cleanedFiles.contains("ignored-dir/")); } + @Test + public void testCleanDirsWithSubmodule() throws Exception { + SubmoduleAddCommand command = new SubmoduleAddCommand(db); + String path = "sub"; + command.setPath(path); + String uri = db.getDirectory().toURI().toString(); + command.setURI(uri); + Repository repo = command.call(); + repo.close(); + + Status beforeCleanStatus = git.status().call(); + assertTrue(beforeCleanStatus.getAdded().contains(DOT_GIT_MODULES)); + assertTrue(beforeCleanStatus.getAdded().contains(path)); + + Set<String> cleanedFiles = git.clean().setCleanDirectories(true).call(); + + // The submodule should not be cleaned. + assertTrue(!cleanedFiles.contains(path + "/")); + + 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); + } } |