Example usage for org.eclipse.jgit.internal.storage.dfs DfsRepositoryDescription DfsRepositoryDescription

List of usage examples for org.eclipse.jgit.internal.storage.dfs DfsRepositoryDescription DfsRepositoryDescription

Introduction

In this page you can find the example usage for org.eclipse.jgit.internal.storage.dfs DfsRepositoryDescription DfsRepositoryDescription.

Prototype

public DfsRepositoryDescription(String repositoryName) 

Source Link

Document

Initialize a new repository description.

Usage

From source file:com.benhumphreys.jgitcassandra.CassandraRepositoryResolver.java

License:Apache License

@Override
public Repository open(DaemonClient client, String name) throws RepositoryNotFoundException,
        ServiceNotAuthorizedException, ServiceNotEnabledException, ServiceMayNotContinueException {
    CassandraRepository repo = repositories.get(name);
    if (repo == null) {
        try {/*from w  ww  .java 2  s. c  om*/
            repo = new CassandraRepository(new DfsRepositoryDescription(sanitiseName(name)), storeconn);
        } catch (Exception e) {
            throw new ServiceMayNotContinueException(e);
        }
        repositories.put(name, repo);
    }
    return repo;
}

From source file:com.benhumphreys.jgitcassandra.InMemoryRepositoryResolver.java

License:Apache License

@Override
public Repository open(DaemonClient client, String name) throws RepositoryNotFoundException,
        ServiceNotAuthorizedException, ServiceNotEnabledException, ServiceMayNotContinueException {
    InMemoryRepository repo = repositories.get(name);
    if (repo == null) {
        repo = new InMemoryRepository(new DfsRepositoryDescription(name));
        repositories.put(name, repo);/*from  w w  w.  j  a  v a2 s .  com*/
    }
    return repo;
}

From source file:com.cloudata.git.jgit.CloudGitRepositoryStore.java

License:Apache License

Repository openUncached(GitRepository repo, boolean mustExist) throws IOException {
    String objectPath = repo.getObjectPath();

    // ByteString suffix = ZERO.concat(ByteString.copyFromUtf8(absolutePath)).concat(ZERO);
    // KeyValuePath refsPath = refsBase.child(suffix);

    DfsRepositoryDescription description = new DfsRepositoryDescription(objectPath);
    ObjectStorePath repoPath = new ObjectStorePath(objectStore, objectPath);
    CloudDfsRepository dfs = new CloudDfsRepository(repo.getData(), description, repoPath, dataStore, tempDir);

    try {// www  .j  a v a2 s.c  o  m
        if (!dfs.exists()) {
            if (mustExist) {
                throw new RepositoryNotFoundException(repo.getData().getName());
            }
            dfs.create(true);
            dfs.updateRef(Constants.HEAD).link("refs/heads/master");
        }
    } catch (IOException e) {
        throw new IllegalStateException("Error creating repository", e);
    }

    dfs.getConfig().setBoolean("http", null, "receivepack", true);

    return dfs;
}

From source file:com.gitblit.plugin.tbacl.MockGitblit.java

License:Apache License

@Override
public Repository getRepository(String name) {
    DfsRepositoryDescription descr = new DfsRepositoryDescription(name);
    return new InMemoryRepository(descr);
}

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();/*from   w w w . ja va2s  .c o  m*/
    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;
}

From source file:com.google.gerrit.gpg.GerritPublicKeyCheckerTest.java

License:Apache License

