use of org.eclipse.jgit.storage.file.FileRepositoryBuilder in project fabric8 by fabric8io.
the class GitUtils method findRepository.
/**
* Returns the git repository for the current folder or null if none can be found
*/
public static Repository findRepository(File baseDir) throws IOException {
File gitFolder = io.fabric8.utils.GitHelpers.findGitFolder(baseDir);
if (gitFolder == null) {
// No git repository found
return null;
}
FileRepositoryBuilder builder = new FileRepositoryBuilder();
Repository repository = builder.readEnvironment().setGitDir(gitFolder).build();
return repository;
}
use of org.eclipse.jgit.storage.file.FileRepositoryBuilder in project winery by eclipse.
the class GitBasedRepository method getGit.
private Git getGit() throws IOException, GitAPIException {
FileRepositoryBuilder builder = new FileRepositoryBuilder();
Repository gitRepo = builder.setWorkTree(this.repository.getRepositoryRoot().toFile()).setMustExist(false).build();
String repoUrl = configuration.getRepositoryUrl();
String branch = configuration.getBranch();
Git git;
if (!Files.exists(this.repository.getRepositoryRoot().resolve(".git"))) {
if (repoUrl != null && !repoUrl.isEmpty()) {
git = cloneRepository(repoUrl, branch);
} else {
gitRepo.create();
git = new Git(gitRepo);
}
} else {
git = new Git(gitRepo);
}
return git;
}
Aggregations