]> source.dussan.org Git - jgit.git/commitdiff
Add convenience factory method for most used builder pattern 25/11325/3
authorMatthias Sohn <matthias.sohn@sap.com>
Tue, 19 Mar 2013 22:26:17 +0000 (23:26 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Tue, 19 Mar 2013 23:44:24 +0000 (00:44 +0100)
This will simplify to adapt EGit to the removal of FileRepository from
jgit's public API in change I2ab1327c202ef2003565e1b0770a583970e432e9.

Change-Id: If98b0b97e8f13a94d4ea7ba1be0f90d82b0fba4b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileRepositoryBuilder.java

index b0f1a85c6ff339856928765088cacdaf1666d1c2..60c916ebccace0fdb94caa4af7e20e9ab3bbdfd4 100644 (file)
@@ -93,4 +93,19 @@ public class FileRepositoryBuilder extends
                        throw new RepositoryNotFoundException(getGitDir());
                return repo;
        }
+
+       /**
+        * Convenience factory method to construct a {@link FileRepository}.
+        *
+        * @param gitDir
+        *            {@code GIT_DIR}, the repository meta directory.
+        * @return a repository matching this configuration.
+        * @throws IOException
+        *             the repository could not be accessed to configure the rest of
+        *             the builder's parameters.
+        */
+       public static Repository create(File gitDir) throws IOException {
+               return new FileRepositoryBuilder().setGitDir(gitDir).readEnvironment()
+                               .build();
+       }
 }