summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2013-03-19 23:26:17 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2013-03-20 00:44:24 +0100
commit38cac0acf3c67d8006121e84b39f7028cf91ffe9 (patch)
treeb8cc4f5f7f902b3103599c2cf0e0eaeb0c78a037
parentd35586a4311df0243d03dd825c1573942c393e0c (diff)
downloadjgit-38cac0acf3c67d8006121e84b39f7028cf91ffe9.tar.gz
jgit-38cac0acf3c67d8006121e84b39f7028cf91ffe9.zip
Add convenience factory method for most used builder pattern
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>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileRepositoryBuilder.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileRepositoryBuilder.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileRepositoryBuilder.java
index b0f1a85c6f..60c916ebcc 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileRepositoryBuilder.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileRepositoryBuilder.java
@@ -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();
+ }
}