@Before
public void setUpInjector() throws Exception {
    Config cfg = InMemoryModule.newDefaultConfig();
    cfg.setInt("receive", null, "maxTrustDepth", 2);
    cfg.setStringList("receive", null, "trustedKey",
            ImmutableList.of(Fingerprint.toString(keyB().getPublicKey().getFingerprint()),
                    Fingerprint.toString(keyD().getPublicKey().getFingerprint())));
    Injector injector = Guice.createInjector(new InMemoryModule(cfg, new TestNotesMigration()));

    lifecycle = new LifecycleManager();
    lifecycle.add(injector);/*www. j  a v a 2  s  . co  m*/
    injector.injectMembers(this);
    lifecycle.start();

    db = schemaFactory.open();
    schemaCreator.create(db);
    userId = accountManager.authenticate(AuthRequest.forUser("user")).getAccountId();
    Account userAccount = db.accounts().get(userId);
    // Note: does not match any key in TestKeys.
    userAccount.setPreferredEmail("user@example.com");
    db.accounts().update(ImmutableList.of(userAccount));
    user = reloadUser();

    requestContext.setContext(new RequestContext() {
        @Override
        public CurrentUser getUser() {
            return user;
        }

        @Override
        public Provider<ReviewDb> getReviewDbProvider() {
            return Providers.of(db);
        }
    });

    storeRepo = new InMemoryRepository(new DfsRepositoryDescription("repo"));
    store = new PublicKeyStore(storeRepo);
}

From source file:com.google.gerrit.gpg.PublicKeyCheckerTest.java

License:Apache License

@Before
public void setUp() {
    repo = new InMemoryRepository(new DfsRepositoryDescription("repo"));
    store = new PublicKeyStore(repo);
}

From source file:com.google.gerrit.gpg.PublicKeyStoreTest.java

License:Apache License

@Before
public void setUp() throws Exception {
    tr = new TestRepository<>(new InMemoryRepository(new DfsRepositoryDescription("pubkeys")));
    store = new PublicKeyStore(tr.getRepository());
}

From source file:com.google.gerrit.gpg.PushCertificateCheckerTest.java

License:Apache License

@Before
public void setUp() throws Exception {
    TestKey key1 = TestKey.key1();//  w  ww. j  av a 2s  .com
    TestKey key3 = TestKey.key3();
    tr = new TestRepository<>(new InMemoryRepository(new DfsRepositoryDescription("repo")));
    tr.branch(REFS_GPG_KEYS).commit()
            .add(PublicKeyStore.keyObjectId(key1.getPublicKey().getKeyID()).name(), key1.getPublicKeyArmored())
            .add(PublicKeyStore.keyObjectId(key3.getPublicKey().getKeyID()).name(), key3.getPublicKeyArmored())
            .create();
    signedPushConfig = new SignedPushConfig();
    signedPushConfig.setCertNonceSeed("sekret");
    signedPushConfig.setCertNonceSlopLimit(60 * 24);

    checker = new PushCertificateChecker(new PublicKeyChecker()) {
        @Override
        protected Repository getRepository() {
            return tr.getRepository();
        }

        @Override
        protected boolean shouldClose(Repository repo) {
            return false;
        }
    };
}

From source file:com.google.gerrit.server.git.gpg.PushCertificateCheckerTest.java

License:Apache License

@Before
public void setUp() throws Exception {
    TestKey key1 = TestKey.key1();/*from w ww. j  av a 2s.  c om*/
    TestKey key3 = TestKey.key3();
    tr = new TestRepository<>(new InMemoryRepository(new DfsRepositoryDescription("repo")));
    tr.branch(RefNames.REFS_GPG_KEYS).commit()
            .add(PublicKeyStore.keyObjectId(key1.getPublicKey().getKeyID()).name(), key1.getPublicKeyArmored())
            .add(PublicKeyStore.keyObjectId(key3.getPublicKey().getKeyID()).name(), key3.getPublicKeyArmored())
            .create();
    signedPushConfig = new SignedPushConfig();
    signedPushConfig.setCertNonceSeed("sekret");
    signedPushConfig.setCertNonceSlopLimit(60 * 24);

    checker = new PushCertificateChecker(new PublicKeyChecker()) {
        @Override
        protected Repository getRepository() {
            return tr.getRepository();
        }

        @Override
        protected boolean shouldClose(Repository repo) {
            return false;
        }
    };
}