Example usage for org.eclipse.jgit.transport UploadPack setAdvertiseRefsHook

List of usage examples for org.eclipse.jgit.transport UploadPack setAdvertiseRefsHook

Introduction

In this page you can find the example usage for org.eclipse.jgit.transport UploadPack setAdvertiseRefsHook.

Prototype

public void setAdvertiseRefsHook(@Nullable AdvertiseRefsHook advertiseRefsHook) 

Source Link

Document

Set the hook used while advertising the refs to the client.

Usage

From source file:com.google.gerrit.sshd.commands.Upload.java

License:Apache License

@Override
protected void runImpl() throws IOException, Failure {
    if (!projectControl.canRunUploadPack()) {
        throw new Failure(1, "fatal: upload-pack not permitted on this server");
    }/*from  w  ww .j av  a2  s.c  o  m*/

    final UploadPack up = new UploadPack(repo);
    if (!projectControl.allRefsAreVisible()) {
        up.setAdvertiseRefsHook(
                new VisibleRefFilter(tagCache, changeCache, repo, projectControl, db.get(), true));
    }
    up.setPackConfig(config.getPackConfig());
    up.setTimeout(config.getTimeout());

    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);
    } catch (UploadValidationException e) {
        // UploadValidationException is used by the UploadValidators to
        // stop the uploadPack. We do not want this exception to go beyond this
        // point otherwise it would print a stacktrace in the logs and return an
        // internal server error to the client.
        if (!e.isOutput()) {
            up.sendMessage(e.getMessage());
        }
    }
}