List of usage examples for org.eclipse.jgit.internal.storage.dfs InMemoryRepository getConfig
@Override
public StoredConfig getConfig()
From source file:com.google.gerrit.acceptance.GitUtil.java
License:Apache License
public static TestRepository<InMemoryRepository> cloneProject(Project.NameKey project, String uri) throws Exception { DfsRepositoryDescription desc = new DfsRepositoryDescription("clone of " + project.get()); InMemoryRepository dest = new InMemoryRepository.Builder().setRepositoryDescription(desc) // SshTransport depends on a real FS to read ~/.ssh/config, but // InMemoryRepository by default uses a null FS. // TODO(dborowitz): Remove when we no longer depend on SSH. .setFS(FS.detect()).build(); Config cfg = dest.getConfig(); cfg.setString("remote", "origin", "url", uri); cfg.setString("remote", "origin", "fetch", "+refs/heads/*:refs/remotes/origin/*"); TestRepository<InMemoryRepository> testRepo = newTestRepository(dest); FetchResult result = testRepo.git().fetch().setRemote("origin").call(); String originMaster = "refs/remotes/origin/master"; if (result.getTrackingRefUpdate(originMaster) != null) { testRepo.reset(originMaster);/* w w w . j a v a 2 s . c o m*/ } return testRepo; }
From source file:de.egore911.versioning.util.vcs.GitProvider.java
License:Open Source License
private InMemoryRepository initRepository() { DfsRepositoryDescription repoDesc = new DfsRepositoryDescription( "git - " + project.getName() + " on " + project.getVcsHost().getName()); InMemoryRepository repo = new InMemoryRepository(repoDesc) { @Override// w ww .j a v a 2 s .com public org.eclipse.jgit.util.FS getFS() { // Hack the InMemoryRepository to have a valid FS, eventhough it // does not have one. Otherwise the LsRemoteCommand will crash // with a NPE FS fs = super.getFS(); if (fs == null) { fs = FS.DETECTED; } return fs; } }; // Mock the configuration to contain the origin url StoredConfig config = repo.getConfig(); config.setString("remote", "origin", "url", project.getCompleteVcsPath()); return repo; }