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>
This commit is contained in:
parent
d35586a431
commit
38cac0acf3
|
@ -93,4 +93,19 @@ public Repository build() throws IOException {
|
|||
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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue