File directory = createTempDirectory("testCloneRepository");
CloneCommand command = Git.cloneRepository();
command.setDirectory(directory);
- command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+ command.setURI(fileUri());
Git git2 = command.call();
addRepoToClose(git2.getRepository());
assertNotNull(git2);
CloneCommand command = Git.cloneRepository();
command.setBare(true);
command.setDirectory(directory);
- command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+ command.setURI(fileUri());
Git git2 = command.call();
addRepoToClose(git2.getRepository());
assertEquals(new RefSpec("+refs/heads/*:refs/heads/*"),
CloneCommand command = Git.cloneRepository();
command.setBranch("refs/heads/master");
command.setDirectory(directory);
- command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+ command.setURI(fileUri());
Git git2 = command.call();
addRepoToClose(git2.getRepository());
command = Git.cloneRepository();
command.setBranch("refs/heads/master");
command.setDirectory(directory);
- command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+ command.setURI(fileUri());
command.setNoCheckout(true);
git2 = command.call();
addRepoToClose(git2.getRepository());
command = Git.cloneRepository();
command.setBranch("refs/heads/master");
command.setDirectory(directory);
- command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+ command.setURI(fileUri());
command.setBare(true);
git2 = command.call();
addRepoToClose(git2.getRepository());
CloneCommand command = Git.cloneRepository();
command.setBranch("test");
command.setDirectory(directory);
- command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+ command.setURI(fileUri());
Git git2 = command.call();
addRepoToClose(git2.getRepository());
CloneCommand command = Git.cloneRepository();
command.setBranch("tag-initial");
command.setDirectory(directory);
- command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+ command.setURI(fileUri());
Git git2 = command.call();
addRepoToClose(git2.getRepository());
command.setBranchesToClone(Collections
.singletonList("refs/heads/master"));
command.setDirectory(directory);
- command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+ command.setURI(fileUri());
Git git2 = command.call();
addRepoToClose(git2.getRepository());
assertNotNull(git2);
command.setBranchesToClone(Collections
.singletonList("refs/heads/master"));
command.setDirectory(directory);
- command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+ command.setURI(fileUri());
command.setBare(true);
git2 = command.call();
addRepoToClose(git2.getRepository());
File directory = createTempDirectory(dirName);
CloneCommand command = Git.cloneRepository();
command.setDirectory(directory);
- command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+ command.setURI(fileUri());
Git git2 = command.call();
addRepoToClose(git2.getRepository());
assertNotNull(git2);
// clone again
command = Git.cloneRepository();
command.setDirectory(directory);
- command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+ command.setURI(fileUri());
try {
git2 = command.call();
// we shouldn't get here
File directory = createTempDirectory("testCloneRepositoryWithMultipleHeadBranches");
CloneCommand clone = Git.cloneRepository();
clone.setDirectory(directory);
- clone.setURI("file://" + git.getRepository().getWorkTree().getPath());
+ clone.setURI(fileUri());
Git git2 = clone.call();
addRepoToClose(git2.getRepository());
assertNotNull(git2);
CloneCommand clone = Git.cloneRepository();
clone.setDirectory(directory);
clone.setCloneSubmodules(true);
- clone.setURI("file://" + git.getRepository().getWorkTree().getPath());
+ clone.setURI(fileUri());
Git git2 = clone.call();
addRepoToClose(git2.getRepository());
assertNotNull(git2);
File directory = createTempDirectory("testCloneRepository1");
CloneCommand command = Git.cloneRepository();
command.setDirectory(directory);
- command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+ command.setURI(fileUri());
Git git2 = command.call();
addRepoToClose(git2.getRepository());
assertFalse(git2
directory = createTempDirectory("testCloneRepository2");
command = Git.cloneRepository();
command.setDirectory(directory);
- command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+ command.setURI(fileUri());
git2 = command.call();
addRepoToClose(git2.getRepository());
assertTrue(git2
directory = createTempDirectory("testCloneRepository2");
command = Git.cloneRepository();
command.setDirectory(directory);
- command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+ command.setURI(fileUri());
git2 = command.call();
addRepoToClose(git2.getRepository());
assertTrue(git2
ConfigConstants.CONFIG_KEY_REBASE, false));
}
+
+ private String fileUri() {
+ return "file://" + git.getRepository().getWorkTree().getAbsolutePath();
+ }
}
File directory = createTempDirectory("testRepository");
CloneCommand command = Git.cloneRepository();
command.setDirectory(directory);
- command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+ command.setURI(fileUri());
command.setCloneAllBranches(true);
Git git2 = command.call();
addRepoToClose(git2.getRepository());
File directory = createTempDirectory("testRepository");
CloneCommand command = Git.cloneRepository();
command.setDirectory(directory);
- command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+ command.setURI(fileUri());
command.setCloneAllBranches(true);
Git git2 = command.call();
addRepoToClose(git2.getRepository());
File directory = createTempDirectory("testRepository");
CloneCommand command = Git.cloneRepository();
command.setDirectory(directory);
- command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+ command.setURI(fileUri());
command.setCloneAllBranches(true);
Git git2 = command.call();
addRepoToClose(git2.getRepository());
@Test
public void testLsRemoteWithoutLocalRepository() throws Exception {
- String uri = "file://" + git.getRepository().getWorkTree().getPath();
+ String uri = fileUri();
Collection<Ref> refs = Git.lsRemoteRepository().setRemote(uri).setHeads(true).call();
assertNotNull(refs);
assertEquals(2, refs.size());
}
+ private String fileUri() {
+ return "file://" + git.getRepository().getWorkTree().getAbsolutePath();
+ }
+
}