List of usage examples for org.eclipse.jgit.storage.file FileRepositoryBuilder create
public static Repository create(File gitDir) throws IOException
From source file:com.buildautomation.jgit.api.CookbookHelper.java
License:Apache License
public static Repository createNewRepository() throws IOException { // prepare a new folder File localPath = File.createTempFile("TestGitRepository", ""); localPath.delete();//from www . j a v a2 s . co m // create the directory Repository repository = FileRepositoryBuilder.create(new File(localPath, ".git")); repository.create(); return repository; }
From source file:com.buildautomation.jgit.api.InitRepository.java
License:Apache License
public static void initRepository() throws IOException, GitAPIException { // run the init-call File dir = File.createTempFile("gitinit", ".test"); if (!dir.delete()) { throw new IOException("Could not delete file " + dir); }//from ww w. j av a 2 s . c o m // The Git-object has a static method to initialize a new repository try (Git git = Git.init().setDirectory(dir).call()) { System.out.println("Created a new repository at " + git.getRepository().getDirectory()); } dir = File.createTempFile("repoinit", ".test"); if (!dir.delete()) { throw new IOException("Could not delete file " + dir); } // you can also create a Repository-object directly from the try (Repository repository = FileRepositoryBuilder.create(new File(dir.getAbsolutePath(), ".git"))) { System.out.println("Created a new repository at " + repository.getDirectory()); } }
From source file:com.github.checkstyle.regression.internal.GitUtils.java
License:Open Source License
public static Repository createNewRepository() throws IOException { final File repoDir = File.createTempFile("TestTempRepository", ""); if (!repoDir.delete()) { throw new IOException("Could not delete temporary file " + repoDir); }/*from w w w. ja va 2 s. com*/ final Repository repository = FileRepositoryBuilder.create(new File(repoDir, ".git")); repository.create(); TEMP_REPOSITORIES.add(repository); return repository; }
From source file:com.googlesource.gerrit.plugins.findowners.OwnersValidatorTest.java
License:Apache License
@Before public void init() throws IOException { repoFolder = File.createTempFile("Git", ""); repoFolder.delete();/*from www. j av a2 s . co m*/ repo = FileRepositoryBuilder.create(new File(repoFolder, ".git")); repo.create(); }
From source file:com.googlesource.gerrit.plugins.uploadvalidator.TestUtils.java
License:Apache License
public static Repository createNewRepository(File repoFolder) throws IOException { Repository repository = FileRepositoryBuilder.create(new File(repoFolder, ".git")); repository.create();//from w w w . j a v a 2 s . c om return repository; }
From source file:com.nlbhub.nlb.vcs.GitAdapter.java
License:Open Source License
@Override public void initRepo(String path) throws NLBVCSException { try {/*from ww w . j a va 2s .c o m*/ m_localRepo = FileRepositoryBuilder.create(new File(path, ".git")); enableLongPaths(m_localRepo, false); m_localRepo.create(); m_git = new Git(m_localRepo); initStatuses(false); // This commit solves the problem with the incorrect HEAD revision, when files // were added but no commits has been done yet commit("Initial commit"); } catch (IOException e) { throw new NLBVCSException("Error while Git repository initialization", e); } }
From source file:com.osbitools.ws.shared.prj.web.AbstractWsPrjInit.java
License:LGPL
public static Git createGitRepo(File dir) throws Exception { Repository repo = FileRepositoryBuilder.create(dir); repo.create(false);/* w w w .j a v a 2 s .c o m*/ Git git = new Git(repo); // Commit first revision git.commit().setMessage("Repository created").call(); return git; }
From source file:edu.nju.cs.inform.jgit.helper.CookbookHelper.java
License:Apache License
public static Repository openJGitCookbookRepository() throws IOException { FileRepositoryBuilder builder = new FileRepositoryBuilder(); // Repository repository = builder // .readEnvironment() // scan environment GIT_* variables // .findGitDir() // scan up the file system tree // .build(); Repository repository = FileRepositoryBuilder.create(new File(AppConfigure.gitProjectPath)); return repository; }
From source file:edu.nju.cs.inform.jgit.porcelain.InitRepository.java
License:Apache License
public static void main(String[] args) throws IOException, GitAPIException { // run the init-call File dir = File.createTempFile("gitinit", ".test"); if (!dir.delete()) { throw new IOException("Could not delete file " + dir); }//from w w w .j a va 2 s. co m // The Git-object has a static method to initialize a new repository try (Git git = Git.init().setDirectory(dir).call()) { System.out.println("Created a new repository at " + git.getRepository().getDirectory()); } dir = File.createTempFile("repoinit", ".test"); if (!dir.delete()) { throw new IOException("Could not delete file " + dir); } // you can also create a Repository-object directly from the try (Repository repository = FileRepositoryBuilder.create(new File(dir.getAbsolutePath(), ".git"))) { System.out.println("Created a new repository at " + repository.getDirectory()); } }
From source file:edu.nju.cs.inform.jgit.unfinished.TestSubmodules.java
License:Apache License
private static File createRepository() throws IOException, GitAPIException { File dir = File.createTempFile("gitinit", ".test"); dir.delete();//w ww.jav a 2s. c o m Git.init().setDirectory(dir).call(); try (Repository repository = FileRepositoryBuilder.create(new File(dir.getAbsolutePath(), ".git"))) { System.out.println("Created a new repository at " + repository.getDirectory()); } return dir; }