Search in sources :

Example 6 with DfsRepositoryDescription

use of org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription in project gerrit by GerritCodeReview.

the class GitUtil method cloneProject.

public static TestRepository<InMemoryRepository> cloneProject(Project.NameKey project, String uri) throws Exception {
    DfsRepositoryDescription desc = new DfsRepositoryDescription("clone of " + project.get());
    FS fs = FS.detect();
    // Avoid leaking user state into our tests.
    fs.setUserHome(null);
    InMemoryRepository dest = new InMemoryRepository.Builder().setRepositoryDescription(desc).setFS(fs).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);
    }
    return testRepo;
}
Also used : InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) FetchResult(org.eclipse.jgit.transport.FetchResult) Config(org.eclipse.jgit.lib.Config) DfsRepositoryDescription(org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription) FS(org.eclipse.jgit.util.FS)

Example 7 with DfsRepositoryDescription

use of org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription in project gerrit by GerritCodeReview.

the class PublicKeyCheckerTest method setUp.

@Before
public void setUp() {
    repo = new InMemoryRepository(new DfsRepositoryDescription("repo"));
    store = new PublicKeyStore(repo);
}
Also used : InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) DfsRepositoryDescription(org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription) Before(org.junit.Before)

Example 8 with DfsRepositoryDescription

use of org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription in project gerrit by GerritCodeReview.

the class PushCertificateCheckerTest method setUp.

@Before
public void setUp() throws Exception {
    TestKey key1 = validKeyWithoutExpiration();
    TestKey key3 = expiredKey();
    repo = new InMemoryRepository(new DfsRepositoryDescription("repo"));
    store = new PublicKeyStore(repo);
    store.add(key1.getPublicKeyRing());
    store.add(key3.getPublicKeyRing());
    PersonIdent ident = new PersonIdent("A U Thor", "author@example.com");
    CommitBuilder cb = new CommitBuilder();
    cb.setAuthor(ident);
    cb.setCommitter(ident);
    assertEquals(RefUpdate.Result.NEW, store.save(cb));
    signedPushConfig = new SignedPushConfig();
    signedPushConfig.setCertNonceSeed("sekret");
    signedPushConfig.setCertNonceSlopLimit(60 * 24);
    checker = newChecker(true);
}
Also used : TestKey(com.google.gerrit.gpg.testutil.TestKey) InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) SignedPushConfig(org.eclipse.jgit.transport.SignedPushConfig) PersonIdent(org.eclipse.jgit.lib.PersonIdent) CommitBuilder(org.eclipse.jgit.lib.CommitBuilder) DfsRepositoryDescription(org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription) Before(org.junit.Before)

Example 9 with DfsRepositoryDescription

use of org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription in project gerrit by GerritCodeReview.

the class NoteDbUpdateManagerTest method newBatchRefUpdate.

@SafeVarargs
private static BatchRefUpdate newBatchRefUpdate(Consumer<ReceiveCommand>... resultSetters) {
    try (Repository repo = new InMemoryRepository(new DfsRepositoryDescription("repo"))) {
        BatchRefUpdate bru = repo.getRefDatabase().newBatchUpdate();
        for (int i = 0; i < resultSetters.length; i++) {
            ReceiveCommand cmd = new ReceiveCommand(ObjectId.fromString(String.format("%039x1", i)), ObjectId.fromString(String.format("%039x2", i)), "refs/heads/branch" + i);
            bru.addCommand(cmd);
            resultSetters[i].accept(cmd);
        }
        return bru;
    }
}
Also used : ReceiveCommand(org.eclipse.jgit.transport.ReceiveCommand) InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) Repository(org.eclipse.jgit.lib.Repository) InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) DfsRepositoryDescription(org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription) BatchRefUpdate(org.eclipse.jgit.lib.BatchRefUpdate)

Example 10 with DfsRepositoryDescription

use of org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription in project gitiles by GerritCodeReview.

the class ServletTest method setUp.

@Before
public void setUp() throws Exception {
    MockSystemReader mockSystemReader = new MockSystemReader();
    SystemReader.setInstance(mockSystemReader);
    DfsRepository r = new InMemoryRepository(new DfsRepositoryDescription("repo"));
    repo = new TestRepository<>(r, new RevWalk(r), mockSystemReader);
    servlet = TestGitilesServlet.create(repo);
}
Also used : DfsRepository(org.eclipse.jgit.internal.storage.dfs.DfsRepository) InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) MockSystemReader(org.eclipse.jgit.junit.MockSystemReader) RevWalk(org.eclipse.jgit.revwalk.RevWalk) DfsRepositoryDescription(org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription) Before(org.junit.Before)

Aggregations

DfsRepositoryDescription (org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription)12 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)12 Before (org.junit.Before)10 RevWalk (org.eclipse.jgit.revwalk.RevWalk)3 Config (org.eclipse.jgit.lib.Config)2 TestKey (com.google.gerrit.gpg.testutil.TestKey)1 LifecycleManager (com.google.gerrit.lifecycle.LifecycleManager)1 Account (com.google.gerrit.reviewdb.client.Account)1 CurrentUser (com.google.gerrit.server.CurrentUser)1 RequestContext (com.google.gerrit.server.util.RequestContext)1 ThreadLocalRequestContext (com.google.gerrit.server.util.ThreadLocalRequestContext)1 InMemoryModule (com.google.gerrit.testutil.InMemoryModule)1 TestNotesMigration (com.google.gerrit.testutil.TestNotesMigration)1 Injector (com.google.inject.Injector)1 Provider (com.google.inject.Provider)1 DfsRepository (org.eclipse.jgit.internal.storage.dfs.DfsRepository)1 MockSystemReader (org.eclipse.jgit.junit.MockSystemReader)1 BatchRefUpdate (org.eclipse.jgit.lib.BatchRefUpdate)1 CommitBuilder (org.eclipse.jgit.lib.CommitBuilder)1 PersonIdent (org.eclipse.jgit.lib.PersonIdent)1