diff options
author | Shawn Pearce <sop@google.com> | 2013-11-01 15:59:57 +0100 |
---|---|---|
committer | Shawn Pearce <sop@google.com> | 2013-11-01 19:57:47 -0700 |
commit | 75cfa03e163f72e8707e7f9126f17fbacb025b99 (patch) | |
tree | 243fc56c5e6728edab1f6a5afff26cbaa5ae9cda /org.eclipse.jgit.test/tst | |
parent | 69c1244989e3524c85bc980940c7e6670bc76e11 (diff) | |
download | jgit-75cfa03e163f72e8707e7f9126f17fbacb025b99.tar.gz jgit-75cfa03e163f72e8707e7f9126f17fbacb025b99.zip |
Use absolute paths for file:// URIs in tests
When run under Buck the repository paths may be relative. Request
an absolute path to construct the URI, as relative paths are not
supported in file:// style URIs.
Change-Id: I85470d1db2f4e80cba30f1559c0d99bdfa8ac410
Diffstat (limited to 'org.eclipse.jgit.test/tst')
8 files changed, 42 insertions, 29 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java index c2c8317d94..91ced0a596 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java @@ -121,7 +121,7 @@ public class BranchCommandTest extends RepositoryTestCase { Git localGit = new Git(localRepository); StoredConfig config = localRepository.getConfig(); RemoteConfig rc = new RemoteConfig(config, "origin"); - rc.addURI(new URIish(remoteRepository.getDirectory().getPath())); + rc.addURI(new URIish(remoteRepository.getDirectory().getAbsolutePath())); rc.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*")); rc.update(config); config.save(); 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 31f909a5f2..56c1201760 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 @@ -110,7 +110,7 @@ public class CloneCommandTest extends RepositoryTestCase { 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); @@ -142,7 +142,7 @@ public class CloneCommandTest extends RepositoryTestCase { 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/*"), @@ -162,7 +162,7 @@ public class CloneCommandTest extends RepositoryTestCase { 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()); @@ -177,7 +177,7 @@ public class CloneCommandTest extends RepositoryTestCase { 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()); @@ -192,7 +192,7 @@ public class CloneCommandTest extends RepositoryTestCase { 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()); @@ -209,7 +209,7 @@ public class CloneCommandTest extends RepositoryTestCase { 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()); @@ -223,7 +223,7 @@ public class CloneCommandTest extends RepositoryTestCase { 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()); @@ -242,7 +242,7 @@ public class CloneCommandTest extends RepositoryTestCase { 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); @@ -257,7 +257,7 @@ public class CloneCommandTest extends RepositoryTestCase { 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()); @@ -284,14 +284,14 @@ public class CloneCommandTest extends RepositoryTestCase { 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 @@ -310,7 +310,7 @@ public class CloneCommandTest extends RepositoryTestCase { 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); @@ -343,7 +343,7 @@ public class CloneCommandTest extends RepositoryTestCase { 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); @@ -458,7 +458,7 @@ public class CloneCommandTest extends RepositoryTestCase { 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 @@ -476,7 +476,7 @@ public class CloneCommandTest extends RepositoryTestCase { 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 @@ -492,7 +492,7 @@ public class CloneCommandTest extends RepositoryTestCase { 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 @@ -502,4 +502,8 @@ public class CloneCommandTest extends RepositoryTestCase { ConfigConstants.CONFIG_KEY_REBASE, false)); } + + private String fileUri() { + return "file://" + git.getRepository().getWorkTree().getAbsolutePath(); + } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LsRemoteCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LsRemoteCommandTest.java index f31276dee4..a853d6ab8f 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LsRemoteCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LsRemoteCommandTest.java @@ -82,7 +82,7 @@ public class LsRemoteCommandTest extends RepositoryTestCase { 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()); @@ -99,7 +99,7 @@ public class LsRemoteCommandTest extends RepositoryTestCase { 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()); @@ -116,7 +116,7 @@ public class LsRemoteCommandTest extends RepositoryTestCase { 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()); @@ -130,10 +130,14 @@ public class LsRemoteCommandTest extends RepositoryTestCase { @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(); + } + } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java index 8d22a1b58a..c03ced563f 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java @@ -139,7 +139,8 @@ public class PullCommandTest extends RepositoryTestCase { assertEquals(sourceCommit.getId(), mergedCommits[1]); RevCommit mergeCommit = new RevWalk(dbTarget).parseCommit(mergeResult .getNewHead()); - String message = "Merge branch 'master' of " + db.getWorkTree(); + String message = "Merge branch 'master' of " + + db.getWorkTree().getAbsolutePath(); assertEquals(message, mergeCommit.getShortMessage()); } @@ -255,7 +256,7 @@ public class PullCommandTest extends RepositoryTestCase { config .addURI(new URIish(source.getRepository().getWorkTree() - .getPath())); + .getAbsolutePath())); config.addFetchRefSpec(new RefSpec( "+refs/heads/*:refs/remotes/origin/*")); config.update(targetConfig); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java index 993e16f5e9..25534fdda6 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java @@ -319,7 +319,7 @@ public class PullCommandWithRebaseTest extends RepositoryTestCase { config .addURI(new URIish(source.getRepository().getWorkTree() - .getPath())); + .getAbsolutePath())); config.addFetchRefSpec(new RefSpec( "+refs/heads/*:refs/remotes/origin/*")); config.update(targetConfig); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java index efdcfeb472..280d6040cc 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java @@ -129,7 +129,8 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase { builder.setMustExist(true); Repository repo2 = builder.build(); - assertEquals(repo1.getDirectory(), repo2.getDirectory()); + assertEquals(repo1.getDirectory().getAbsolutePath(), repo2 + .getDirectory().getAbsolutePath()); assertEquals(dir, repo2.getWorkTree()); } @@ -167,7 +168,8 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase { builder.setWorkTree(dir); builder.findGitDir(dir); - assertEquals(repo1.getDirectory(), builder.getGitDir()); + assertEquals(repo1.getDirectory().getAbsolutePath(), builder + .getGitDir().getAbsolutePath()); builder.setMustExist(true); Repository repo2 = builder.build(); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java index 2b9c107778..383ff5011c 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java @@ -171,8 +171,10 @@ public class SubmoduleWalkTest extends RepositoryTestCase { Repository subRepo = gen.getRepository(); addRepoToClose(subRepo); assertNotNull(subRepo); - assertEquals(modulesGitDir, subRepo.getDirectory()); - assertEquals(new File(db.getWorkTree(), path), subRepo.getWorkTree()); + assertEquals(modulesGitDir.getAbsolutePath(), + subRepo.getDirectory().getAbsolutePath()); + assertEquals(new File(db.getWorkTree(), path).getAbsolutePath(), + subRepo.getWorkTree().getAbsolutePath()); assertFalse(gen.next()); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java index b9691836b6..28a3f4428e 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java @@ -231,7 +231,7 @@ public class TransportTest extends SampleDataRepositoryTestCase { @Test public void testLocalTransportFetchWithoutLocalRepository() throws Exception { - URIish uri = new URIish("file://" + db.getWorkTree().getPath()); + URIish uri = new URIish("file://" + db.getWorkTree().getAbsolutePath()); transport = Transport.open(uri); FetchConnection fetchConnection = transport.openFetch(); try { |