List of usage examples for org.eclipse.jgit.internal.storage.file FileRepository getObjectDatabase
@Override
public ObjectDirectory getObjectDatabase()
From source file:com.tenxdev.ovcs.command.AbstractOvcsCommand.java
License:Open Source License
/** * checks if the current directory is a git repository and returns a * repository object if it is//from www.ja v a 2 s.c o m * * @return a repository object * @throws OvcsException * if the current directory is not a git repository */ protected FileRepository getRepoForCurrentDir() throws OvcsException { final File workingDir = new File(System.getProperty("user.dir")); final File gitDir = new File(workingDir, ".git"); if (!gitDir.exists()) { throw new OvcsException("The current directory is not a git repository"); } try { final FileRepository fileRepository = new FileRepository(gitDir); if (!fileRepository.getObjectDatabase().exists()) { throw new OvcsException("The current directory is not a git repository"); } return fileRepository; } catch (final IOException e) { throw new OvcsException("Could not open the current directory as a git repository", e); } }