public void initialize() throws IOException { if (!gitRepo.getDirectory().exists()) { gitRepo.create(); } else { cleanAndResetToMaster(); } }
public static Repository prepareBareRemote() throws IOException { // Create a folder in the temp folder that will act as the remote repository File remoteDir = File.createTempFile("remote", ""); remoteDir.delete(); remoteDir.mkdirs(); // Create a bare repository FileKey fileKey = FileKey.exact(remoteDir, FS.DETECTED); Repository remoteRepo = fileKey.open(false); remoteRepo.create(true); return remoteRepo; }
@Signature public void init(boolean bare) throws IOException { getWrappedObject().getRepository().create(bare); }
/** * Create a new Git repository. * <p> * Repository with working tree is created using this method. This method is * the same as {@code create(false)}. * * @throws java.io.IOException * @see #create(boolean) */ public void create() throws IOException { create(false); }
fileKey.open(false).create(true);
this.remoteRepo.create(true);
remoteRepo.create(true);
public static Repository createNewRepository() throws IOException { // prepare a new folder File localPath = File.createTempFile("TestGitRepository", ""); if(!localPath.delete()) { throw new IOException("Could not delete temporary file " + localPath); } // create the directory Repository repository = FileRepositoryBuilder.create(new File(localPath, ".git")); repository.create(); return repository; } }
public static Repository createNewRepository() throws IOException { // prepare a new folder File localPath = File.createTempFile("TestGitRepository", ""); if(!localPath.delete()) { throw new IOException("Could not delete temporary file " + localPath); } // create the directory Repository repository = FileRepositoryBuilder.create(new File(localPath, ".git")); repository.create(); return repository; } }
@BeforeClass public void setup() throws Exception { cleanUpDir(TEST_DIR); // Create a bare repository RepositoryCache.FileKey fileKey = RepositoryCache.FileKey.exact(remoteDir, FS.DETECTED); this.remoteRepo = fileKey.open(false); this.remoteRepo.create(true); this.gitForPush = Git.cloneRepository().setURI(this.remoteRepo.getDirectory().getAbsolutePath()).setDirectory(cloneDir).call(); // push an empty commit as a base for detecting changes this.gitForPush.commit().setMessage("First commit").call(); this.gitForPush.push().setRemote("origin").setRefSpecs(this.masterRefSpec).call(); this.config = ConfigBuilder.create() .addPrimitive(GitConfigMonitor.GIT_CONFIG_MONITOR_PREFIX + "." + ConfigurationKeys.GIT_MONITOR_REPO_URI, this.remoteRepo.getDirectory().getAbsolutePath()) .addPrimitive(GitConfigMonitor.GIT_CONFIG_MONITOR_PREFIX + "." + ConfigurationKeys.GIT_MONITOR_REPO_DIR, TEST_DIR + "/jobConfig") .addPrimitive(ConfigurationKeys.FLOWSPEC_STORE_DIR_KEY, TEST_DIR + "flowCatalog") .addPrimitive(ConfigurationKeys.GIT_MONITOR_POLLING_INTERVAL, 5) .build(); this.flowCatalog = new FlowCatalog(config); this.flowCatalog.startAsync().awaitRunning(); this.gitConfigMonitor = new GitConfigMonitor(this.config, this.flowCatalog); this.gitConfigMonitor.setActive(true); }
/** * Create a new Git repository. * <p> * Repository with working tree is created using this method. This method is * the same as {@code create(false)}. * * @throws java.io.IOException * @see #create(boolean) */ public void create() throws IOException { create(false); }
/** * Create a new Git repository. * <p> * Repository with working tree is created using this method. This method is * the same as {@code create(false)}. * * @throws IOException * @see #create(boolean) */ public void create() throws IOException { create(false); }
repository.create(bare); return new Git(repository, true); } catch (IOException e) {
@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(); }
@Nonnull public static Repository createRepository(@Nonnull File dir, boolean bare) throws IOException { Repository repo = new RepositoryBuilder() .readEnvironment() .setGitDir(bare ? dir : new File(dir, Constants.DOT_GIT)) .build(); repo.create(bare); return repo; }
public RepoMerger(String outputRepositoryPath, List<SubtreeConfig> subtreeConfigs) throws IOException { this.subtreeConfigs = subtreeConfigs; File file = new File(outputRepositoryPath); repository = new RepositoryBuilder().setWorkTree(file).build(); if (!repository.getDirectory().exists()) { repository.create(); } }
@Nonnull public static Repository createRepository(File dir, boolean bare) throws IOException { Repository repo = new RepositoryBuilder() .readEnvironment() .setGitDir(bare ? dir : new File(dir, DOT_GIT)) .build(); repo.create(bare); return repo; }
@Nonnull public static Repository createRepository(File dir, boolean bare) throws IOException { Repository repo = new RepositoryBuilder() .readEnvironment() .setGitDir(bare ? dir : new File(dir, DOT_GIT)) .build(); repo.create(bare); return repo; }
public static Repository emptyRepository() throws IOException { final Repository repository = new InMemoryRepository(new DfsRepositoryDescription(null)); repository.create(); return repository; } }
@Override public Git init(final DirectoryResource dir) throws IOException { FileResource<?> gitDir = dir.getChildDirectory(GIT_DIRECTORY).reify(FileResource.class); gitDir.mkdirs(); RepositoryBuilder db = new RepositoryBuilder().setGitDir(gitDir.getUnderlyingResourceObject()).setup(); Git git = new Git(db.build()); git.getRepository().create(); return git; }