]> source.dussan.org Git - jgit.git/commitdiff
Don't use internal type FileRepository in public API 24/11324/3
authorMatthias Sohn <matthias.sohn@sap.com>
Tue, 19 Mar 2013 22:23:59 +0000 (23:23 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Tue, 19 Mar 2013 23:44:24 +0000 (00:44 +0100)
Change-Id: I7c9c09b4f190fa7cb830563bcdf2071407ee2ce0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/JGitTestUtil.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RepositorySetupWorkDirTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java
org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileRepositoryBuilder.java

index a20e21cb04720330effc7864ef9393082812250a..c6fe4e4d91466b1b09dd650f592f47d5b8009771 100644 (file)
@@ -54,7 +54,7 @@ import java.lang.reflect.Method;
 import java.net.URISyntaxException;
 import java.net.URL;
 
-import org.eclipse.jgit.internal.storage.file.FileRepository;
+import org.eclipse.jgit.lib.Repository;
 import org.eclipse.jgit.util.FileUtils;
 import org.eclipse.jgit.util.IO;
 import org.eclipse.jgit.util.RawParseUtils;
@@ -135,14 +135,14 @@ public abstract class JGitTestUtil {
                return JGitTestUtil.class.getClassLoader();
        }
 
-       public static File writeTrashFile(final FileRepository db,
+       public static File writeTrashFile(final Repository db,
                        final String name, final String data) throws IOException {
                File path = new File(db.getWorkTree(), name);
                write(path, data);
                return path;
        }
 
-       public static File writeTrashFile(final FileRepository db,
+       public static File writeTrashFile(final Repository db,
                        final String subdir,
                        final String name, final String data) throws IOException {
                File path = new File(db.getWorkTree() + "/" + subdir, name);
@@ -190,13 +190,13 @@ public abstract class JGitTestUtil {
                return new String(body, 0, body.length, "UTF-8");
        }
 
-       public static String read(final FileRepository db, final String name)
+       public static String read(final Repository db, final String name)
                        throws IOException {
                File file = new File(db.getWorkTree(), name);
                return read(file);
        }
 
-       public static void deleteTrashFile(final FileRepository db,
+       public static void deleteTrashFile(final Repository db,
                        final String name) throws IOException {
                File path = new File(db.getWorkTree(), name);
                FileUtils.delete(path);
index 2c811671d88db29d4b700fa46d3f582d5dc4833a..46c4af3973867ec1a46e116c8f8e49feca72560d 100644 (file)
@@ -55,6 +55,7 @@ import java.io.IOException;
 import org.eclipse.jgit.junit.LocalDiskRepositoryTestCase;
 import org.eclipse.jgit.lib.ConfigConstants;
 import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.Repository;
 import org.eclipse.jgit.storage.file.FileBasedConfig;
 import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
 import org.eclipse.jgit.util.FileUtils;
@@ -126,7 +127,7 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase {
 
                builder.setWorkTree(dir);
                builder.setMustExist(true);
-               FileRepository repo2 = builder.build();
+               Repository repo2 = builder.build();
 
                assertEquals(repo1.getDirectory(), repo2.getDirectory());
                assertEquals(dir, repo2.getWorkTree());
@@ -145,7 +146,7 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase {
                FileRepositoryBuilder builder = new FileRepositoryBuilder();
                builder.setWorkTree(dir);
                builder.setMustExist(true);
-               FileRepository repo2 = builder.build();
+               Repository repo2 = builder.build();
 
                assertEquals(repo1.getDirectory(), repo2.getDirectory());
                assertEquals(dir, repo2.getWorkTree());
@@ -165,7 +166,7 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase {
                builder.findGitDir(dir);
                assertEquals(repo1.getDirectory(), builder.getGitDir());
                builder.setMustExist(true);
-               FileRepository repo2 = builder.build();
+               Repository repo2 = builder.build();
 
                assertEquals(repo1.getDirectory(), repo2.getDirectory());
                assertEquals(dir, repo2.getWorkTree());
index 20896001caee8269004556a8dab8e39e2b052f55..bc47782ea01099eaf8a23c7771b174169a012364 100644 (file)
@@ -97,7 +97,8 @@ public class RepositorySetupWorkDirTest extends LocalDiskRepositoryTestCase {
        @Test
        public void testNotBare_CreateRepositoryFromWorkDirOnly() throws Exception {
                File workdir = getFile("workdir", "repo");
-               FileRepository repo = new FileRepositoryBuilder().setWorkTree(workdir).build();
+               Repository repo = new FileRepositoryBuilder().setWorkTree(workdir)
+                               .build();
                assertFalse(repo.isBare());
                assertWorkdirPath(repo, "workdir", "repo");
                assertGitdirPath(repo, "workdir", "repo", Constants.DOT_GIT);
@@ -107,7 +108,8 @@ public class RepositorySetupWorkDirTest extends LocalDiskRepositoryTestCase {
        public void testWorkdirIsDotGit_CreateRepositoryFromWorkDirOnly()
                        throws Exception {
                File workdir = getFile("workdir", "repo");
-               FileRepository repo = new FileRepositoryBuilder().setWorkTree(workdir).build();
+               Repository repo = new FileRepositoryBuilder().setWorkTree(workdir)
+                               .build();
                assertGitdirPath(repo, "workdir", "repo", Constants.DOT_GIT);
        }
 
@@ -117,7 +119,7 @@ public class RepositorySetupWorkDirTest extends LocalDiskRepositoryTestCase {
                File gitDir = getFile("workdir", "repoWithConfig");
                File workTree = getFile("workdir", "treeRoot");
                setWorkTree(gitDir, workTree);
-               FileRepository repo = new FileRepositoryBuilder().setGitDir(gitDir).build();
+               Repository repo = new FileRepositoryBuilder().setGitDir(gitDir).build();
                assertFalse(repo.isBare());
                assertWorkdirPath(repo, "workdir", "treeRoot");
                assertGitdirPath(repo, "workdir", "repoWithConfig");
@@ -128,7 +130,7 @@ public class RepositorySetupWorkDirTest extends LocalDiskRepositoryTestCase {
                        throws Exception {
                File gitDir = getFile("workdir", "repoWithConfig");
                setBare(gitDir, true);
-               FileRepository repo = new FileRepositoryBuilder().setGitDir(gitDir).build();
+               Repository repo = new FileRepositoryBuilder().setGitDir(gitDir).build();
                assertTrue(repo.isBare());
        }
 
@@ -137,7 +139,7 @@ public class RepositorySetupWorkDirTest extends LocalDiskRepositoryTestCase {
                        throws Exception {
                File gitDir = getFile("workdir", "repoWithBareConfigTrue", "child");
                setBare(gitDir, false);
-               FileRepository repo = new FileRepositoryBuilder().setGitDir(gitDir).build();
+               Repository repo = new FileRepositoryBuilder().setGitDir(gitDir).build();
                assertWorkdirPath(repo, "workdir", "repoWithBareConfigTrue");
        }
 
@@ -146,7 +148,7 @@ public class RepositorySetupWorkDirTest extends LocalDiskRepositoryTestCase {
                        throws Exception {
                File gitDir = getFile("workdir", "repoWithBareConfigFalse", "child");
                setBare(gitDir, false);
-               FileRepository repo = new FileRepositoryBuilder().setGitDir(gitDir).build();
+               Repository repo = new FileRepositoryBuilder().setGitDir(gitDir).build();
                assertFalse(repo.isBare());
                assertWorkdirPath(repo, "workdir", "repoWithBareConfigFalse");
                assertGitdirPath(repo, "workdir", "repoWithBareConfigFalse", "child");
index a4de35ee97eac80fb47bd2e01603536d2f835395..921ec29d5355d792f646f43ab984a52c40877002 100644 (file)
@@ -140,8 +140,8 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase {
                repo1initial.close();
 
                File theDir = new File(repo1Parent, Constants.DOT_GIT);
-               FileRepository r = new FileRepositoryBuilder().setGitDir(theDir)
-                               .build();
+               FileRepository r = (FileRepository) new FileRepositoryBuilder()
+                               .setGitDir(theDir).build();
                assertEqualsPath(theDir, r.getDirectory());
                assertEqualsPath(repo1Parent, r.getWorkTree());
                assertEqualsPath(new File(theDir, "index"), r.getIndexFile());
@@ -165,8 +165,9 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase {
                repo1initial.close();
 
                File theDir = new File(repo1Parent, Constants.DOT_GIT);
-               FileRepository r = new FileRepositoryBuilder().setGitDir(theDir)
-                               .setWorkTree(repo1Parent.getParentFile()).build();
+               FileRepository r = (FileRepository) new FileRepositoryBuilder()
+                               .setGitDir(theDir).setWorkTree(repo1Parent.getParentFile())
+                               .build();
                assertEqualsPath(theDir, r.getDirectory());
                assertEqualsPath(repo1Parent.getParentFile(), r.getWorkTree());
                assertEqualsPath(new File(theDir, "index"), r.getIndexFile());
@@ -189,8 +190,8 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase {
                repo1initial.close();
 
                File theDir = new File(repo1Parent, Constants.DOT_GIT);
-               FileRepository r = new FileRepositoryBuilder().setWorkTree(repo1Parent)
-                               .build();
+               FileRepository r = (FileRepository) new FileRepositoryBuilder()
+                               .setWorkTree(repo1Parent).build();
                assertEqualsPath(theDir, r.getDirectory());
                assertEqualsPath(repo1Parent, r.getWorkTree());
                assertEqualsPath(new File(theDir, "index"), r.getIndexFile());
@@ -218,8 +219,8 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase {
                repo1initial.close();
 
                File theDir = new File(repo1Parent, Constants.DOT_GIT);
-               FileRepository r = new FileRepositoryBuilder().setGitDir(theDir)
-                               .build();
+               FileRepository r = (FileRepository) new FileRepositoryBuilder()
+                               .setGitDir(theDir).build();
                assertEqualsPath(theDir, r.getDirectory());
                assertEqualsPath(workdir, r.getWorkTree());
                assertEqualsPath(new File(theDir, "index"), r.getIndexFile());
@@ -247,8 +248,8 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase {
                repo1initial.close();
 
                File theDir = new File(repo1Parent, Constants.DOT_GIT);
-               FileRepository r = new FileRepositoryBuilder().setGitDir(theDir)
-                               .build();
+               FileRepository r = (FileRepository) new FileRepositoryBuilder()
+                               .setGitDir(theDir).build();
                assertEqualsPath(theDir, r.getDirectory());
                assertEqualsPath(workdir, r.getWorkTree());
                assertEqualsPath(new File(theDir, "index"), r.getIndexFile());
@@ -275,7 +276,7 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase {
                repo1initial.close();
 
                File theDir = new File(repo1Parent, Constants.DOT_GIT);
-               FileRepository r = new FileRepositoryBuilder() //
+               FileRepository r = (FileRepository) new FileRepositoryBuilder() //
                                .setGitDir(theDir).setObjectDirectory(objDir) //
                                .addAlternateObjectDirectory(altObjDir) //
                                .setIndexFile(indexFile) //
index 5ce85b8f67355f6e19cc7779a8a3e316fae5c748..b0f1a85c6ff339856928765088cacdaf1666d1c2 100644 (file)
@@ -49,6 +49,7 @@ import java.io.IOException;
 import org.eclipse.jgit.errors.RepositoryNotFoundException;
 import org.eclipse.jgit.internal.storage.file.FileRepository;
 import org.eclipse.jgit.lib.BaseRepositoryBuilder;
+import org.eclipse.jgit.lib.Repository;
 
 /**
  * Constructs a {@link FileRepository}.
@@ -70,7 +71,7 @@ import org.eclipse.jgit.lib.BaseRepositoryBuilder;
  * </pre>
  */
 public class FileRepositoryBuilder extends
-               BaseRepositoryBuilder<FileRepositoryBuilder, FileRepository> {
+               BaseRepositoryBuilder<FileRepositoryBuilder, Repository> {
        /**
         * Create a repository matching the configuration in this builder.
         * <p>
@@ -86,7 +87,7 @@ public class FileRepositoryBuilder extends
         *             the builder's parameters.
         */
        @Override
-       public FileRepository build() throws IOException {
+       public Repository build() throws IOException {
                FileRepository repo = new FileRepository(setup());
                if (isMustExist() && !repo.getObjectDatabase().exists())
                        throw new RepositoryNotFoundException(getGitDir());