@Signature public boolean isExists() throws IOException { return getWrappedObject().getRepository().getObjectDatabase().exists(); }
/** * Create a repository matching the configuration in this builder. * <p> * If an option was not set, the build method will try to default the option * based on other options. If insufficient information is available, an * exception is thrown to the caller. * * @return a repository matching this configuration. The caller is * responsible to close the repository instance when it is no longer * needed. * @throws java.lang.IllegalArgumentException * insufficient parameters were set. * @throws java.io.IOException * the repository could not be accessed to configure the rest of * the builder's parameters. */ @SuppressWarnings({ "unchecked", "resource" }) public R build() throws IOException { R repo = (R) new FileRepository(setup()); if (isMustExist() && !repo.getObjectDatabase().exists()) throw new RepositoryNotFoundException(getGitDir()); return repo; }
if (!repository.getObjectDatabase().exists()) repository.create(bare); return new Git(repository, true);
@Override public void useExistingRepository(RepoStore repoStore) throws IOException { initRepositoryField(repoStore); Preconditions.checkState(repository.isPresent()); Preconditions.checkState( repository.get().getObjectDatabase().exists() ); }
@Override public void initRepo(RepoStore repoStore) throws IOException { initRepositoryField(repoStore); Preconditions.checkState(repository.isPresent()); Repository repo = this.repository.get(); // TODO: assert that this is a fresh repo. At the moment, we can't be // sure whether the repo to be init'd doesn't exist or is just fresh // and we crashed / aborted while committing if (repo.getObjectDatabase().exists()) return; repo.create(); }
/** * hasGitRepo. * * @return true if this workspace has a git repository * @throws hudson.plugins.git.GitException if underlying git operation fails. */ @Override public boolean hasGitRepo() throws GitException { try (Repository repo = getRepository()) { return repo.getObjectDatabase().exists(); } catch (GitException e) { return false; } }
private static Repository repo(File repoDir) throws IOException { final Lock lock = getLock(repoDir); boolean success = false; lock.lock(); try { repoDir.getParentFile().mkdirs(); final Repository repo = new RepositoryBuilder().setGitDir(repoDir).setBare().build(); if (!repo.getObjectDatabase().exists()) { repo.create(true); } success = true; return repo; } finally { if (!success) { lock.unlock(); } } }
private static Repository repo(File repoDir) throws IOException { final Lock lock = getLock(repoDir); boolean success = false; lock.lock(); try { repoDir.getParentFile().mkdirs(); final Repository repo = new RepositoryBuilder().setGitDir(repoDir).setBare().build(); if (!repo.getObjectDatabase().exists()) { repo.create(true); } success = true; return repo; } finally { if (!success) { lock.unlock(); } } }
@Override public void check() throws GitRepositoryException { if (!repository.getObjectDatabase().exists()) { File path = repository.isBare() ? repository.getDirectory() : repository.getWorkTree(); throw new GitRepositoryException(path.getAbsolutePath() + " is not a Git repository."); } checked = true; }
private static Repository repo(File repoDir) throws IOException { final Lock lock = getLock(repoDir); boolean success = false; lock.lock(); try { repoDir.getParentFile().mkdirs(); final Repository repo = new RepositoryBuilder().setGitDir(repoDir).setBare().build(); if (!repo.getObjectDatabase().exists()) { repo.create(true); } success = true; return repo; } finally { if (!success) { lock.unlock(); } } }
if (bundle != null) if (!repo.getObjectDatabase().exists())
/** * Create a repository matching the configuration in this builder. * <p> * If an option was not set, the build method will try to default the option * based on other options. If insufficient information is available, an * exception is thrown to the caller. * * @return a repository matching this configuration. The caller is * responsible to close the repository instance when it is no longer * needed. * @throws IllegalArgumentException * insufficient parameters were set. * @throws IOException * the repository could not be accessed to configure the rest of * the builder's parameters. */ @SuppressWarnings({ "unchecked", "resource" }) public R build() throws IOException { R repo = (R) new FileRepository(setup()); if (isMustExist() && !repo.getObjectDatabase().exists()) throw new RepositoryNotFoundException(getGitDir()); return repo; }
private Git getWorkingFileRepository() throws GitAPIException { // Check for existing repo if (config.getWorkingFileRepository().getObjectDatabase().exists()) { return Git.wrap(config.getWorkingFileRepository()); } // Clone new repo return config.configure(pushRepository.clone(Git.cloneRepository())).setBare(true).call(); } }
/** * Create a repository matching the configuration in this builder. * <p> * If an option was not set, the build method will try to default the option * based on other options. If insufficient information is available, an * exception is thrown to the caller. * * @return a repository matching this configuration. The caller is * responsible to close the repository instance when it is no longer * needed. * @throws java.lang.IllegalArgumentException * insufficient parameters were set. * @throws java.io.IOException * the repository could not be accessed to configure the rest of * the builder's parameters. */ @SuppressWarnings({ "unchecked", "resource" }) public R build() throws IOException { R repo = (R) new FileRepository(setup()); if (isMustExist() && !repo.getObjectDatabase().exists()) throw new RepositoryNotFoundException(getGitDir()); return repo; }
if (!repository.getObjectDatabase().exists()) repository.create(bare); return new Git(repository);
if (!repository.getObjectDatabase().exists()) repository.create(bare); return new Git(repository, true);