aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorStefan Lay <stefan.lay@sap.com>2011-04-06 14:08:25 +0200
committerStefan Lay <stefan.lay@sap.com>2011-04-06 15:00:22 +0200
commitfbf35fea4ec254339f9b0eee7865eb6ccfe22700 (patch)
treeb9c1ef896e2058a66cb4f8bb9f17dda5b7679df5 /org.eclipse.jgit.test
parent792b93bc62bb3714eb04ccf6e0c800d3b5b85f5b (diff)
downloadjgit-fbf35fea4ec254339f9b0eee7865eb6ccfe22700.tar.gz
jgit-fbf35fea4ec254339f9b0eee7865eb6ccfe22700.zip
Add parameters for timeout and branches to clone
The timeout is also used in the FetchCommand called by the CloneCommand. The possibility to provide a list of branches to fetch initially is a feature offered by EGit. To implement it here is a prerequisite for EGit to be able to use the CloneCommand. Change-Id: I21453de22e9ca61919a7c3386fcc526024742f5f Signed-off-by: Stefan Lay <stefan.lay@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java
index f2ad9e5f11..f21dc4a0be 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java
@@ -48,7 +48,9 @@ import static org.junit.Assert.fail;
import java.io.File;
import java.io.IOException;
+import java.util.Collections;
+import org.eclipse.jgit.api.ListBranchCommand.ListMode;
import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Constants;
@@ -114,6 +116,8 @@ public class CloneCommandTest extends RepositoryTestCase {
.getConfig()
.getString(ConfigConstants.CONFIG_BRANCH_SECTION,
"test", ConfigConstants.CONFIG_KEY_MERGE));
+ assertEquals(2, git2.branchList().setListMode(ListMode.REMOTE)
+ .call().size());
} catch (Exception e) {
fail(e.getMessage());
}
@@ -137,6 +141,28 @@ public class CloneCommandTest extends RepositoryTestCase {
}
}
+ @Test
+ public void testCloneRepositoryOnlyOneBranch() {
+ try {
+ File directory = createTempDirectory("testCloneRepositoryWithBranch");
+ CloneCommand command = Git.cloneRepository();
+ command.setBranch("refs/heads/master");
+ command.setBranchesToClone(Collections
+ .singletonList("refs/heads/master"));
+ command.setDirectory(directory);
+ command.setURI("file://"
+ + git.getRepository().getWorkTree().getPath());
+ Git git2 = command.call();
+ assertNotNull(git2);
+ assertEquals(git2.getRepository().getFullBranch(),
+ "refs/heads/master");
+ assertEquals(1, git2.branchList().setListMode(ListMode.REMOTE)
+ .call().size());
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
public static File createTempDirectory(String name) throws IOException {
final File temp;
temp = File.createTempFile(name, Long.toString(System.nanoTime()));