]> source.dussan.org Git - jgit.git/commitdiff
Use absolute paths for file:// URIs in tests 89/17989/1
authorShawn Pearce <sop@google.com>
Fri, 1 Nov 2013 14:59:57 +0000 (15:59 +0100)
committerShawn Pearce <sop@google.com>
Sat, 2 Nov 2013 02:57:47 +0000 (19:57 -0700)
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

org.eclipse.jgit.ant.test/src/org/eclipse/jgit/ant/tasks/GitCloneTaskTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LsRemoteCommandTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java

index 7cd5b74516d32f13613f1e27fbb34af396d26e47..3ce0663762ce98e9f23fe68084ff681883f5dc33 100644 (file)
@@ -101,7 +101,7 @@ public class GitCloneTaskTest extends LocalDiskRepositoryTestCase {
        public void shouldCloneAValidGitRepository() throws Exception {
                Repository repo = createBareRepository();
                File directory = repo.getDirectory();
-               task.setUri("file://" + directory);
+               task.setUri("file://" + directory.getAbsolutePath());
                task.execute();
 
                assertTrue(RepositoryCache.FileKey.isGitRepository(new File(dest, ".git"), FS.DETECTED));
@@ -111,7 +111,7 @@ public class GitCloneTaskTest extends LocalDiskRepositoryTestCase {
        public void shouldCreateABareCloneOfAValidGitRepository() throws Exception {
                Repository repo = createBareRepository();
                File directory = repo.getDirectory();
-               task.setUri("file://" + directory);
+               task.setUri("file://" + directory.getAbsolutePath());
                task.setBare(true);
                task.execute();
 
index c2c8317d94675f81e27f12fdc89608b3fff45d40..91ced0a596f6cfac5dac97ac999b07da66a48aa0 100644 (file)
@@ -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();
index 31f909a5f2a77c3dcfc930f39a1bb5f7bf69c4a7..56c1201760453ccc5206aa618bebdbd93582442f 100644 (file)
@@ -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();
+       }
 }
index f31276dee4b9649e0873687141130184187aebf5..a853d6ab8fa9757434828c57450efb0f721c365f 100644 (file)
@@ -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();
+       }
+
 }
index 8d22a1b58a8fe49c435eb796324d91f53b0e6b89..c03ced563f9b617e2da3093f01546449c549454f 100644 (file)
@@ -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);
index 993e16f5e94df50e0e4350ae48dafd1c5ed0e94f..25534fdda6a5e5219d2604fa91c5d0f7aa80002d 100644 (file)
@@ -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);
index efdcfeb47201ec301f16d6a7f577b9bda705aac7..280d6040cc6844b36a117a1edcc652c63149c57d 100644 (file)
@@ -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();
 
index 2b9c1077782fad1762af9b0e6581e11691c1dc75..383ff5011c87c481075f1000e4ebdaceb9dada75 100644 (file)
@@ -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());
        }
 
index b9691836b664941ce0ae74e3b3ba632a25223c8b..28a3f4428e247bb88d1474c25fcd1bd6c754bcb6 100644 (file)
@@ -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 {