/** * Get submodule repository at path, using the specified file system * abstraction * * @param parent * @param path * @param fs * the file system abstraction to be used * @return repository or null if repository doesn't exist * @throws IOException * @since 4.10 */ public static Repository getSubmoduleRepository(final File parent, final String path, FS fs) throws IOException { File subWorkTree = new File(parent, path); if (!subWorkTree.isDirectory()) return null; File workTree = new File(parent, path); try { return new RepositoryBuilder() // .setMustExist(true) // .setFS(fs) // .setWorkTree(workTree) // .build(); } catch (RepositoryNotFoundException e) { return null; } }
/** * Open repository * * @param dir * the repository to open. May be either the GIT_DIR, or the * working tree directory that contains {@code .git}. * @param fs * filesystem abstraction to use when accessing the repository. * @return a {@link org.eclipse.jgit.api.Git} object for the existing git * repository. Closing this instance will close the repo. * @throws java.io.IOException */ public static Git open(File dir, FS fs) throws IOException { RepositoryCache.FileKey key; key = RepositoryCache.FileKey.lenient(dir, fs); Repository db = new RepositoryBuilder().setFS(fs).setGitDir(key.getFile()) .setMustExist(true).build(); return new Git(db, true); }
static RepositoryBuilder getVerifiedRepositoryBuilder(Path basedir) { RepositoryBuilder builder = new RepositoryBuilder() .findGitDir(basedir.toFile()) .setMustExist(true); if (builder.getGitDir() == null) { throw MessageException.of("Not inside a Git work tree: " + basedir); } return builder; } }
/** * Get submodule repository at path * * @param parent * @param path * @return repository or null if repository doesn't exist * @throws IOException */ public static Repository getSubmoduleRepository(final File parent, final String path) throws IOException { File subWorkTree = new File(parent, path); if (!subWorkTree.isDirectory()) return null; File workTree = new File(parent, path); try { return new RepositoryBuilder() // .setMustExist(true) // .setFS(FS.DETECTED) // .setWorkTree(workTree) // .build(); } catch (RepositoryNotFoundException e) { return null; } }
/** * Get submodule repository at path, using the specified file system * abstraction * * @param parent * @param path * @param fs * the file system abstraction to be used * @return repository or null if repository doesn't exist * @throws IOException * @since 4.10 */ public static Repository getSubmoduleRepository(final File parent, final String path, FS fs) throws IOException { File subWorkTree = new File(parent, path); if (!subWorkTree.isDirectory()) return null; File workTree = new File(parent, path); try { return new RepositoryBuilder() // .setMustExist(true) // .setFS(fs) // .setWorkTree(workTree) // .build(); } catch (RepositoryNotFoundException e) { return null; } }
/** * Opens a JGit repository in the current directory or a parent directory. * @param basedir The directory to start with * @throws IOException If the repository cannot be opened */ public static Git openRepo( File basedir ) throws IOException { return new Git( new RepositoryBuilder().readEnvironment().findGitDir( basedir ).setMustExist( true ).build() ); }
/** * Opens a JGit repository in the current directory or a parent directory. * @param basedir The directory to start with * @throws IOException If the repository cannot be opened */ public static Git openRepo( File basedir ) throws IOException { return new Git( new RepositoryBuilder().readEnvironment().findGitDir( basedir ).setMustExist( true ).build() ); }
/** * @param dir * the repository to open. May be either the GIT_DIR, or the * working tree directory that contains {@code .git}. * @param fs * filesystem abstraction to use when accessing the repository. * @return a {@link Git} object for the existing git repository. Closing this * instance will close the repo. * @throws IOException */ public static Git open(File dir, FS fs) throws IOException { RepositoryCache.FileKey key; key = RepositoryCache.FileKey.lenient(dir, fs); Repository db = new RepositoryBuilder().setFS(fs).setGitDir(key.getFile()) .setMustExist(true).build(); return new Git(db, true); }
/** * Open repository * * @param dir * the repository to open. May be either the GIT_DIR, or the * working tree directory that contains {@code .git}. * @param fs * filesystem abstraction to use when accessing the repository. * @return a {@link org.eclipse.jgit.api.Git} object for the existing git * repository. Closing this instance will close the repo. * @throws java.io.IOException */ public static Git open(File dir, FS fs) throws IOException { RepositoryCache.FileKey key; key = RepositoryCache.FileKey.lenient(dir, fs); Repository db = new RepositoryBuilder().setFS(fs).setGitDir(key.getFile()) .setMustExist(true).build(); return new Git(db, true); }