Search in sources :

Example 1 with UploadPack

use of org.eclipse.jgit.transport.UploadPack in project gitblit by gitblit.

the class GitblitUploadPackFactory method create.

@Override
public UploadPack create(X req, Repository db) throws ServiceNotEnabledException, ServiceNotAuthorizedException {
    int timeout = 0;
    if (req instanceof GitDaemonClient) {
        // git daemon request is always anonymous
        GitDaemonClient client = (GitDaemonClient) req;
        // set timeout from Git daemon
        timeout = client.getDaemon().getTimeout();
    }
    UploadPack up = new UploadPack(db);
    up.setTimeout(timeout);
    return up;
}
Also used : UploadPack(org.eclipse.jgit.transport.UploadPack) GitDaemonClient(com.gitblit.transport.git.GitDaemonClient)

Example 2 with UploadPack

use of org.eclipse.jgit.transport.UploadPack in project gitblit by gitblit.

the class Upload method runImpl.

@Override
protected void runImpl() throws Failure {
    try {
        SshKey key = getContext().getClient().getKey();
        if (key != null && !key.canClone()) {
            throw new Failure(1, "Sorry, your SSH public key is not allowed to clone!");
        }
        UploadPack up = uploadPackFactory.create(getContext().getClient(), repo);
        up.upload(in, out, null);
    } catch (Exception e) {
        throw new Failure(1, "fatal: Cannot upload pack: ", e);
    }
}
Also used : SshKey(com.gitblit.transport.ssh.SshKey) UploadPack(org.eclipse.jgit.transport.UploadPack)

Example 3 with UploadPack

use of org.eclipse.jgit.transport.UploadPack in project gerrit by GerritCodeReview.

the class Upload method runImpl.

@Override
protected void runImpl() throws IOException, Failure {
    if (!projectControl.canRunUploadPack()) {
        throw new Failure(1, "fatal: upload-pack not permitted on this server");
    }
    final UploadPack up = new UploadPack(repo);
    up.setAdvertiseRefsHook(new VisibleRefFilter(tagCache, changeNotesFactory, changeCache, repo, projectControl, db, true));
    up.setPackConfig(config.getPackConfig());
    up.setTimeout(config.getTimeout());
    up.setPostUploadHook(PostUploadHookChain.newChain(Lists.newArrayList(postUploadHooks)));
    List<PreUploadHook> allPreUploadHooks = Lists.newArrayList(preUploadHooks);
    allPreUploadHooks.add(uploadValidatorsFactory.create(project, repo, session.getRemoteAddressAsString()));
    up.setPreUploadHook(PreUploadHookChain.newChain(allPreUploadHooks));
    try {
        up.upload(in, out, err);
        session.setPeerAgent(up.getPeerUserAgent());
    } catch (UploadValidationException e) {
        // internal server error to the client.
        if (!e.isOutput()) {
            up.sendMessage(e.getMessage());
        }
    }
}
Also used : PreUploadHook(org.eclipse.jgit.transport.PreUploadHook) UploadValidationException(com.google.gerrit.server.git.validators.UploadValidationException) UploadPack(org.eclipse.jgit.transport.UploadPack) VisibleRefFilter(com.google.gerrit.server.git.VisibleRefFilter)

Aggregations

UploadPack (org.eclipse.jgit.transport.UploadPack)3 GitDaemonClient (com.gitblit.transport.git.GitDaemonClient)1 SshKey (com.gitblit.transport.ssh.SshKey)1 VisibleRefFilter (com.google.gerrit.server.git.VisibleRefFilter)1 UploadValidationException (com.google.gerrit.server.git.validators.UploadValidationException)1 PreUploadHook (org.eclipse.jgit.transport.PreUploadHook)1